Stefan Kendall
Stefan Kendall

Reputation: 67892

How do I restrict chrome greasemonkey scripts to a single webpage, or just certain webpages?

Is there a way to prevent chrome from running greasemonkey scripts except for on certain domains? I could do some hackery with location.href, but it would be nice if there were a cleaner solution.

When I install by dragger script.user.js into the browser, the script automatically runs for all websites.

How do I prevent this?

Upvotes: 32

Views: 15905

Answers (2)

Satish
Satish

Reputation: 6485

using @include @exclude tags in metadata? http://diveintogreasemonkey.org/helloworld/metadata.html https://wiki.greasespot.net/Metadata_Block

Upvotes: 4

Stefan Kendall
Stefan Kendall

Reputation: 67892

Use @match, as described here.

Example:

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

Upvotes: 46

Related Questions