clean up
This commit is contained in:
@@ -116,7 +116,7 @@ func loadRules() RuleSet {
|
|||||||
return RulesList
|
return RulesList
|
||||||
}
|
}
|
||||||
log.Println("Loading rules")
|
log.Println("Loading rules")
|
||||||
// TODO: Load the rules from the URL
|
|
||||||
resp, err := http.Get(rulesUrl)
|
resp, err := http.Get(rulesUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("ERROR:", err)
|
log.Println("ERROR:", err)
|
||||||
@@ -149,10 +149,11 @@ func applyRules(domain string, path string, body string) string {
|
|||||||
if rule.Path != "" && rule.Path != path {
|
if rule.Path != "" && rule.Path != path {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, domRule := range rule.DomRules {
|
/*
|
||||||
re := regexp.MustCompile(domRule.Match)
|
for _, domRule := range rule.DomRules {
|
||||||
body = re.ReplaceAllString(body, domRule.Replace)
|
// run the dom rules
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
for _, regexRule := range rule.RegexRules {
|
for _, regexRule := range rule.RegexRules {
|
||||||
re := regexp.MustCompile(regexRule.Match)
|
re := regexp.MustCompile(regexRule.Match)
|
||||||
body = re.ReplaceAllString(body, regexRule.Replace)
|
body = re.ReplaceAllString(body, regexRule.Replace)
|
||||||
|
|||||||
29
ruleset.yaml
29
ruleset.yaml
@@ -1,24 +1,15 @@
|
|||||||
- domain: www.example.ch
|
- domain: www.example.com
|
||||||
path: /article
|
path: /article
|
||||||
regexRules:
|
regexRules:
|
||||||
- match: "asdf"
|
- match: <script\s+([^>]*\s+)?src="(/)([^"]*)"
|
||||||
replace: "asdf"
|
replace: <script $1 script="/https://www.example.com/$3"
|
||||||
- match: "asdf"
|
|
||||||
replace: "asdf"
|
|
||||||
domRules:
|
domRules:
|
||||||
- match: "asdf"
|
- match: "tobe.defined"
|
||||||
replace: "asdf"
|
replace: "test"
|
||||||
- match: "asdf"
|
- domain: www.anotherdomain.com
|
||||||
replace: "asdf"
|
|
||||||
- domain: www.srf.ch
|
|
||||||
path: /article
|
|
||||||
regexRules:
|
regexRules:
|
||||||
- match: "asdf"
|
- match: <script\s+([^>]*\s+)?src="(/)([^"]*)"
|
||||||
replace: "asdf"
|
replace: <script $1 script="/https://www.example.com/$3"
|
||||||
- match: "asdf"
|
|
||||||
replace: "asdf"
|
|
||||||
domRules:
|
domRules:
|
||||||
- match: "asdf"
|
- match: "tobe.defined"
|
||||||
replace: "asdf"
|
replace: "test"
|
||||||
- match: "asdf"
|
|
||||||
replace: "asdf"
|
|
||||||
Reference in New Issue
Block a user