71

I have to include all sites in tampermonkey..this is the script that i have to run

// ==UserScript==
// @name       Phishing Blockz
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description Phishing block based on hyperlinks
// @match      http://*/*
// @run-at     document-end

var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.status;
var locheader=req.getResponseHeader("Location");
alert(headers);
alert(locheader);

Have I done something wrong.please help me to run this userscript in all pages in chrome

user1972757
  • 721
  • 1
  • 5
  • 6

5 Answers5

94
// @match      http://*/*

will only match addresses starting with http://... but not https://... for example.

Use the following to include all addresses if that's what you really require (including local pages you may have saved on your hard-drive!)..

// @match      *://*/*

Note: The method below also works at the time of writing by virtue of a potential bug or undocumented feature in TM2.12 (so could well be subject to change in future versions!!):

// @match      *
Richard Plester
  • 1,138
  • 6
  • 11
  • 5
    `@match *` is not a valid pattern. See the doc page and there can be more than one `@match` line. The OP's metadata block is corrupt and the OP appears to have abandoned this question. – Brock Adams Apr 17 '13 at 01:09
  • Shame on OP if has abandoned, though it's still a useful QA. Would the generally correct syntax be _// @match *//*/*_ ? For the record I have scripts with _match *_ working under TamperMonkey 2.12! – Richard Plester Apr 17 '13 at 08:42
  • Close, you need the colon. See [the doc](http://developer.chrome.com/extensions/match_patterns.html). That's interesting about `*` in Tampermonkey. I'm going off the Chrome rules -- which are supposed to be the master for `@match` in both Greasemonkey and Tampermonkey. I wonder if Tampermonkey works despite the error -- while Chrome does not. I'll test this at some point. – Brock Adams Apr 17 '13 at 08:56
  • I did try it in TM before answering/commenting on the question which is specific to TM - and it definitely works ;) – Richard Plester Apr 17 '13 at 11:39
  • 2
    Okay tested it myself and `*` works while `` does not! There is no error in Tampermonkey, even in verbose mode, for either one. This is all a bug, AFAIC, and it's not consistent with Chrome nor Greasemonkey. Still, your answer is more correct than I thought. +1. – Brock Adams Apr 17 '13 at 12:03
  • Tampermonkey is documented as not supporting , so that is a feature. On further investigation I concur _match *_ is a deviation from the Chrome extensions documentation which TM offers as a reference (in lieu of stand alone documentation), so this is a bug. I will amend my answer (and scripts!) to future-proof. – Richard Plester Apr 17 '13 at 13:03
  • `` is not meant to be matched literally. The doc was written like that to mean `http://www.google.com/` or `http://www.facebook.com/` or `https://stackoverflow.com/`, in other words any valid url can be matched exactly to only run on that url page. – Ignat Jul 26 '17 at 17:34
  • 1
    Tampermonkey no longer supports '*", so use the more appropriate suggestions shown here now... – Kevin Dec 03 '18 at 06:52
18

// @match *://*/*

This should find all URLs. Using TamperMonkey/GreaseMonkey

// ==UserScript==
// @name         Match Every Site
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  I will pop up on every site!!
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

alert("I am working!")

This might be useful for browser-extensions on some pages:

So accordingly: *://*/* matches all HTTP, HTTPS, and WebSocket URLs.

Joe
  • 879
  • 3
  • 14
  • 37
8

Doing @include instead of @match works quite nicely

// ==UserScript==
// @name       Phishing Blockz
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description Phishing block based on hyperlinks
// @include     *
// @run-at     document-end

this works on all websites across the web (tested in TamperMonkey)

əkaunt
  • 109
  • 1
  • 3
4

The real answer would be to have:

// @match https://*/*
// @match http://*/*
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
  • Latest documentation from https://www.tampermonkey.net/documentation.php#_match says that it is possible to simple include `'http*://'.` It does widen the scope, but I think it is highly unlikely there are other protocols that start with http and are not http/https. – powersource97 Jul 30 '20 at 04:23
  • Please upvote this one as there is obsolete answer in any others – Nicolas Thery Nov 26 '22 at 09:40
0

For me, using

// @match https://*/*
// @match http://*/*

DOES NOT work. Rather, I have to use @include for tampermonkey to load scripts on all pages in my device,

// @include https://*/*
// @include http://*/*

FYI: I am using tampermonkey in Fennec v105.1(Firefox android version in F-droid) running in android 10