mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-04 16:47:15 +02:00
Improve google-analytics shim
Related issue: - https://github.com/uBlockOrigin/uAssets/issues/11456
This commit is contained in:
parent
250cf96aae
commit
fba680f9ab
@ -76,15 +76,22 @@
|
|||||||
if ( dl instanceof Object ) {
|
if ( dl instanceof Object ) {
|
||||||
if ( dl.hide instanceof Object && typeof dl.hide.end === 'function' ) {
|
if ( dl.hide instanceof Object && typeof dl.hide.end === 'function' ) {
|
||||||
dl.hide.end();
|
dl.hide.end();
|
||||||
|
dl.hide.end = ()=>{};
|
||||||
}
|
}
|
||||||
if ( typeof dl.push === 'function' ) {
|
if ( typeof dl.push === 'function' ) {
|
||||||
const doCallback = function(item) {
|
const doCallback = function(item) {
|
||||||
if ( item instanceof Object === false ) { return; }
|
if ( item instanceof Object === false ) { return; }
|
||||||
if ( typeof item.eventCallback !== 'function' ) { return; }
|
if ( typeof item.eventCallback !== 'function' ) { return; }
|
||||||
setTimeout(item.eventCallback, 1);
|
setTimeout(item.eventCallback, 1);
|
||||||
|
item.eventCallback = ()=>{};
|
||||||
};
|
};
|
||||||
|
dl.push = new Proxy(dl.push, {
|
||||||
|
apply: function(target, thisArg, args) {
|
||||||
|
doCallback(args[0]);
|
||||||
|
return Reflect.apply(target, thisArg, args);
|
||||||
|
}
|
||||||
|
});
|
||||||
if ( Array.isArray(dl) ) {
|
if ( Array.isArray(dl) ) {
|
||||||
dl.push = item => doCallback(item);
|
|
||||||
const q = dl.slice();
|
const q = dl.slice();
|
||||||
for ( const item of q ) {
|
for ( const item of q ) {
|
||||||
doCallback(item);
|
doCallback(item);
|
||||||
|
Loading…
Reference in New Issue
Block a user