1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-04 10:09:38 +02:00

Further improve GA's surrogate script

Related issue:
- https://github.com/AdguardTeam/Scriptlets/issues/154

Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1807
This commit is contained in:
Raymond Hill 2021-11-09 15:18:30 -05:00
parent 8378baa894
commit 3b53c3a3e3
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -46,7 +46,10 @@
/(^|\.)_link$/.test(a[0]) && /(^|\.)_link$/.test(a[0]) &&
typeof a[1] === 'string' typeof a[1] === 'string'
) { ) {
window.location.assign(a[1]); try {
window.location.assign(a[1]);
} catch(ex) {
}
} }
// https://github.com/gorhill/uBlock/issues/2162 // https://github.com/gorhill/uBlock/issues/2162
if ( a[0] === '_set' && a[1] === 'hitCallback' && typeof a[2] === 'function' ) { if ( a[0] === '_set' && a[1] === 'hitCallback' && typeof a[2] === 'function' ) {
@ -62,7 +65,7 @@
'_cookiePathCopy _deleteCustomVar _getName _setAccount', '_cookiePathCopy _deleteCustomVar _getName _setAccount',
'_getAccount _getClientInfo _getDetectFlash _getDetectTitle', '_getAccount _getClientInfo _getDetectFlash _getDetectTitle',
'_getLinkerUrl _getLocalGifPath _getServiceMode _getVersion', '_getLinkerUrl _getLocalGifPath _getServiceMode _getVersion',
'_getVisitorCustomVar _initData _link _linkByPost', '_getVisitorCustomVar _initData _linkByPost',
'_setAllowAnchor _setAllowHash _setAllowLinker _setCampContentKey', '_setAllowAnchor _setAllowHash _setAllowLinker _setCampContentKey',
'_setCampMediumKey _setCampNameKey _setCampNOKey _setCampSourceKey', '_setCampMediumKey _setCampNameKey _setCampNOKey _setCampSourceKey',
'_setCampTermKey _setCampaignCookieTimeout _setCampaignTrack _setClientInfo', '_setCampTermKey _setCampaignCookieTimeout _setCampaignTrack _setClientInfo',
@ -74,13 +77,20 @@
'_trackPageview _trackSocial _trackTiming _trackTrans', '_trackPageview _trackSocial _trackTiming _trackTrans',
'_visitCode' '_visitCode'
].join(' ').split(/\s+/); ].join(' ').split(/\s+/);
let i = api.length; for ( const method of api ) {
while ( i-- ) { out[method] = noopfn;
out[api[i]] = noopfn;
} }
out._getLinkerUrl = function(a) { out._getLinkerUrl = function(a) {
return a; return a;
}; };
// https://github.com/AdguardTeam/Scriptlets/issues/154
out._link = function(a) {
if ( typeof a !== 'string' ) { return; }
try {
window.location.assign(a);
} catch(ex) {
}
};
return out; return out;
})(); })();
// //