我有一个简单的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://*
和file://*
作为包含的页面和脚本设置部分我http* file*
在“包含的页面”复选框。
请参阅Greasemonkey docs中的“可润滑方案”。Greasemonkeyfile://
默认情况下忽略该协议。
为了使脚本可以使用file://
路径,您需要打开about:config并将其设置extensions.greasemonkey.fileIsGreaseable
为true
。
您可能必须重新启动Firefox才能使此设置生效。
另外,// @include http* file*
语法无效。您将使用:
// @include http://*
// @include https://*
// @include file://*
除外,请尽可能避免使用此类全局包含。将脚本调整为仅显示的目标域和/或页面。
这样可以避免意外的副作用,提高性能,并减少被“零日”漏洞利用的可能性。
我还建议您删除自己编写的脚本的“用户设置”选项。这只会在以后导致心痛和混乱。;)仅将脚本的元数据部分用于您控制的脚本。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句