我有一个简单的 Greasemonkey 脚本:
// ==UserScript==
// @name hello
// @namespace http://www.webmonkey.com
// @description A test of accessing documents using file:// protocol
// @include http* file*
// @grant none
// ==/UserScript==
alert("hi");
只要 URL 是以下形式,它就可以正常工作http://...
如何让脚本在表单的 URL 上运行file://...
?
在“用户设置”部分我有http://*
and file://*
作为包含的页面和脚本设置部分我有http* file*
在“包含的页面”框中。
See Greasemonkey 文档中的“Greaseable 方案”。油猴无视file://
默认协议。
对于要使用的脚本file://
路径,您需要打开关于:配置并设置extensions.greasemonkey.fileIsGreaseable
to true
.
您可能需要重新启动 Firefox 才能使此设置生效。
Also, // @include http* file*
是无效语法。你会使用:
// @include http://*
// @include https://*
// @include file://*
except, 避免使用此类全局包含尽你所能地。将脚本调整为仅您明确定位的域和/或页面。
这:避免意外的副作用,提高性能,并减少被某些“零日”漏洞攻击的机会。
我还建议您删除用户设置您自己编写的脚本的选项。这只会导致日后的心痛和困惑。 ;) 仅对您控制的脚本使用脚本的元数据部分。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)