Chore: update ESLint config

This commit is contained in:
SukkaW
2023-09-28 22:59:19 +08:00
parent d69def0024
commit 3d2afa608c
21 changed files with 315 additions and 315 deletions

View File

@@ -1,5 +1,6 @@
(function () {
'use strict';
const noopfn = function () {
};
window.addthis = {
@@ -15,4 +16,4 @@
toolbox: noopfn,
update: noopfn
};
})();
}());

View File

@@ -1,5 +1,6 @@
(function () {
'use strict';
const head = document.head;
if (!head) { return; }
const style = document.createElement('style');
@@ -10,4 +11,4 @@
'}'
].join('\n');
head.appendChild(style);
})();
}());

View File

@@ -1,88 +1,89 @@
(function () {
'use strict';
// https://developers.google.com/analytics/devguides/collection/analyticsjs/
const noopfn = function () {
};
'use strict';
// https://developers.google.com/analytics/devguides/collection/analyticsjs/
const noopfn = function () {
};
//
const Tracker = function () {
};
const p = Tracker.prototype;
p.get = noopfn;
p.set = noopfn;
p.send = noopfn;
//
const w = window;
const gaName = w.GoogleAnalyticsObject || 'ga';
const gaQueue = w[gaName];
const ga = function () {
const len = arguments.length;
if (len === 0) { return; }
const args = Array.from(arguments);
let fn;
let a = args[len - 1];
if (a instanceof Object && typeof a.hitCallback === 'function') {
fn = a.hitCallback;
} else if (a instanceof Function) {
fn = () => { a(ga.create()); };
} else {
const pos = args.indexOf('hitCallback');
if (pos !== -1 && typeof args[pos + 1] === 'function') {
fn = args[pos + 1];
}
}
if (typeof fn !== 'function') { return; }
try {
fn();
} catch (ex) {
}
};
ga.create = function () {
return new Tracker();
};
ga.getByName = function () {
return new Tracker();
};
ga.getAll = function () {
return [new Tracker()];
};
ga.remove = noopfn;
// https://github.com/uBlockOrigin/uAssets/issues/2107
ga.loaded = true;
w[gaName] = ga;
// https://github.com/gorhill/uBlock/issues/3075
const dl = w.dataLayer;
if (dl instanceof Object) {
if (dl.hide instanceof Object && typeof dl.hide.end === 'function') {
dl.hide.end();
dl.hide.end = () => { };
}
if (typeof dl.push === 'function') {
const doCallback = function (item) {
if (item instanceof Object === false) { return; }
if (typeof item.eventCallback !== 'function') { return; }
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)) {
const q = dl.slice();
for (const item of q) {
doCallback(item);
}
}
}
const Tracker = function () {
};
const p = Tracker.prototype;
p.get = noopfn;
p.set = noopfn;
p.send = noopfn;
//
const w = window;
const gaName = w.GoogleAnalyticsObject || 'ga';
const gaQueue = w[gaName];
const ga = function (...args) {
const len = args.length;
if (len === 0) { return; }
let fn;
const a = args[len - 1];
if (typeof a === 'object' && typeof a.hitCallback === 'function') {
fn = a.hitCallback;
} else if (typeof a === 'function') {
fn = () => { a(ga.create()); };
} else {
const pos = args.indexOf('hitCallback');
if (pos !== -1 && typeof args[pos + 1] === 'function') {
fn = args[pos + 1];
}
}
// empty ga queue
if (typeof gaQueue === 'function' && Array.isArray(gaQueue.q)) {
const q = gaQueue.q.slice();
gaQueue.q.length = 0;
for (const entry of q) {
ga(...entry);
}
if (typeof fn !== 'function') { return; }
try {
fn();
} catch (ex) {
}
})();
};
ga.create = function () {
return new Tracker();
};
ga.getByName = function () {
return new Tracker();
};
ga.getAll = function () {
return [new Tracker()];
};
ga.remove = noopfn;
// https://github.com/uBlockOrigin/uAssets/issues/2107
ga.loaded = true;
w[gaName] = ga;
// https://github.com/gorhill/uBlock/issues/3075
const dl = w.dataLayer;
if (typeof dl === 'object') {
if (typeof dl.hide === 'object' && typeof dl.hide.end === 'function') {
dl.hide.end();
dl.hide.end = () => { };
}
if (typeof dl.push === 'function') {
const doCallback = function (item) {
if (typeof item === 'object' === false) { return; }
if (typeof item.eventCallback !== 'function') { return; }
// eslint-disable-next-line sukka/prefer-timer-id -- deliberate use of setTimeout
setTimeout(item.eventCallback, 1);
item.eventCallback = () => { };
};
dl.push = new Proxy(dl.push, {
apply(target, thisArg, args) {
doCallback(args[0]);
return Reflect.apply(target, thisArg, args);
}
});
if (Array.isArray(dl)) {
const q = dl.slice();
for (const item of q) {
doCallback(item);
}
}
}
}
// empty ga queue
if (typeof gaQueue === 'function' && Array.isArray(gaQueue.q)) {
const q = gaQueue.q.slice();
gaQueue.q.length = 0;
for (const entry of q) {
ga(...entry);
}
}
}());

