reddit: sabotage event tracker

Blocks the reddit event collector

目前為 2018-03-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name         reddit: sabotage event tracker
// @namespace    mz1js5x0yt0zxq1kf22z1wdn6zq2ij2g
// @version      1.0
// @description  Blocks the reddit event collector
// @match        *://*.reddit.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
	"use strict";

	// Dummy function that just returns true and becomes
	// 0 or an empty string when type-converted.
	var dummyFunction = function () {
		return true;
	};

	dummyFunction.toString = function toString() {
		return "";
	};

	dummyFunction[Symbol.toPrimitive] = function (hint) {
		if (hint === "number") {
			return 0;
		}
		return "";
	};


	// Trapped constructor. This actually returns
	// a Proxy of the newly created object
	function EventTracker(e, t, n, r, i, s, o, u) {
		if (!this) {
			return new EventTracker(...arguments);
		}

		// Intercept property access. Any unknown prop
		// is assumed to be a function call, so return
		// our dummyFunction in response
		return new Proxy(this, {
			get: function(target, prop) {
				if (prop in target) {
					return target[prop];
				}
				return dummyFunction;
			}
		});
	}


	// Prevent extra properties from being added to the prototype
	Reflect.preventExtensions(EventTracker.prototype);


	// Export to window in a way that silently prevents it
	// from being overwritten
	Reflect.defineProperty(window, "EventTracker", {
		configurable: false,
		enumerable: true,
		set: function (value) {}, // empty setter to prevent overwriting
		get: function () {
			return EventTracker;
		}
	});
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址