javascript 在位于本地文件系统上的 html 文件上运行 Greasemonkey 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9931115/
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-26 08:16:47  来源:igfitidea点击:

Run Greasemonkey on html files located on the local filesystem?

javascriptgreasemonkeyuserscriptslocal-files

提问by Niklas R

I have an API documentation lying around on my Harddrive and to ease my workflow, I have written a simple script that modifies the page for my needs. I've developed it using FireBug on FireFox.

我的硬盘上有一个 API 文档,为了简化我的工作流程,我编写了一个简单的脚本来根据我的需要修改页面。我在 FireFox 上使用 FireBug 开发了它。

@include-ing webpages works correctly, but Greasemonkey does not seem to detect pages on the local file-system?

@include-ing 网页工作正常,但 Greasemonkey 似乎没有检测到本地文件系统上的页面?

I would like to have an include like

我想要一个包含像

// @include        *R13/Python*R13/*

Which should match for example

例如哪个应该匹配

file:///Z:/Eigene%20Dateien/Cinema4D/Documentations/R13/Python%20R13/modules/c4d/index.html

But it is not recognized. How can I achieve that the userscript runs on local html files, too?

但它不被认可。我怎样才能实现用户脚本也可以在本地 html 文件上运行?

Thanks in advance,

提前致谢,

回答by Mikey G

Since a couple of releases there are two new 'hidden' preferences:

greasemonkey.aboutIsGreaseable
greasemonkey.fileIsGreaseable

The default value is "false". If you want Greasemonkey to run on file:/// urls, you have to set the second one to "true" (in about:config).

由于几个版本有两个新的“隐藏”首选项:

greasemonkey.aboutIsGreaseable
greasemonkey.fileIsGreaseable

默认值为“假”。如果您希望 Greasemonkey 在 file:/// urls 上运行,您必须将第二个设置为“true”(在 about:config 中)。

Quoted from here:

从这里引用:

http://groups.google.com/group/greasemonkey-users/browse_thread/thread/ad67ee03ae92e3f0/1dc4075bdb53438a

http://groups.google.com/group/greasemonkey-users/browse_thread/thread/ad67ee03ae92e3f0/1dc4075bdb53438a

回答by samstav

tampermonkey

篡改猴子

If you're here for the same reason I am, which is -> looking for the tampermonkeyequivalent, (and you're using Chrome)... go to Chrome Preferences -> Extensions, aka chrome://extensions/, and you'll see Allow access to file URLs

如果你来这里的原因和我一样,那就是 -> 寻找等效的tampermonkey,(并且你正在使用 Chrome)......转到 Chrome 首选项 -> 扩展程序,又名 chrome://extensions/,然后你会看到 允许访问文件 URL

Allow access to file URLs

允许打开文件中的链接