mirror of https://github.com/gorhill/uBlock.git
minor code review: just tidying
This commit is contained in:
parent
987e26e41c
commit
102dc8b596
|
@ -89,7 +89,7 @@ return {
|
|||
firstUpdateAfter: 5 * oneMinute,
|
||||
nextUpdateAfter: 7 * oneHour,
|
||||
|
||||
selfieMagic: 'gcygyxptwycl',
|
||||
selfieMagic: 'hdnliuyxkoeg',
|
||||
selfieAfter: 7 * oneMinute,
|
||||
|
||||
pageStores: {},
|
||||
|
|
|
@ -31,29 +31,27 @@
|
|||
var µb = µBlock;
|
||||
|
||||
// fedcba9876543210
|
||||
// ||| | | |
|
||||
// ||| | | |
|
||||
// ||| | | |
|
||||
// ||| | | |
|
||||
// ||| | | +---- bit 0-6: unused
|
||||
// ||| | +---- bit 8-7: party [0 - 3]
|
||||
// ||| +---- bit 12-9: type [0 - 15]
|
||||
// ||+---- bit 13: `important`
|
||||
// |+---- bit 14: [BlockAction | AllowAction]
|
||||
// +---- bit 15: unused (to ensure valid unicode character)
|
||||
// | | | |||
|
||||
// | | | |||
|
||||
// | | | |||
|
||||
// | | | |||
|
||||
// | | | ||+---- bit 0: [BlockAction | AllowAction]
|
||||
// | | | |+---- bit 1: `important`
|
||||
// | | | +---- bit 2-3: party [0 - 3]
|
||||
// | | +---- bit 4-7: type [0 - 15]
|
||||
// | +---- bit 8-15: unused
|
||||
// +---- bit 15: never use! (to ensure valid unicode character)
|
||||
|
||||
const BlockAction = 0 << 14;
|
||||
const AllowAction = 1 << 14;
|
||||
const BlockAction = 0 << 0;
|
||||
const AllowAction = 1 << 0;
|
||||
const ToggleAction = BlockAction ^ AllowAction;
|
||||
|
||||
const Important = 1 << 13;
|
||||
|
||||
const AnyType = 1 << 9;
|
||||
const Important = 1 << 1;
|
||||
|
||||
const AnyParty = 0 << 7;
|
||||
const FirstParty = 1 << 7;
|
||||
const ThirdParty = 2 << 7;
|
||||
const SpecificParty = 3 << 7;
|
||||
const AnyParty = 0 << 2;
|
||||
const FirstParty = 1 << 2;
|
||||
const ThirdParty = 2 << 2;
|
||||
const SpecificParty = 3 << 2;
|
||||
|
||||
const BlockAnyTypeAnyParty = BlockAction | AnyType | AnyParty;
|
||||
const BlockAnyType1stParty = BlockAction | AnyType | FirstParty;
|
||||
|
@ -71,6 +69,19 @@ const AllowAnyType = AllowAction | AnyType;
|
|||
const AllowAnyParty = AllowAction | AnyParty;
|
||||
const AllowOneParty = AllowAction | SpecificParty;
|
||||
|
||||
const AnyType = 1 << 4;
|
||||
|
||||
var typeNameToTypeValue = {
|
||||
'stylesheet': 2 << 4,
|
||||
'image': 3 << 4,
|
||||
'object': 4 << 4,
|
||||
'script': 5 << 4,
|
||||
'xmlhttprequest': 6 << 4,
|
||||
'sub_frame': 7 << 4,
|
||||
'other': 8 << 4,
|
||||
'popup': 9 << 4
|
||||
};
|
||||
|
||||
var pageHostname = '';
|
||||
|
||||
var reIgnoreEmpty = /^\s+$/;
|
||||
|
@ -80,17 +91,6 @@ var reHostnameToken = /^[0-9a-z]+/g;
|
|||
var reGoodToken = /[%0-9a-z]{2,}/g;
|
||||
var reURLPostHostnameAnchors = /[\/?#]/;
|
||||
|
||||
var typeNameToTypeValue = {
|
||||
'stylesheet': 2 << 9,
|
||||
'image': 3 << 9,
|
||||
'object': 4 << 9,
|
||||
'script': 5 << 9,
|
||||
'xmlhttprequest': 6 << 9,
|
||||
'sub_frame': 7 << 9,
|
||||
'other': 8 << 9,
|
||||
'popup': 9 << 9
|
||||
};
|
||||
|
||||
// ABP filters: https://adblockplus.org/en/filters
|
||||
// regex tester: http://regex101.com/
|
||||
|
||||
|
@ -824,12 +824,16 @@ FilterManyWildcardsHostname.fromSelfie = function(s) {
|
|||
// here because the special treatment would be only for a few specific tokens,
|
||||
// not systematically done for all tokens.
|
||||
|
||||
// key=Ȁ ad count=655
|
||||
// key=Ȁ ads count=432
|
||||
// key=̀ doubleclick count= 94
|
||||
// key=Ȁ adv count= 89
|
||||
// key=Ȁ google count= 67
|
||||
// key=Ȁ banner count= 55
|
||||
// key=?? ad count=657
|
||||
// key=?? ads count=431
|
||||
// key=?? mdn count=267
|
||||
// key=?? google count=181
|
||||
// key=?? pagead2 count=166
|
||||
// key=?? doubleclick count=118
|
||||
// key=?? g count=100
|
||||
// key=?? doubleclick count=94
|
||||
// key=?? js count=88
|
||||
// key=?? adv count=88
|
||||
|
||||
var FilterBucket = function(a, b) {
|
||||
this.f = null;
|
||||
|
@ -843,6 +847,9 @@ var FilterBucket = function(a, b) {
|
|||
};
|
||||
|
||||
FilterBucket.prototype.add = function(a) {
|
||||
// If filter count > n, create dictionary in which filter buckets will be
|
||||
// keyed on prefix-suffix string. There will be a special bucket, always
|
||||
// evaluated for those filters who can't supply a two-char keys.
|
||||
this.filters.push(a);
|
||||
};
|
||||
|
||||
|
|
24
js/ublock.js
24
js/ublock.js
|
@ -224,17 +224,19 @@
|
|||
/******************************************************************************/
|
||||
|
||||
µBlock.transposeType = function(type, path) {
|
||||
if ( type === 'other' ) {
|
||||
var pos = path.lastIndexOf('.');
|
||||
if ( pos > 0 ) {
|
||||
var ext = path.slice(pos);
|
||||
if ( '.eot.ttf.otf.svg.woff'.indexOf(ext) >= 0 ) {
|
||||
return 'stylesheet';
|
||||
}
|
||||
if ( '.ico.png'.indexOf(ext) >= 0 ) {
|
||||
return 'image';
|
||||
}
|
||||
}
|
||||
if ( type !== 'other' ) {
|
||||
return type;
|
||||
}
|
||||
var pos = path.lastIndexOf('.');
|
||||
if ( pos === -1 ) {
|
||||
return type;
|
||||
}
|
||||
var ext = path.slice(pos);
|
||||
if ( '.eot.ttf.otf.svg.woff'.indexOf(ext) !== -1 ) {
|
||||
return 'stylesheet';
|
||||
}
|
||||
if ( '.ico.png.gif.jpg.jpeg'.indexOf(ext) !== -1 ) {
|
||||
return 'image';
|
||||
}
|
||||
return type;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue