mirror of
https://github.com/davegallant/rfd-redirect-stripper.git
synced 2025-08-05 08:13:40 +00:00
* add chrome support * fix alarms * Add tkqlhce.com (#12) * add tkqlhce.com * add match at beginning of regex * formatting * set config needs to come first * still need background.scripts for firefox * need full path * add onStartup listener to ensure alarm is created * set time to 60 * add manifest specific to chrome and bump version
32 lines
734 B
JavaScript
32 lines
734 B
JavaScript
function stripRedirect(URL, redirectRegex) {
|
|
for (var i = 0; i < redirectRegex.length; i++) {
|
|
var rule = redirectRegex[i];
|
|
var result = new RegExp(rule.pattern).exec(URL);
|
|
|
|
if (result) {
|
|
var newURL = result.groups.baseUrl;
|
|
try {
|
|
return decodeURIComponent(newURL);
|
|
} catch (e) {
|
|
console.log(e);
|
|
return URL;
|
|
}
|
|
}
|
|
}
|
|
|
|
return URL;
|
|
}
|
|
|
|
function stripRedirects() {
|
|
var Links = document.querySelectorAll("a.postlink, a.autolinker_link");
|
|
|
|
chrome.storage.local.get("redirects", function (result) {
|
|
Links.forEach(function (Link) {
|
|
var ReferralURL = Link.href;
|
|
Link.href = stripRedirect(ReferralURL, result["redirects"]);
|
|
});
|
|
});
|
|
}
|
|
|
|
stripRedirects();
|