mirror of
https://github.com/davegallant/rfd-redirect-stripper.git
synced 2025-08-05 16:23:40 +00:00
Generate tamper-monkey-script (#20)
* Generate tamper-monkey-script * Update script.js using gomplate --------- Co-authored-by: GitHub Actions <actions@users.noreply.github.com>
This commit is contained in:
30
.github/workflows/tamper-monkey.yaml
vendored
Normal file
30
.github/workflows/tamper-monkey.yaml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: "Generate Tampermonkey script"
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
gomplate:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
|
||||
- name: Install gomplate
|
||||
run: |
|
||||
wget -O gomplate https://github.com/hairyhenderson/gomplate/releases/download/v3.10.0/gomplate_linux-amd64
|
||||
chmod +x gomplate
|
||||
sudo mv gomplate /usr/local/bin/
|
||||
|
||||
- name: Run gomplate
|
||||
run: gomplate < script.js.tmpl > script.js
|
||||
|
||||
- name: Commit and push changes
|
||||
run: |
|
||||
git config --global user.name "GitHub Actions"
|
||||
git config --global user.email "actions@users.noreply.github.com"
|
||||
git add .
|
||||
git commit -m "Update script.js using gomplate" || true
|
||||
git push
|
BIN
icon-32x32.png
Normal file
BIN
icon-32x32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
163
script.js
163
script.js
@@ -16,87 +16,88 @@
|
||||
var Links = document.querySelectorAll('a.postlink, a.autolinker_link');
|
||||
|
||||
const REDIRECT_REGEX = [
|
||||
{
|
||||
name: 'Amazon',
|
||||
pattern: 'www.amazon.ca/gp/redirect.html\\?ie=UTF8&location=(?<baseUrl>.*?)(&|ref%3D|%3F)',
|
||||
},
|
||||
{
|
||||
name: 'Best Buy',
|
||||
pattern: 'bestbuyca.(.*).net(.*)\\?u=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: 'HP',
|
||||
pattern: 'www.awin1.com(.*)\&clickref=\&p=(?<baseUrl>.*)\&.*',
|
||||
},
|
||||
{
|
||||
name: 'Samsung',
|
||||
pattern: 'www.awin1.com(.*)\?p=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: 'redirectingat.com',
|
||||
pattern: 'go.redirectingat.com/.*url=(?<baseUrl>.*).*',
|
||||
},
|
||||
{
|
||||
name: 'homedepot',
|
||||
pattern: 'the-home-depot-ca.pxf.io(.*)\?u=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: 'redirectingat',
|
||||
pattern: 'go.redirectingat.com(.*)\?url=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: 'adidas-canada',
|
||||
pattern: 'adidas-canada.sjv.io(.*)\?u=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: 'canadiantire',
|
||||
pattern: 'imp.i([0-9]*).net(.*)\?u=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: 'kqzyfj',
|
||||
pattern: 'www.awin1.com(.*)\?ued=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: 'lenovo',
|
||||
pattern: '(.*).evyy.net(.*)\?u=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: 'thesource',
|
||||
pattern: 'www.kqzyfj.com(.*)?url=(?<baseUrl>.*)&sid=.*',
|
||||
},
|
||||
{
|
||||
name: 'walmart',
|
||||
pattern: 'click.linksynergy.com(.*)\?murl=(?<baseUrl>.*)&u1=.*',
|
||||
},
|
||||
{
|
||||
name: 'dpbolvw.net',
|
||||
pattern: 'www.dpbolvw.net(.*)?url=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: "jdoqocy.com",
|
||||
pattern: "www.jdoqocy.com(.*)?url=(?<baseUrl>.*)&sid=.*"
|
||||
},
|
||||
{
|
||||
name: 'pxf.io',
|
||||
pattern: '(.*).pxf.io(.*)\?u=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: 'avantlink.com',
|
||||
pattern: '(.*).avantlink.com(.*)\?url=(?<baseUrl>.*)',
|
||||
},
|
||||
{
|
||||
name: "anrdoezrs.net",
|
||||
pattern: ".*anrdoezrs\\.net.+\\?url=(?<baseUrl>.*)&sid=.+"
|
||||
},
|
||||
{
|
||||
name: "tkqlhce.com",
|
||||
pattern: ".*tkqlhce\\.com.+?url=(?<baseUrl>.*)&sid=.*"
|
||||
},
|
||||
{
|
||||
name: "staples",
|
||||
pattern: ".*staplescanada\\.4u8mqw\\.net.+\\?u=(?<baseUrl>.*)"
|
||||
}
|
||||
];
|
||||
{
|
||||
"name": "Amazon",
|
||||
"pattern": "www.amazon.ca/gp/redirect.html\\?ie=UTF8&location=(?<baseUrl>.*?)(&|ref%3D|%3F)"
|
||||
},
|
||||
{
|
||||
"name": "Best Buy",
|
||||
"pattern": "bestbuyca.(.*).net(.*)\\?u=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "HP",
|
||||
"pattern": "www.awin1.com(.*)&clickref=&p=(?<baseUrl>.*)&.*"
|
||||
},
|
||||
{
|
||||
"name": "Samsung",
|
||||
"pattern": "www.awin1.com(.*)?p=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "redirectingat.com",
|
||||
"pattern": "go.redirectingat.com/.*url=(?<baseUrl>.*).*"
|
||||
},
|
||||
{
|
||||
"name": "homedepot",
|
||||
"pattern": "the-home-depot-ca.pxf.io(.*)?u=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "redirectingat",
|
||||
"pattern": "go.redirectingat.com(.*)?url=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "adidas-canada",
|
||||
"pattern": "adidas-canada.sjv.io(.*)?u=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "canadiantire",
|
||||
"pattern": "imp.i([0-9]*).net(.*)?u=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "underarmour",
|
||||
"pattern": "www.awin1.com(.*)?ued=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "lenovo",
|
||||
"pattern": "(.*).evyy.net(.*)?u=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "kqzyfj",
|
||||
"pattern": "www.kqzyfj.com(.*)?url=(?<baseUrl>.*)&sid=.*"
|
||||
},
|
||||
{
|
||||
"name": "walmart",
|
||||
"pattern": "click.linksynergy.com(.*)?murl=(?<baseUrl>.*)&u1=.*"
|
||||
},
|
||||
{
|
||||
"name": "dpbolvw.net",
|
||||
"pattern": "www.dpbolvw.net(.*)?url=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "jdoqocy.com",
|
||||
"pattern": "www.jdoqocy.com(.*)?url=(?<baseUrl>.*)&sid=rfdcb"
|
||||
},
|
||||
{
|
||||
"name": "pfx.io",
|
||||
"pattern": "(.*).pxf.io(.*)?u=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "avantlink.com",
|
||||
"pattern": "(.*).avantlink.com(.*)?url=(?<baseUrl>.*)"
|
||||
},
|
||||
{
|
||||
"name": "anrdoezrs.net",
|
||||
"pattern": ".*anrdoezrs\\.net.+\\?url=(?<baseUrl>.*)&sid=.*"
|
||||
},
|
||||
{
|
||||
"name": "tkqlhce.com",
|
||||
"pattern": ".*tkqlhce\\.com.+?url=(?<baseUrl>.*)&sid=.*"
|
||||
},
|
||||
{
|
||||
"name": "staples",
|
||||
"pattern": ".*staplescanada\\.4u8mqw\\.net.+\\?u=(?<baseUrl>.*)"
|
||||
}
|
||||
]
|
||||
;
|
||||
|
||||
var StripRedirect = function(URL) {
|
||||
for (var i = 0; i < REDIRECT_REGEX.length; i++) {
|
||||
|
42
script.js.tmpl
Normal file
42
script.js.tmpl
Normal file
@@ -0,0 +1,42 @@
|
||||
// ==UserScript==
|
||||
// @name RedFlagDeals Redirect Stripper
|
||||
// @author Dave Gallant
|
||||
// @description Strip redirect links on forums.redflagdeals.com
|
||||
// @downloadURL https://raw.githubusercontent.com/davegallant/rfd-redirect-stripper/main/script.js
|
||||
// @grant none
|
||||
// @match *://forums.redflagdeals.com/*
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @updateURL https://raw.githubusercontent.com/davegallant/rfd-redirect-stripper/main/script.js
|
||||
// @version 0.0.1
|
||||
// ==/UserScript==
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var Links = document.querySelectorAll('a.postlink, a.autolinker_link');
|
||||
|
||||
const REDIRECT_REGEX = {{ file.Read "redirects.json" }};
|
||||
|
||||
var StripRedirect = function(URL) {
|
||||
for (var i = 0; i < REDIRECT_REGEX.length; i++) {
|
||||
var rule = REDIRECT_REGEX[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;
|
||||
};
|
||||
|
||||
Links.forEach(function(Link) {
|
||||
var ReferralURL = Link.href;
|
||||
Link.href = StripRedirect(ReferralURL);
|
||||
});
|
||||
|
||||
})();
|
Reference in New Issue
Block a user