mirror of
https://github.com/privacy-protection-tools/anti-AD.git
synced 2025-02-13 17:12:41 +08:00
代码升级,支持adgh官方的modifiers, 修复 #410
This commit is contained in:
parent
3b79c54d2e
commit
edc2f9a8ca
@ -1,5 +1,5 @@
|
||||
!Title: anti-AD
|
||||
!Version: 20210501095057
|
||||
!Version: 20210501104605
|
||||
!Homepage: https://github.com/privacy-protection-tools/anti-AD
|
||||
!Total lines: 38147
|
||||
||*.wap.xsbiquge.com^
|
||||
@ -75,7 +75,7 @@
|
||||
||vix.*.criteo.net^
|
||||
||vtnlog-*.elb.amazonaws.com^
|
||||
||ya*.dwstatic.com^
|
||||
||ad*.udn.com^
|
||||
||ad*.udn.com^$dnstype=~A
|
||||
||*.mgr.consensu.org^
|
||||
||vs*.gzcu.u3.ucweb.com^
|
||||
||ad*.goforandroid.com^
|
||||
@ -3290,7 +3290,7 @@
|
||||
||adversaldisplay.com^
|
||||
||adversalservers.com^
|
||||
||adverserve.net^
|
||||
/^(\S+\.)?advert/
|
||||
/^(\S+\.)?advert/$dnstype=~A
|
||||
||advfeeds.com^
|
||||
||advg.jp^
|
||||
/^(\S+\.)?widgets?\./
|
||||
|
@ -1 +1 @@
|
||||
0e910a5f124d421c134fbeec0d4cdbb1
|
||||
45c51a1343e1da09313e310c463bea1a
|
@ -21,7 +21,7 @@ define('WILDCARD_SRC', ROOT_DIR . 'origin-files/wildcard-src-easylist.txt');
|
||||
define('WHITERULE_SRC', ROOT_DIR . 'origin-files/whiterule-src-easylist.txt');
|
||||
|
||||
$ARR_MERGED_WILD_LIST = array(
|
||||
'ad*.udn.com' => null,
|
||||
'ad*.udn.com$dnstype=~A' => null,
|
||||
'*.mgr.consensu.org' => null,
|
||||
'vs*.gzcu.u3.ucweb.com' => null,
|
||||
'ad*.goforandroid.com' => null,
|
||||
@ -137,10 +137,9 @@ $ARR_MERGED_WILD_LIST = array(
|
||||
$ARR_REGEX_LIST = array(
|
||||
'/9377[a-z]{2}\.com$/' => null,
|
||||
'/^(\S+\.)?ad(s?[\d]+|m|s)?\./' => null,
|
||||
'/^(\S+\.)?advert/' => null, // TODO 覆盖面很大
|
||||
'/^(\S+\.)?advert/$dnstype=~A' => null, // TODO 覆盖面很大
|
||||
'/^(\S+\.)?affiliat(es?[0-9a-z]*?|ion[0-9\-a-z]*?|ly[0-9a-z\-]*?)\./' => null, // fixed #406
|
||||
'/^(\S+\.)?s?metrics\./' => null, // TODO 覆盖面很大
|
||||
// '/^(\S+\.)?affiliat(es|ion|e)\./' => null,
|
||||
'/afgr[\d]{1,2}\.com$/' => null,
|
||||
'/^(\S+\.)?analytics(\-|\.)/' => null,
|
||||
'/^(\S+\.)?counter(\-|\.)/' => null,
|
||||
@ -282,7 +281,12 @@ while(!feof($wild_fp)){
|
||||
|
||||
$matched = false;
|
||||
foreach($ARR_REGEX_LIST as $regex_str => $regex_row){
|
||||
if(preg_match($regex_str, str_replace('*', '',$matches[1]))){
|
||||
$arr_regex = explode('/$', $regex_str);
|
||||
$final_regex = $regex_str;
|
||||
if(count($arr_regex) > 1){
|
||||
$final_regex = $arr_regex[0] . '/';
|
||||
}
|
||||
if(preg_match($final_regex, str_replace('*', '',$matches[1]))){
|
||||
$matched = true;
|
||||
}
|
||||
}
|
||||
@ -301,18 +305,27 @@ while(!feof($src_fp)){
|
||||
continue;
|
||||
}
|
||||
|
||||
if((substr($row, 0, 1) === '!') && (substr($row, 0, 13) === '!Total lines:')){
|
||||
$insert_pos = $written_size;
|
||||
}
|
||||
|
||||
if(!preg_match('/^\|.+?/', $row)){
|
||||
if((substr($row, 0, 1) === '!')){
|
||||
if(substr($row, 0, 13) === '!Total lines:'){
|
||||
$insert_pos = $written_size;
|
||||
}
|
||||
$written_size += fwrite($new_fp, $row);
|
||||
continue;
|
||||
}
|
||||
|
||||
// if(!preg_match('/^\|.+?/', $row)){
|
||||
// $written_size += fwrite($new_fp, $row);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
$matched = false;
|
||||
foreach($ARR_REGEX_LIST as $regex_str => $regex_row){
|
||||
if(preg_match($regex_str, substr(trim($row), 2, -1))){
|
||||
$arr_regex = explode('/$', $regex_str);
|
||||
$final_regex = $regex_str;
|
||||
if(count($arr_regex) > 1){
|
||||
$final_regex = $arr_regex[0] . '/';
|
||||
}
|
||||
if(preg_match($final_regex, substr(trim($row), 2, -1))){
|
||||
$matched = true;
|
||||
if(!array_key_exists($regex_str, $wrote_wild)){
|
||||
$written_size += fwrite($new_fp, "${regex_str}\n");
|
||||
@ -329,7 +342,13 @@ while(!feof($src_fp)){
|
||||
foreach($arr_wild_src as $core_str => $wild_row){
|
||||
$match_rule = str_replace(array('.', '*'), array('\\.', '.*'), $core_str);
|
||||
if(!array_key_exists($core_str, $wrote_wild)){
|
||||
$written_size += fwrite($new_fp, "||${core_str}^\n");
|
||||
$arr_wild_sub = explode('$', $core_str);
|
||||
if(count($arr_wild_sub) > 1){
|
||||
$written_size += fwrite($new_fp, "||${arr_wild_sub[0]}^\$${arr_wild_sub[1]}\n");
|
||||
}else{
|
||||
$written_size += fwrite($new_fp, "||${core_str}^\n");
|
||||
}
|
||||
|
||||
$line_count++;
|
||||
$wrote_wild[$core_str] = 1;
|
||||
}
|
||||
@ -373,11 +392,20 @@ foreach($ARR_WHITE_RULE_LIST as $row => $v){
|
||||
foreach($wrote_wild as $core_str => $val){
|
||||
if(substr($core_str, 0, 1) === '/'){
|
||||
$match_rule = $core_str;
|
||||
$arr_regex = explode('/$', $match_rule);
|
||||
}else{
|
||||
$match_rule = str_replace(array('.', '*'), array('\\.', '.*'), $core_str);
|
||||
$match_rule = "/^${match_rule}/";
|
||||
}
|
||||
if(preg_match($match_rule, $matches[1])){
|
||||
|
||||
|
||||
$final_regex = $match_rule;
|
||||
if(count($arr_regex) > 1){
|
||||
$final_regex = $arr_regex[0] . '/';
|
||||
}
|
||||
|
||||
|
||||
if(preg_match($final_regex, $matches[1])){
|
||||
$domain = addressMaker::extract_main_domain($matches[1]);
|
||||
if(array_key_exists($domain, $black_domain_list) ||
|
||||
(is_array($black_domain_list[$domain]) && in_array($matches[1], $black_domain_list[$domain]))
|
||||
|
Loading…
Reference in New Issue
Block a user