Defines the Google Analytics opt-out object on every page.
目前為
// ==UserScript==
// @name Google Analytics opt-out
// @namespace zdnq5fclhrdh8lgo
// @match *://*/*
// @grant none
// @version 1.0
// @license MIT
// @description Defines the Google Analytics opt-out object on every page.
// @run-at document-start
// @inject-into content
// ==/UserScript==
(function () {
"use strict";
const runInPage = (null, function () {
const optout = {};
const ioo = () => true;
Reflect.defineProperty(optout, "ioo", {
enumerable: true,
configurable: false,
get() { return ioo; },
set() {}
});
Reflect.defineProperty(window, "_gaUserPrefs", {
enumerable: false,
configurable: false,
get() { return optout; },
set() {}
});
});
const inject = `"use strict";(${runInPage})();`
if ("wrappedJSObject" in window) {
// Bypass Firefox sandbox
window.eval(inject);
} else {
// Inject script tag (Chrome)
const script = document.createElement("script");
script.text = inject;
(document.head ?? document.documentElement).prepend(script);
script.remove();
}
})();