A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/gorhill/uBlock/commit/1888033070003cd5e6a3687a4029448bf41fccea below:

Add support for `all` filter option · gorhill/uBlock@1888033 · GitHub

@@ -75,8 +75,26 @@ const typeNameToTypeValue = {

75 75

'webrtc': 19 << 4,

76 76

'unsupported': 20 << 4

77 77

};

78 + 78 79

const otherTypeBitValue = typeNameToTypeValue.other;

79 80 81 +

// All network request types to bitmap

82 +

// bring origin to 0 (from 4 -- see typeNameToTypeValue)

83 +

// left-shift 1 by the above-calculated value

84 +

// subtract 1 to set all type bits

85 +

const allNetworkTypesBits =

86 +

(1 << (otherTypeBitValue >>> 4)) - 1;

87 + 88 +

const allTypesBits =

89 +

allNetworkTypesBits |

90 +

1 << (typeNameToTypeValue['popup'] >>> 4) - 1 |

91 +

1 << (typeNameToTypeValue['main_frame'] >>> 4) - 1 |

92 +

1 << (typeNameToTypeValue['inline-font'] >>> 4) - 1 |

93 +

1 << (typeNameToTypeValue['inline-script'] >>> 4) - 1;

94 + 95 +

const unsupportedTypeBit =

96 +

1 << (typeNameToTypeValue['unsupported'] >>> 4) - 1;

97 + 80 98

const typeValueToTypeName = {

81 99

1: 'stylesheet',

82 100

2: 'image',

@@ -1792,12 +1810,6 @@ const FilterParser = function() {

1792 1810

this.reBadCSP = /(?:^|;)\s*report-(?:to|uri)\b/;

1793 1811

this.domainOpt = '';

1794 1812

this.noTokenHash = µb.urlTokenizer.noTokenHash;

1795 -

this.unsupportedTypeBit = this.bitFromType('unsupported');

1796 -

// All network request types to bitmap

1797 -

// bring origin to 0 (from 4 -- see typeNameToTypeValue)

1798 -

// left-shift 1 by the above-calculated value

1799 -

// subtract 1 to set all type bits

1800 -

this.allNetRequestTypeBits = (1 << (otherTypeBitValue >>> 4)) - 1;

1801 1813

this.reset();

1802 1814

};

1803 1815

@@ -1807,6 +1819,7 @@ const FilterParser = function() {

1807 1819

// Transpose `ping` into `other` for now.

1808 1820 1809 1821

FilterParser.prototype.toNormalizedType = {

1822 +

'all': 'all',

1810 1823

'beacon': 'other',

1811 1824

'css': 'stylesheet',

1812 1825

'data': 'data',

@@ -1833,7 +1846,7 @@ FilterParser.prototype.toNormalizedType = {

1833 1846

'xhr': 'xmlhttprequest',

1834 1847

'xmlhttprequest': 'xmlhttprequest',

1835 1848

'webrtc': 'unsupported',

1836 -

'websocket': 'websocket'

1849 +

'websocket': 'websocket',

1837 1850

};

1838 1851 1839 1852

/******************************************************************************/

@@ -1877,24 +1890,28 @@ FilterParser.prototype.bitFromType = function(type) {

1877 1890

// Be ready to handle multiple negated types

1878 1891 1879 1892

FilterParser.prototype.parseTypeOption = function(raw, not) {

1880 -

var typeBit = this.bitFromType(this.toNormalizedType[raw]);

1893 +

const typeBit = raw !== 'all'

1894 +

? this.bitFromType(this.toNormalizedType[raw])

1895 +

: allTypesBits;

1881 1896 1882 1897

if ( !not ) {

1883 1898

this.types |= typeBit;

1884 1899

return;

1885 1900

}

1886 1901 1887 -

// Non-discrete network types can't be negated.

1888 -

if ( (typeBit & this.allNetRequestTypeBits) === 0 ) {

1902 +

// Non-network types can only toggle themselves.

1903 +

if ( (typeBit & allNetworkTypesBits) === 0 ) {

1904 +

this.types &= ~typeBit;

1889 1905

return;

1890 1906

}

1891 1907 1892 -

// Negated type: set all valid network request type bits to 1

1908 +

// Negated network type: the first negation imply all network types are

1909 +

// toggled on.

1893 1910

if (

1894 -

(typeBit & this.allNetRequestTypeBits) !== 0 &&

1895 -

(this.types & this.allNetRequestTypeBits) === 0

1911 +

(typeBit & allNetworkTypesBits) !== 0 &&

1912 +

(this.types & allNetworkTypesBits) === 0

1896 1913

) {

1897 -

this.types |= this.allNetRequestTypeBits;

1914 +

this.types |= allNetworkTypesBits;

1898 1915

}

1899 1916

this.types &= ~typeBit;

1900 1917

};

@@ -2080,8 +2097,8 @@ FilterParser.prototype.parse = function(raw) {

2080 2097

// https://github.com/gorhill/uBlock/issues/2283

2081 2098

// Abort if type is only for unsupported types, otherwise

2082 2099

// toggle off `unsupported` bit.

2083 -

if ( this.types & this.unsupportedTypeBit ) {

2084 -

this.types &= ~this.unsupportedTypeBit;

2100 +

if ( this.types & unsupportedTypeBit ) {

2101 +

this.types &= ~unsupportedTypeBit;

2085 2102

if ( this.types === 0 ) {

2086 2103

this.unsupported = true;

2087 2104

return this;

@@ -2735,6 +2752,12 @@ FilterContainer.prototype.compileToAtomicFilter = function(

2735 2752

return;

2736 2753

}

2737 2754 2755 +

// If all network types are set, just use `no_type`.

2756 +

if ( (type & allNetworkTypesBits) === allNetworkTypesBits ) {

2757 +

writer.push([ descBits, parsed.tokenHash, fdata ]);

2758 +

type &= ~allNetworkTypesBits;

2759 +

}

2760 + 2738 2761

// Specific type(s)

2739 2762

let bitOffset = 1;

2740 2763

do {

@@ -2748,9 +2771,9 @@ FilterContainer.prototype.compileToAtomicFilter = function(

2748 2771

// Only static filter with an explicit type can be redirected. If we reach

2749 2772

// this point, it's because there is one or more explicit type.

2750 2773

if ( parsed.redirect ) {

2751 -

let redirects = µb.redirectEngine.compileRuleFromStaticFilter(parsed.raw);

2774 +

const redirects = µb.redirectEngine.compileRuleFromStaticFilter(parsed.raw);

2752 2775

if ( Array.isArray(redirects) ) {

2753 -

for ( let redirect of redirects ) {

2776 +

for ( const redirect of redirects ) {

2754 2777

writer.push([ typeNameToTypeValue.redirect, redirect ]);

2755 2778

}

2756 2779

}


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4