1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00

Convert more resources as immutable

Related commit:
- 152cea2dfe
This commit is contained in:
Raymond Hill 2019-07-03 19:26:09 -04:00
parent 0ba9a35818
commit 8e245c8919
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
5 changed files with 81 additions and 3 deletions

View File

@ -138,6 +138,11 @@ const immutableResources = new Map([
alias: 'nano-stb.js',
redirect: false
} ],
[ 'noeval.js', {
} ],
[ 'noeval-if.js', {
redirect: false
} ],
[ 'noeval-silent.js', {
alias: 'silent-noeval.js',
} ],

View File

@ -0,0 +1,41 @@
/*******************************************************************************
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 needle = '{{1}}';
if ( needle === '' || needle === '{{1}}' ) {
needle = '.?';
} else if ( needle.slice(0,1) === '/' && needle.slice(-1) === '/' ) {
needle = needle.slice(1,-1);
} else {
needle = needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
needle = new RegExp(needle);
window.eval = new Proxy(window.eval, { // jshint ignore: line
apply: function(target, thisArg, args) {
const a = args[0];
if ( needle.test(a.toString()) === false ) {
return target.apply(thisArg, args);
}
}
});
})();

View File

@ -21,6 +21,8 @@
(function() {
'use strict';
window.eval = function() {
}.bind(window);
window.eval = new Proxy(window.eval, { // jshint ignore: line
apply: function() {
}
});
})();

View File

@ -0,0 +1,30 @@
/*******************************************************************************
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);
window.eval = new Proxy(window.eval, { // jshint ignore: line
apply: function(target, thisArg, args) {
log(`Document tried to eval... ${args[0]}\n`);
}
});
})();

View File

@ -76,7 +76,7 @@
}
const prop = chain.slice(0, pos);
let v = owner[prop];
chain = chain.slice(pos + 1);
chain = chain.slice(pos + 1);
if ( v !== undefined ) {
makeProxy(v, chain);
return;