I am trying to make firefox addon redirects connection to another link, translating ccTLD domain name to gTLD one. (http://foo.bar.co.baz/GETdata)->(http://foo.qux.com/GETdata)
I tried match pattern and other options, without any luck.
Match pattern (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) : It seems like parser does not support ccTLD(ex: foo.co.au), but only gTLD (ex: foo.com).
events.UrlFilter (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/events/UrlFilter) : It seems it's not for webRequest.
<all_urls>: I also tried to call listener for all domains, then filter it inside the listener by if(details.url.contains("domain-name")) statement, which failed. It did managed to filter other gTLD domains, but not ccTLD ones.
var pattern = "https://mdn.mozillademos.org/*";
function redirect(requestDetails) {
console.log("Redirecting: " + requestDetails.url);
return {
redirectUrl: "https://38.media.tumblr.com/tumblr_ldbj01lZiP1qe0eclo1_500.gif"
};
}
browser.webRequest.onBeforeRequest.addListener(
redirect,
{urls:[pattern], types:["image"]},
["blocking"]
);
//used MDN example code. permission is given to entire hosts in manifest.json
I can't get ccTLD filtered with any options. It seems internal parser simply can't handle it since 3rd option also failed. Am I missing something?