如何将chrome greasemonkey脚本限制为单个网页,或仅限于某些网页?

时间:2011-06-16 14:09:09

标签: javascript google-chrome greasemonkey

有没有办法阻止chrome运行greasemonkey脚本,除了某些域名?我可以用location.href做一些hackery,但是如果有一个更清洁的解决方案会很好。

当我通过拖动器script.user.js安装到浏览器中时,脚本会自动为所有网站运行。

如何防止这种情况?

2 个答案:

答案 0 :(得分:30)

使用@match,如here所述。

示例:

// ==UserScript==
// @match http://*/*
// @match http://*.google.com/*
// @match http://www.google.com/*
// ==/UserScript==

答案 1 :(得分:3)

在元数据中使用@include @exclude标记? http://diveintogreasemonkey.org/helloworld/metadata.html