javascript - chrome.extension.sendRequest() asynchronous problem -


i building chrome extension involves changing default css of site, code skeleton follow

chrome.extension.sendrequest({     options: "foo" }, function(response) {     if(response=='on'){   var d = document.documentelement;   var css_chunk = document.createelement("style");   css_chunk.type = "text/css";   css_chunk.innertext = "img{ visibility:hidden !important; display:none !important; } ";   d.insertbefore(css_chunk, null);               } }); 

i found it's more ajax call , therefore css not alway change before original website loaded. problem sometime "winks" short time before images disappear. there option make call synchronous?

i tied add sleep(n) outside after call , works. function optional user, i.e. if function off, page sleep(n) not reasonable.

why not use stylebot? either that, or write greasemonkey script, , save trouble of writing full extension.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -