-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40d8be8
commit 491bae2
Showing
4 changed files
with
180 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: "Generate Tampermonkey script" | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
gomplate: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- 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: Check for changes | ||
id: check_changes | ||
run: | | ||
git diff --exit-code || echo "Changes found" | ||
- name: Commit and push changes | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
git add . | ||
git commit -m "Update script.js using gomplate" || true | ||
git push |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
|
||
})(); |