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
Post a Comment