禁止使用 Firefox 加载特定的 JavaScript 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6291916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 20:11:50  来源:igfitidea点击:

Disabling loading specific JavaScript files with Firefox

javascriptfirefox

提问by Sander

I am looking for a way to prevent loading a specific JavaScript file on a website for any website of choice, with Firefox.

我正在寻找一种方法来防止使用 Firefox 在网站上为任何选择的网站加载特定的 JavaScript 文件。

For example: Say I don't want to load jQuery (when loading the page, not afterwards 'disabling' it). I then want to be able to set that

例如:假设我不想加载 jQuery(加载页面时,而不是之后“禁用”它)。然后我希望能够设置它

http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js

should not be loaded. The browser should complete ignore this to debug other JavaScript on the website. I don't have access to the domain directly, so that is why I am trying to do this via the browser.

不应该加载。浏览器应该完全忽略它以调试网站上的其他 JavaScript。我无法直接访问域,所以这就是我尝试通过浏览器执行此操作的原因。

So for clarity::) I don't want to disable scripts from a certain domain, but want to be able to disable certain scripts. It can be that 10 scripts are on 1 domain, so killing all 10 of them is not what I want; in that case I want to prevent loading only one.

所以为了清楚起见::) 我不想禁用来自某个域的脚本,但希望能够禁用某些脚本。可能是 10 个脚本在 1 个域上,所以杀死所有 10 个脚本不是我想要的;在这种情况下,我想防止只加载一个。

Is there a way to do so?

有没有办法这样做?

回答by xxx

Several options:

几个选项:

  1. Use the Addon "Adblock Plus". It will probably still accesses the js but does not execute it.

  2. Use the Addon "Greasemonkey", which - when cofigured right - does not even touch the js-url. But its generally harder to configure right. ;)

  3. Have a look at Firefox's buildin security policies: http://kb.mozillazine.org/Security_PoliciesHere you can block javascript on an url or even function-level

  1. 使用插件“Adblock Plus”。它可能仍会访问 js 但不会执行它。

  2. 使用插件“Greasemonkey”,当配置正确时,它甚至不会触及 js-url。但通常很难正确配置。;)

  3. 看看 Firefox 的内置安全策略:http: //kb.mozillazine.org/Security_Policies在这里,您可以在 url 甚至函数级别上阻止 javascript

回答by Lourens

Go to your hosts file C:\Windows\System32\drivers\etc(Windows) or /etc/hosts(Linux).

转到您的主机文件C:\Windows\System32\drivers\etc(Windows) 或/etc/hosts(Linux)。

Add: 127.0.0.1 ajax.googleapis.com(separated by a tab)

添加:( 127.0.0.1 ajax.googleapis.com由制表符分隔)

And reopen your browser This way the jQuery file will fail to load.

并重新打开浏览器这样 jQuery 文件将无法加载。