From 501dfb106ad5e025f19b9cc2c88ebea52b3b9480 Mon Sep 17 00:00:00 2001
From: joncrangle <94425204+joncrangle@users.noreply.github.com>
Date: Tue, 7 Nov 2023 21:15:24 -0500
Subject: [PATCH 1/4] feat: enable multiple domains to apply same rule
---
handlers/proxy.go | 52 +++++++++++++++++++++++++----------------------
1 file changed, 28 insertions(+), 24 deletions(-)
diff --git a/handlers/proxy.go b/handlers/proxy.go
index 89d8fa8..664e9c8 100644
--- a/handlers/proxy.go
+++ b/handlers/proxy.go
@@ -172,33 +172,37 @@ func applyRules(domain string, path string, body string) string {
}
for _, rule := range rulesSet {
- if rule.Domain != domain {
- continue
- }
- if len(rule.Paths) > 0 && !StringInSlice(path, rule.Paths) {
- continue
- }
- for _, regexRule := range rule.RegexRules {
- re := regexp.MustCompile(regexRule.Match)
- body = re.ReplaceAllString(body, regexRule.Replace)
- }
- for _, injection := range rule.Injections {
- doc, err := goquery.NewDocumentFromReader(strings.NewReader(body))
- if err != nil {
- log.Fatal(err)
- }
- if injection.Replace != "" {
- doc.Find(injection.Position).ReplaceWithHtml(injection.Replace)
+ // rule.Domain can be multiple domains delimited by "|"
+ domains := strings.Split(rule.Domain, "|")
+ for _, ruleDomain := range domains {
+ if ruleDomain != domain {
+ continue
}
- if injection.Append != "" {
- doc.Find(injection.Position).AppendHtml(injection.Append)
+ if len(rule.Paths) > 0 && !StringInSlice(path, rule.Paths) {
+ continue
}
- if injection.Prepend != "" {
- doc.Find(injection.Position).PrependHtml(injection.Prepend)
+ for _, regexRule := range rule.RegexRules {
+ re := regexp.MustCompile(regexRule.Match)
+ body = re.ReplaceAllString(body, regexRule.Replace)
}
- body, err = doc.Html()
- if err != nil {
- log.Fatal(err)
+ for _, injection := range rule.Injections {
+ doc, err := goquery.NewDocumentFromReader(strings.NewReader(body))
+ if err != nil {
+ log.Fatal(err)
+ }
+ if injection.Replace != "" {
+ doc.Find(injection.Position).ReplaceWithHtml(injection.Replace)
+ }
+ if injection.Append != "" {
+ doc.Find(injection.Position).AppendHtml(injection.Append)
+ }
+ if injection.Prepend != "" {
+ doc.Find(injection.Position).PrependHtml(injection.Prepend)
+ }
+ body, err = doc.Html()
+ if err != nil {
+ log.Fatal(err)
+ }
}
}
}
From 84617b32e326d8714d8a49997481e1a8e99e960d Mon Sep 17 00:00:00 2001
From: joncrangle <94425204+joncrangle@users.noreply.github.com>
Date: Tue, 7 Nov 2023 22:44:28 -0500
Subject: [PATCH 2/4] add conde nytimes torstar usatoday washingtonpost
---
ruleset.yaml | 83 +++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 76 insertions(+), 7 deletions(-)
diff --git a/ruleset.yaml b/ruleset.yaml
index 8ca8ce7..28af5b6 100644
--- a/ruleset.yaml
+++ b/ruleset.yaml
@@ -4,21 +4,21 @@
replace:
- position: h1
- replace: |
+ replace: |
An example with a ladder ;-)
- domain: www.americanbanker.com
- paths:
+ paths:
- /news
injections:
- position: head
- append: |
+ append: |
- domain: www.nzz.ch
- paths:
+ paths:
- /international
- /sport
- /wirtschaft
@@ -46,10 +46,79 @@
- /finanze
injections:
- position: head
- append: |
+ append: |
\ No newline at end of file
+
+- domain: www.architecturaldigest.com|www.bonappetit.com|www.cntraveler.com|www.epicurious.com|www.gq.com|www.newyorker.com|www.vanityfair.com|www.vogue.com|www.wired.com
+ injections:
+ - position: head
+ append: |
+
+- domain: www.nytimes.com|www.time.com
+ injections:
+ - position: head
+ append: |
+
+- domain: www.thestar.com|www.niagarafallsreview.ca|www.stcatharinesstandard.ca|www.thepeterboroughexaminer.com|www.therecord.com|www.thespec.com|www.wellandtribune.ca
+ injections:
+ - position: head
+ append: |
+
+- domain: www.usatoday.com
+ injections:
+ - position: head
+ append: |
+
+- domain: www.washingtonpost.com
+ injections:
+ - position: head
+ append: |
+
From 1aa917e0c1549cf5798146a0954e8f686ecc1db3 Mon Sep 17 00:00:00 2001
From: joncrangle <94425204+joncrangle@users.noreply.github.com>
Date: Wed, 8 Nov 2023 00:14:10 -0500
Subject: [PATCH 3/4] unblur images on washingtonpost
---
ruleset.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ruleset.yaml b/ruleset.yaml
index 28af5b6..8f4796c 100644
--- a/ruleset.yaml
+++ b/ruleset.yaml
@@ -120,5 +120,7 @@
document.addEventListener("DOMContentLoaded", () => {
let paywall = document.querySelectorAll('div[data-qa$="-ad"], div[id="leaderboard-wrapper"], div[data-qa="subscribe-promo"]');
paywall.forEach(el => { el.remove(); });
+ const images = document.querySelectorAll('img');
+ images.forEach(image => { image.parentElement.style.filter = ''; });
});
From 5442da81b9c85497350aaefbf80ece25bc227011 Mon Sep 17 00:00:00 2001
From: Gianni Carafa
Date: Wed, 8 Nov 2023 23:36:06 +0100
Subject: [PATCH 4/4] allow domain list in rules
---
README.md | 5 ++++-
handlers/proxy.go | 14 +++++++++-----
ruleset.yaml | 26 +++++++++++++++++++++++---
3 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index c2a63c7..25cea80 100644
--- a/README.md
+++ b/README.md
@@ -121,12 +121,15 @@ See in [ruleset.yaml](ruleset.yaml) for an example.
```yaml
- domain: www.example.com
+ domains: # Additional domains to apply the rule
+ - www.example.com
+ - www.beispiel.de
regexRules:
- match:
-- domain: www.architecturaldigest.com|www.bonappetit.com|www.cntraveler.com|www.epicurious.com|www.gq.com|www.newyorker.com|www.vanityfair.com|www.vogue.com|www.wired.com
+- domains:
+ - www.architecturaldigest.com
+ - www.bonappetit.com
+ - www.cntraveler.com
+ - www.epicurious.com
+ - www.gq.com
+ - www.newyorker.com
+ - www.vanityfair.com
+ - www.vogue.com
+ - www.wired.com
injections:
- position: head
append: |
@@ -63,7 +74,9 @@
banners.forEach(el => { el.remove(); });
});
-- domain: www.nytimes.com|www.time.com
+- domains:
+ - www.nytimes.com
+ - www.time.com
injections:
- position: head
append: |
@@ -74,7 +87,14 @@
banners.forEach(el => { el.remove(); });
});
-- domain: www.thestar.com|www.niagarafallsreview.ca|www.stcatharinesstandard.ca|www.thepeterboroughexaminer.com|www.therecord.com|www.thespec.com|www.wellandtribune.ca
+- domains:
+ - www.thestar.com
+ - www.niagarafallsreview.ca
+ - www.stcatharinesstandard.ca
+ - www.thepeterboroughexaminer.com
+ - www.therecord.com
+ - www.thespec.com
+ - www.wellandtribune.ca
injections:
- position: head
append: |