mirror of
https://github.com/davegallant/rfd-redirect-stripper.git
synced 2025-08-06 08:43: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 |
83
script.js
83
script.js
@@ -17,86 +17,87 @@
|
|||||||
|
|
||||||
const REDIRECT_REGEX = [
|
const REDIRECT_REGEX = [
|
||||||
{
|
{
|
||||||
name: 'Amazon',
|
"name": "Amazon",
|
||||||
pattern: 'www.amazon.ca/gp/redirect.html\\?ie=UTF8&location=(?<baseUrl>.*?)(&|ref%3D|%3F)',
|
"pattern": "www.amazon.ca/gp/redirect.html\\?ie=UTF8&location=(?<baseUrl>.*?)(&|ref%3D|%3F)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Best Buy',
|
"name": "Best Buy",
|
||||||
pattern: 'bestbuyca.(.*).net(.*)\\?u=(?<baseUrl>.*)',
|
"pattern": "bestbuyca.(.*).net(.*)\\?u=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'HP',
|
"name": "HP",
|
||||||
pattern: 'www.awin1.com(.*)\&clickref=\&p=(?<baseUrl>.*)\&.*',
|
"pattern": "www.awin1.com(.*)&clickref=&p=(?<baseUrl>.*)&.*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Samsung',
|
"name": "Samsung",
|
||||||
pattern: 'www.awin1.com(.*)\?p=(?<baseUrl>.*)',
|
"pattern": "www.awin1.com(.*)?p=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'redirectingat.com',
|
"name": "redirectingat.com",
|
||||||
pattern: 'go.redirectingat.com/.*url=(?<baseUrl>.*).*',
|
"pattern": "go.redirectingat.com/.*url=(?<baseUrl>.*).*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'homedepot',
|
"name": "homedepot",
|
||||||
pattern: 'the-home-depot-ca.pxf.io(.*)\?u=(?<baseUrl>.*)',
|
"pattern": "the-home-depot-ca.pxf.io(.*)?u=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'redirectingat',
|
"name": "redirectingat",
|
||||||
pattern: 'go.redirectingat.com(.*)\?url=(?<baseUrl>.*)',
|
"pattern": "go.redirectingat.com(.*)?url=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'adidas-canada',
|
"name": "adidas-canada",
|
||||||
pattern: 'adidas-canada.sjv.io(.*)\?u=(?<baseUrl>.*)',
|
"pattern": "adidas-canada.sjv.io(.*)?u=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'canadiantire',
|
"name": "canadiantire",
|
||||||
pattern: 'imp.i([0-9]*).net(.*)\?u=(?<baseUrl>.*)',
|
"pattern": "imp.i([0-9]*).net(.*)?u=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'kqzyfj',
|
"name": "underarmour",
|
||||||
pattern: 'www.awin1.com(.*)\?ued=(?<baseUrl>.*)',
|
"pattern": "www.awin1.com(.*)?ued=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'lenovo',
|
"name": "lenovo",
|
||||||
pattern: '(.*).evyy.net(.*)\?u=(?<baseUrl>.*)',
|
"pattern": "(.*).evyy.net(.*)?u=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'thesource',
|
"name": "kqzyfj",
|
||||||
pattern: 'www.kqzyfj.com(.*)?url=(?<baseUrl>.*)&sid=.*',
|
"pattern": "www.kqzyfj.com(.*)?url=(?<baseUrl>.*)&sid=.*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'walmart',
|
"name": "walmart",
|
||||||
pattern: 'click.linksynergy.com(.*)\?murl=(?<baseUrl>.*)&u1=.*',
|
"pattern": "click.linksynergy.com(.*)?murl=(?<baseUrl>.*)&u1=.*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'dpbolvw.net',
|
"name": "dpbolvw.net",
|
||||||
pattern: 'www.dpbolvw.net(.*)?url=(?<baseUrl>.*)',
|
"pattern": "www.dpbolvw.net(.*)?url=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "jdoqocy.com",
|
"name": "jdoqocy.com",
|
||||||
pattern: "www.jdoqocy.com(.*)?url=(?<baseUrl>.*)&sid=.*"
|
"pattern": "www.jdoqocy.com(.*)?url=(?<baseUrl>.*)&sid=rfdcb"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'pxf.io',
|
"name": "pfx.io",
|
||||||
pattern: '(.*).pxf.io(.*)\?u=(?<baseUrl>.*)',
|
"pattern": "(.*).pxf.io(.*)?u=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'avantlink.com',
|
"name": "avantlink.com",
|
||||||
pattern: '(.*).avantlink.com(.*)\?url=(?<baseUrl>.*)',
|
"pattern": "(.*).avantlink.com(.*)?url=(?<baseUrl>.*)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "anrdoezrs.net",
|
"name": "anrdoezrs.net",
|
||||||
pattern: ".*anrdoezrs\\.net.+\\?url=(?<baseUrl>.*)&sid=.+"
|
"pattern": ".*anrdoezrs\\.net.+\\?url=(?<baseUrl>.*)&sid=.*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "tkqlhce.com",
|
"name": "tkqlhce.com",
|
||||||
pattern: ".*tkqlhce\\.com.+?url=(?<baseUrl>.*)&sid=.*"
|
"pattern": ".*tkqlhce\\.com.+?url=(?<baseUrl>.*)&sid=.*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "staples",
|
"name": "staples",
|
||||||
pattern: ".*staplescanada\\.4u8mqw\\.net.+\\?u=(?<baseUrl>.*)"
|
"pattern": ".*staplescanada\\.4u8mqw\\.net.+\\?u=(?<baseUrl>.*)"
|
||||||
}
|
}
|
||||||
];
|
]
|
||||||
|
;
|
||||||
|
|
||||||
var StripRedirect = function(URL) {
|
var StripRedirect = function(URL) {
|
||||||
for (var i = 0; i < REDIRECT_REGEX.length; i++) {
|
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