mirror of https://github.com/gorhill/uBlock.git
parent
3613a67df5
commit
f9e680f111
|
@ -57,6 +57,14 @@ const immutableResources = new Map([
|
|||
alias: 'aopw.js',
|
||||
redirect: false
|
||||
} ],
|
||||
[ 'addEventListener-defuser.js', {
|
||||
alias: 'aeld.js',
|
||||
redirect: false
|
||||
} ],
|
||||
[ 'addEventListener-logger.js', {
|
||||
alias: 'aell.js',
|
||||
redirect: false
|
||||
} ],
|
||||
[ 'addthis_widget.js', {
|
||||
alias: 'addthis.com/addthis_widget.js',
|
||||
inject: false
|
||||
|
@ -174,6 +182,10 @@ const immutableResources = new Map([
|
|||
[ 'popads-dummy.js', {
|
||||
alias: 'popads-dummy.js',
|
||||
} ],
|
||||
[ 'remove-attr.js', {
|
||||
alias: 'ra.js',
|
||||
redirect: false
|
||||
} ],
|
||||
[ 'scorecardresearch_beacon.js', {
|
||||
alias: 'scorecardresearch.com/beacon.js',
|
||||
inject: false
|
||||
|
@ -200,6 +212,8 @@ const immutableResources = new Map([
|
|||
[ 'webrtc-if.js', {
|
||||
redirect: false
|
||||
} ],
|
||||
[ 'window.open-defuser.js', {
|
||||
} ],
|
||||
]);
|
||||
|
||||
const mimeMap = {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 2019-present Raymond Hill
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
let needle1 = '{{1}}';
|
||||
if ( needle1 === '' || needle1 === '{{1}}' ) {
|
||||
needle1 = '.?';
|
||||
} else if ( /^\/.+\/$/.test(needle1) ) {
|
||||
needle1 = needle1.slice(1,-1);
|
||||
} else {
|
||||
needle1 = needle1.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
needle1 = new RegExp(needle1);
|
||||
let needle2 = '{{2}}';
|
||||
if ( needle2 === '' || needle2 === '{{2}}' ) {
|
||||
needle2 = '.?';
|
||||
} else if ( /^\/.+\/$/.test(needle2) ) {
|
||||
needle2 = needle2.slice(1,-1);
|
||||
} else {
|
||||
needle2 = needle2.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
needle2 = new RegExp(needle2);
|
||||
self.EventTarget.prototype.addEventListener = new Proxy(
|
||||
self.EventTarget.prototype.addEventListener,
|
||||
{
|
||||
apply: function(target, thisArg, args) {
|
||||
const type = args[0].toString();
|
||||
const handler = String(args[1]);
|
||||
if (
|
||||
needle1.test(type) === false ||
|
||||
needle2.test(handler) === false
|
||||
) {
|
||||
return target.apply(thisArg, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
})();
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 2019-present Raymond Hill
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
const log = console.log.bind(console);
|
||||
self.EventTarget.prototype.addEventListener = new Proxy(
|
||||
self.EventTarget.prototype.addEventListener,
|
||||
{
|
||||
apply: function(target, thisArg, args) {
|
||||
const type = args[0].toString();
|
||||
const handler = String(args[1]);
|
||||
log('addEventListener("%s", %s)', type, handler);
|
||||
return target.apply(thisArg, args);
|
||||
}
|
||||
}
|
||||
);
|
||||
})();
|
|
@ -0,0 +1,50 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 2019-present Raymond Hill
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
const token = '{{1}}';
|
||||
if ( token === '' || token === '{{1}}' ) { return; }
|
||||
const tokens = token.split(/\s*\|\s*/);
|
||||
let selector = '{{2}}';
|
||||
if ( selector === '' || selector === '{{2}}' ) {
|
||||
selector = `[${tokens.join('],[')}]`;
|
||||
}
|
||||
const rmattr = function(ev) {
|
||||
if ( ev ) {
|
||||
window.removeEventListener(ev.type, rmattr, true);
|
||||
}
|
||||
try {
|
||||
const nodes = document.querySelectorAll(selector);
|
||||
for ( const node of nodes ) {
|
||||
for ( const attr of tokens ) {
|
||||
node.removeAttribute(attr);
|
||||
}
|
||||
}
|
||||
} catch(ex) {
|
||||
}
|
||||
};
|
||||
if ( document.readyState === 'loading' ) {
|
||||
window.addEventListener('DOMContentLoaded', rmattr, true);
|
||||
} else {
|
||||
rmattr();
|
||||
}
|
||||
})();
|
|
@ -0,0 +1,43 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 2019-present Raymond Hill
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
let result = parseInt('{{1}}', 10);
|
||||
result = isNaN(result) || result !== 0;
|
||||
let needle = '{{2}}';
|
||||
if ( needle === '' || needle === '{{2}}' ) {
|
||||
needle = '.?';
|
||||
} else if ( /^\/.+\/$/.test(needle) ) {
|
||||
needle = needle.slice(1,-1);
|
||||
} else {
|
||||
needle = needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
needle = new RegExp(needle);
|
||||
window.open = new Proxy(window.open, {
|
||||
apply: function(target, thisArg, args) {
|
||||
const url = args[0];
|
||||
if ( needle.test(url) === result ) {
|
||||
return target.apply(thisArg, args);
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
Loading…
Reference in New Issue