Greasemonkey: V4 @match behaves differently than V3 and TamperMonkey

Created on 15 Nov 2017  路  8Comments  路  Source: greasemonkey/greasemonkey

My script has following entries (sanitized at those are intranet addresses):

// @match        http://*.some-net.net/*
// @match        http://*.some-net.net/*
// @match        https://*.some-othernet.net/*
// @match        https://*.some-othernet.net/*

On V3/tampermonkey it works for all following addresses examples (both http and https)

[1] service.some-net.net
[2] service.some-othernet.net
[3] service.some-net.net:1234
[4] service.some-othernet.net:1234
[5] service.customer.some-net.net:1234
[6] service.customer.location.some-net.net

Hovewer on V4 [3][4] and [5] does not work. For [3] fix was to add those to match the port too:

// @match        http://*.some-net.net:*/*
// @match        http://*.some-net.net:*/*
// @match        https://*.some-othernet.net:*/*
// @match        https://*.some-othernet.net:*/*

As for [5] i tried this, but even it does not help

// @match        http://*.*.some-net.net:*/*
// @match        http://*.*.some-net.net:*/*
// @match        https://*.*.some-othernet.net:*/*
// @match        https://*.*.some-othernet.net:*/*

And this does not make any sense for me as [6] work on first (original) rule set alone.

All 8 comments

The official documentation is terse and doesn't mention ports at all. Will be sure to include a test when fixing, to prevent regressions.

That said comparing the new/old code:

I'm unclear how this happened, it didn't change.

Well, maybe something changed in method that is used to get current URL. Everyone with new Firefox has this issue, for others using old FF/Chrome it's working.
Unfortunately when I wanted to modify XPI to add some prints I found that it needs to be signed....

There's a Bugzilla about match and ports. Not sure what the resolution was. Will see if I can find it.

Buzilla on match and ports. Here.

Ok, back in 3.x days we used nsIURI, which had separately host, port, and hostport. Now we have to use URL which still has something called host -- but it means hostport. We need to use hostname.

Not directly related to the problem functionality, but guarantees compatibility with FF implementation. Should said API be implemented.

https://bugzilla.mozilla.org/show_bug.cgi?id=1395278

This fix should be in 4.1beta6; testing and confirming this would be very appreciated!

https://addons.mozilla.org/firefox/downloads/file/800957/greasemonkey-4.1beta6-an+fx.xpi?src=devhub

Checked now and seems to work properly. Thanks!

Was this page helpful?
0 / 5 - 0 ratings