View File

@@ -1,9 +1,10 @@
(function () {
'use strict';
const noopfn = function () {
};
window.cxApi = {
chooseVariation: function () {
chooseVariation() {
return 0;
},
getChosenVariation: noopfn,
@@ -12,4 +13,4 @@
setCookiePath: noopfn,
setDomainName: noopfn
};
})();
}());

View File

@@ -1,5 +1,6 @@
(function () {
'use strict';
const noopfn = function () {
};
//
@@ -20,9 +21,9 @@
if (Array.isArray(a) === false) { return; }
// https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory#_gat.GA_Tracker_._link
if (
typeof a[0] === 'string' &&
/(^|\.)_link$/.test(a[0]) &&
typeof a[1] === 'string'
typeof a[0] === 'string'
&& /(^|\.)_link$/.test(a[0])
&& typeof a[1] === 'string'
) {
try {
window.location.assign(a[1]);
@@ -69,7 +70,7 @@
}
};
return out;
})();
}());
//
const Gat = function () {
};
@@ -102,6 +103,7 @@
gaq.push(aa.shift());
}
}
})();
window._gaq = gaq.qf = gaq;
})();
}());
gaq.qf = gaq;
window._gaq = gaq;
}());

View File

@@ -1,7 +1,8 @@
(function () {
'use strict';
window._gaq = window._gaq || {
push: function () {
push() {
}
};
})();
}());

View File

@@ -1,9 +1,10 @@
(function () {
'use strict';
const init = () => {
window.adsbygoogle = {
loaded: true,
push: function () {
push() {
}
};
const phs = document.querySelectorAll('.adsbygoogle');
@@ -21,11 +22,11 @@
}
};
if (
document.querySelectorAll('.adsbygoogle').length === 0 &&
document.readyState === 'loading'
document.querySelectorAll('.adsbygoogle').length === 0
&& document.readyState === 'loading'
) {
window.addEventListener('DOMContentLoaded', init, { once: true });
} else {
init();
}
})();
}());

View File

@@ -1,22 +1,24 @@
(function () {
'use strict';
const noopfn = function () {
};
const w = window;
w.ga = w.ga || noopfn;
const dl = w.dataLayer;
if (dl instanceof Object === false) { return; }
if (dl.hide instanceof Object && typeof dl.hide.end === 'function') {
if (typeof dl !== 'object') { return; }
if (typeof dl.hide === 'object' && typeof dl.hide.end === 'function') {
dl.hide.end();
}
if (typeof dl.push === 'function') {
dl.push = function (o) {
if (
o instanceof Object &&
typeof o.eventCallback === 'function'
typeof o === 'object'
&& typeof o.eventCallback === 'function'
) {
// eslint-disable-next-line sukka/prefer-timer-id -- deliberately use setTimeout
setTimeout(o.eventCallback, 1);
}
};
}
})();
}());

View File

@@ -1,5 +1,6 @@
(function () {
'use strict';
// https://developers.google.com/doubleclick-gpt/reference
const noopfn = function () {
}.bind();
@@ -42,8 +43,8 @@
clearTagForChildDirectedTreatment: noopthisfn,
clearTargeting: noopthisfn,
collapseEmptyDivs: noopfn,
defineOutOfPagePassback: function () { return new PassbackSlot(); },
definePassback: function () { return new PassbackSlot(); },
defineOutOfPagePassback() { return new PassbackSlot(); },
definePassback() { return new PassbackSlot(); },
disableInitialLoad: noopfn,
display: noopfn,
enableAsyncRendering: noopfn,
@@ -129,4 +130,4 @@
while (cmd.length !== 0) {
gpt.cmd.push(cmd.shift());
}
})();
}());