Stop slow-loading script with GreaseMonkey

久未见 提交于 2019-12-11 13:59:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!