Skip to content

Commit

Permalink
feat: Action support both single and multi
Browse files Browse the repository at this point in the history
  • Loading branch information
zu1k committed Oct 12, 2021
1 parent 79378dd commit 052562a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
27 changes: 13 additions & 14 deletions rules/ads.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@
filter:
url-regex: '(nfmovies)(?!.*?(\.css|\.js|\.jpeg|\.png|\.gif)).*'
action:
- modify-response:
body:
origin: '<head>'
new: '<link rel="stylesheet" href="https://limbopro.com/CSS/nfmovies.css" type="text/css"><script type="text/javascript" src="//limbopro.com/Adguard/nfmovies.js"></script></head>'
modify-response:
body:
origin: '<head>'
new: '<link rel="stylesheet" href="https://limbopro.com/CSS/nfmovies.css" type="text/css"><script type="text/javascript" src="//limbopro.com/Adguard/nfmovies.js"></script></head>'

- name: "低端影视去广告"
filter:
domain-prefix: 'ddrk.me'
action:
- modify-response:
body:
origin: '<head>'
new: '<head><link rel="stylesheet" href="https://limbopro.com/CSS/ddrk.css" type="text/css"><script type="text/javascript" src="//limbopro.com/Adguard/ddrk.js"></script>'
modify-response:
body:
origin: '<head>'
new: '<head><link rel="stylesheet" href="https://limbopro.com/CSS/ddrk.css" type="text/css"><script type="text/javascript" src="//limbopro.com/Adguard/ddrk.js"></script>'

- name: "www.pianku.li 片库网"
filter:
domain-keyword: 'pianku'
action:
- modify-response:
body:
origin: '</body>'
new: '<link rel="stylesheet" href="https://limbopro.com/CSS/mypianku.css" type="text/css"><script type="text/javascript" src="//limbopro.com/Adguard/mypianku.js"></script></body>'
modify-response:
body:
origin: '</body>'
new: '<link rel="stylesheet" href="https://limbopro.com/CSS/mypianku.css" type="text/css"><script type="text/javascript" src="//limbopro.com/Adguard/mypianku.js"></script></body>'

- name: "m.yhdm.io 樱花动漫"
filter:
url-regex: '^http:\/\/m\.yhdm\.io\/bar\/yfgg\.js'
action:
- reject
action: reject
9 changes: 8 additions & 1 deletion src/rule/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ use std::{error::Error, fs::File, io::BufReader, path::Path};
pub struct Rule {
pub name: String,
pub filter: Filter,
pub action: Vec<action::Action>,
pub action: Actions,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum Actions {
Action(action::Action),
MultiActions(Vec<action::Action>),
}

#[derive(Debug, Clone, Deserialize, Serialize)]
Expand Down
5 changes: 4 additions & 1 deletion src/rule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ impl From<file::Rule> for Rule {
};
Self {
filter,
action: rule.action,
action: match rule.action {
file::Actions::Action(action) => vec![action],
file::Actions::MultiActions(actions) => actions,
},
url: None,
}
}
Expand Down

0 comments on commit 052562a

Please sign in to comment.