add another domain
This commit is contained in:
@@ -164,7 +164,7 @@ func applyRules(domain string, path string, body string) string {
|
||||
if rule.Domain != domain {
|
||||
continue
|
||||
}
|
||||
if rule.Path != "" && !strings.HasPrefix(path, rule.Path) {
|
||||
if len(rule.Paths) > 0 && !StringInSlice(path, rule.Paths) {
|
||||
continue
|
||||
}
|
||||
for _, regexRule := range rule.RegexRules {
|
||||
@@ -180,7 +180,6 @@ func applyRules(domain string, path string, body string) string {
|
||||
doc.Find(injection.Position).ReplaceWithHtml(injection.Replace)
|
||||
}
|
||||
if injection.Append != "" {
|
||||
log.Println("Appending", injection.Append)
|
||||
doc.Find(injection.Position).AppendHtml(injection.Append)
|
||||
}
|
||||
if injection.Prepend != "" {
|
||||
@@ -203,7 +202,7 @@ type Rule struct {
|
||||
|
||||
type RuleSet []struct {
|
||||
Domain string `yaml:"domain"`
|
||||
Path string `yaml:"path,omitempty"`
|
||||
Paths []string `yaml:"paths,omitempty"`
|
||||
GoogleCache bool `yaml:"googleCache,omitempty"`
|
||||
RegexRules []Rule `yaml:"regexRules"`
|
||||
Injections []struct {
|
||||
@@ -213,3 +212,12 @@ type RuleSet []struct {
|
||||
Replace string `yaml:"replace"`
|
||||
} `yaml:"injections"`
|
||||
}
|
||||
|
||||
func StringInSlice(s string, list []string) bool {
|
||||
for _, x := range list {
|
||||
if strings.HasPrefix(s, x) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
30
ruleset.yaml
30
ruleset.yaml
@@ -10,8 +10,12 @@
|
||||
console.log("test");
|
||||
alert("Hello!");
|
||||
</script>
|
||||
- position: h1
|
||||
replace: |
|
||||
<h1>An example with a ladder ;-)</h1>
|
||||
- domain: www.americanbanker.com
|
||||
path: /news
|
||||
paths:
|
||||
- /news
|
||||
injections:
|
||||
- position: head
|
||||
append: |
|
||||
@@ -25,3 +29,27 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
- domain: www.nzz.ch
|
||||
paths:
|
||||
- /international
|
||||
- /sport
|
||||
- /wirtschaft
|
||||
- /technologie
|
||||
- /feuilleton
|
||||
- /zuerich
|
||||
- /wissenschaft
|
||||
- /gesellschaft
|
||||
- /panorama
|
||||
- /mobilitaet
|
||||
- /reisen
|
||||
- /meinung
|
||||
- /finanze
|
||||
injections:
|
||||
- position: head
|
||||
append: |
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const paywall = document.querySelector('.dynamic-regwall');
|
||||
removeDOMElement(paywall)
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user