我试图阻止某个站点能够使用 javascript 将浏览器重定向到另一个页面。有问题的脚本是内联脚本,因此 Greasemonkey 和 adBlock 对此无能为力。
可配置的安全策略 (CAPS) 似乎是答案,但我无法使用它,而且我window.location
所有的搜索都没有发现任何有用的东西。该脚本如下所示:
<script>
window.location = "someotherpage.html";
</script>
Run Code Online (Sandbox Code Playgroud)
这就是我在 user.js 文件中尝试过的:
user_pref("capability.policy.policynames", "noredirect");
user_pref("capability.policy.noredirect.sites", "http://www.zshare.net http://127.0.0.1");
user_pref("capability.policy.noredirect.Window.Location.replace", "noAccess");
user_pref("capability.policy.noredirect.Window.Location.assign", "noAccess");
user_pref("capability.policy.noredirect.Window.Location.reload", "noAccess");
user_pref("capability.policy.noredirect.Window.Location", "noAccess");
user_pref("capability.policy.noredirect.Document.Location.replace", "noAccess");
user_pref("capability.policy.noredirect.Document.Location.assign", "noAccess");
user_pref("capability.policy.noredirect.Document.Location.reload", "noAccess");
user_pref("capability.policy.noredirect.Document.Location", "noAccess");
user_pref("capability.policy.noredirect.Location.replace", "noAccess");
user_pref("capability.policy.noredirect.Location.assign", "noAccess");
user_pref("capability.policy.noredirect.Location.reload", "noAccess");
user_pref("capability.policy.noredirect.Location", "noAccess");
Run Code Online (Sandbox Code Playgroud)
我一直在本地托管的页面上对其进行测试,并且能够阻止警报功能,但我尝试的任何内容都无法禁用window.location
.
有谁知道如何做到这一点?
我正在访问一个网站,但它会在大约 2 秒内自动重定向到另一个网站,然后我才能单击 Firefox 中的停止按钮。例如,这个网站 www.duda.org
所以我想知道是否可以停止自动定向?
感谢致敬!