问题
On a page that I visit, it has a slow-loading external script that occasionally takes so long that the page is basically unusable. Disabling this script entirely removes some functionality, but it's better than nothing.
Is there a way I could use greasemonkey to cancel the script? I know I could use NoScript, but I wanted to give it a chance (with a JS timeout).
I kind of doubt it (since Greasemonkey doesn't even seem to run scripts until the page has finished loading), but I wanted to check to be sure
回答1:
Is that script located at a different domain (that's not used by (almost) anything else)?
If so, you can block access to it by changing your hosts
file; e.g., see http://someonewhocares.org/hosts/
回答2:
Quite possibly not. Since Greasemonkey runs last, you can't remove the tag before it happens, and I'm pretty darn sure that no form of Javascript will let you kill an HTTP request of any sort.
Have you tried just plain removing the script tag before it finishes loading completely, though? I suspect that in some browsers that might do the trick, since I think Greasemonkey scripts run on DOMReady, not onload.
来源:https://stackoverflow.com/questions/3190356/stop-slow-loading-script-with-greasemonkey