mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 03:12:33 +01:00
code review
This commit is contained in:
parent
c34ee1b4b2
commit
05476e9fd3
@ -3,7 +3,7 @@ e65fbcaa573c028770f1d0afada55672 assets/ublock/redirect-resources.txt
|
|||||||
7a04294b44b88baa34cf3e4bfe0e59db assets/ublock/privacy.txt
|
7a04294b44b88baa34cf3e4bfe0e59db assets/ublock/privacy.txt
|
||||||
b2dbf435507aa0262b289c67cbef2142 assets/ublock/filters.txt
|
b2dbf435507aa0262b289c67cbef2142 assets/ublock/filters.txt
|
||||||
146704ad1c0393e342afdb416762c183 assets/ublock/badware.txt
|
146704ad1c0393e342afdb416762c183 assets/ublock/badware.txt
|
||||||
4b3df06f0b27c57cea0006ae559e078b assets/ublock/redirect.txt
|
d3e766dbd8624423a7e5fea878580ee9 assets/ublock/redirect.txt
|
||||||
e1a6bb625a9ee59cc57f6b77c76108ff assets/ublock/filter-lists.json
|
e1a6bb625a9ee59cc57f6b77c76108ff assets/ublock/filter-lists.json
|
||||||
f549ce62117ff04b63c177227b5cb288 assets/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt
|
f549ce62117ff04b63c177227b5cb288 assets/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt
|
||||||
da709032e6b674de08b7561e3f4e552d assets/thirdparties/easylist-downloads.adblockplus.org/easylist.txt
|
da709032e6b674de08b7561e3f4e552d assets/thirdparties/easylist-downloads.adblockplus.org/easylist.txt
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
# uBlock Origin -- To redirect blocked resources to friendlier contents.
|
# uBlock Origin -- To redirect blocked resources to neutered contents.
|
||||||
|
#
|
||||||
|
# The redirect tokens reference an entry in the resource library:
|
||||||
|
# https://github.com/gorhill/uBlock/blob/master/assets/ublock/redirect-resources.txt
|
||||||
|
|
||||||
||s3.amazonaws.com/homad-global-configs.schneevonmorgen.com/hd-main.js$script,domain=cdnapi.kaltura.com,redirect=hd-main.js
|
||s3.amazonaws.com/homad-global-configs.schneevonmorgen.com/hd-main.js$script,domain=cdnapi.kaltura.com,redirect=hd-main.js
|
||||||
||hgc.svonm.com/hd-main.js$script,domain=cdnapi.kaltura.com,redirect=hd-main.js
|
||hgc.svonm.com/hd-main.js$script,domain=cdnapi.kaltura.com,redirect=hd-main.js
|
||||||
|
@ -130,7 +130,7 @@ RedirectEngine.prototype.fromCompiledRule = function(line) {
|
|||||||
RedirectEngine.prototype.compileRuleFromStaticFilter = function(line) {
|
RedirectEngine.prototype.compileRuleFromStaticFilter = function(line) {
|
||||||
var matches = this.reFilterParser.exec(line);
|
var matches = this.reFilterParser.exec(line);
|
||||||
if ( matches === null || matches.length !== 4 ) {
|
if ( matches === null || matches.length !== 4 ) {
|
||||||
return '';
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pattern = (matches[1] + matches[2]).replace(/[.+?{}()|[\]\\]/g, '\\$&')
|
var pattern = (matches[1] + matches[2]).replace(/[.+?{}()|[\]\\]/g, '\\$&')
|
||||||
@ -138,7 +138,7 @@ RedirectEngine.prototype.compileRuleFromStaticFilter = function(line) {
|
|||||||
.replace(/\*/g, '.*?');
|
.replace(/\*/g, '.*?');
|
||||||
|
|
||||||
var des = matches[1];
|
var des = matches[1];
|
||||||
var types = [];
|
var type;
|
||||||
var redirect = '';
|
var redirect = '';
|
||||||
var srcs = [];
|
var srcs = [];
|
||||||
var options = matches[3].split(','), option;
|
var options = matches[3].split(','), option;
|
||||||
@ -151,20 +151,24 @@ RedirectEngine.prototype.compileRuleFromStaticFilter = function(line) {
|
|||||||
srcs = option.slice(7).split('|');
|
srcs = option.slice(7).split('|');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// One and only one type must be specified.
|
||||||
if ( option in this.supportedTypes ) {
|
if ( option in this.supportedTypes ) {
|
||||||
types.push(option);
|
if ( type !== undefined ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
type = option;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need a resource token.
|
// Need a resource token.
|
||||||
if ( redirect === '' ) {
|
if ( redirect === '' ) {
|
||||||
return '';
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need one single type (not negated).
|
// Need one single type -- not negated.
|
||||||
if ( types.length !== 1 || types[0].charAt(0) === '~' ) {
|
if ( type === undefined || type.charAt(0) === '~' ) {
|
||||||
return '';
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( des === '' ) {
|
if ( des === '' ) {
|
||||||
@ -179,10 +183,17 @@ RedirectEngine.prototype.compileRuleFromStaticFilter = function(line) {
|
|||||||
var i = srcs.length, src;
|
var i = srcs.length, src;
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
src = srcs[i];
|
src = srcs[i];
|
||||||
|
if ( src === '' ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ( src.charAt(0) === '~' ) {
|
if ( src.charAt(0) === '~' ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
out.push(srcs[i] + '\t' + des + '\t' + types[0] + '\t' + pattern + '\t' + redirect);
|
// Need at least one specific src or des.
|
||||||
|
if ( src === '*' && des === '*' ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out.push(src + '\t' + des + '\t' + type + '\t' + pattern + '\t' + redirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
@ -2053,6 +2053,9 @@ FilterContainer.prototype.compileToAtomicFilter = function(filterClass, parsed,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var redirects = µb.redirectEngine.compileRuleFromStaticFilter(parsed.raw);
|
var redirects = µb.redirectEngine.compileRuleFromStaticFilter(parsed.raw);
|
||||||
|
if ( Array.isArray(redirects) === false ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var i = redirects.length;
|
var i = redirects.length;
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
out.push('n\v\v\v=>\v' + redirects[i]);
|
out.push('n\v\v\v=>\v' + redirects[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user