Greasy Fork is available in English.
speed up subway surfers on randomkzn
// ==UserScript==
// @name randomkzn speedup
// @namespace https://greasyfork.org/
// @version 1.0.0
// @description speed up subway surfers on randomkzn
// @author placeholdernamexd
// @match https://ss.randomkzn.com/*
// @run-at document-start
// @grant none
// @license MIT
// ==/UserScript==
(function () {
'use strict';
// ============================================================
// 1. BLOCKED TRACKING DOMAINS
// Any fetch() or XHR to these will be silently dropped.
// ============================================================
const BLOCKED_DOMAINS = [
'google-analytics.com',
'analytics.google.com',
'googletagmanager.com',
'googletagservices.com',
'googlesyndication.com',
'doubleclick.net',
'google.com/ads',
'connect.facebook.net',
'facebook.com/tr',
'graph.facebook.com',
'hotjar.com',
'clarity.ms',
'mixpanel.com',
'segment.com',
'segment.io',
'amplitude.com',
'heap.io',
'fullstory.com',
'mouseflow.com',
'crazyegg.com',
'scorecardresearch.com',
'quantserve.com',
'adsymptotic.com',
'adnxs.com',
'moatads.com',
'taboola.com',
'outbrain.com',
'criteo.com',
'ads.twitter.com',
'static.ads-twitter.com',
'analytics.tiktok.com',
'bat.bing.com',
];
function isBlocked(url) {
try {
const hostname = new URL(url).hostname;
return BLOCKED_DOMAINS.some(domain => hostname.includes(domain));
} catch {
return false;
}
}
// ============================================================
// 2. INTERCEPT fetch()
// Drop any fetch request going to a blocked domain.
// ============================================================
const originalFetch = window.fetch;
window.fetch = function (input, init) {
const url = typeof input === 'string' ? input : input?.url;
if (url && isBlocked(url)) {
console.debug('[Shield] Blocked fetch:', url);
return Promise.resolve(new Response('', { status: 200 }));
}
return originalFetch.apply(this, arguments);
};
// ============================================================
// 3. INTERCEPT XMLHttpRequest
// Drop XHR open() calls going to blocked domains.
// ============================================================
const originalOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function (method, url) {
if (url && isBlocked(url)) {
console.debug('[Shield] Blocked XHR:', url);
// Redirect to a harmless dead-end so send() doesn't throw
return originalOpen.call(this, method, 'about:blank');
}
return originalOpen.apply(this, arguments);
};
// ============================================================
// 4. NEUTER COOKIES
// Block cookies that look like tracking cookies.
// Known tracking cookie name patterns are listed below.
// ============================================================
const BLOCKED_COOKIE_PATTERNS = [
/^_ga/, // Google Analytics
/^_gid/, // Google Analytics session
/^_gat/, // Google Analytics throttle
/^_fbp/, // Facebook Pixel
/^_fbc/, // Facebook Click ID
/^__utm/, // Old Google Analytics
/^_hjid/, // Hotjar
/^_hjSession/, // Hotjar session
/^mp_/, // Mixpanel
/^ajs_/, // Segment
/^_clck/, // Microsoft Clarity
/^_clsk/, // Microsoft Clarity session
/^MUID/, // Microsoft tracking
/^mbox/, // Adobe Target
/^at_check/, // Adobe Target
];
function isCookieBlocked(cookieString) {
const name = cookieString.split('=')[0].trim();
return BLOCKED_COOKIE_PATTERNS.some(pattern => pattern.test(name));
}
const cookieDescriptor = Object.getOwnPropertyDescriptor(Document.prototype, 'cookie')
|| Object.getOwnPropertyDescriptor(HTMLDocument.prototype, 'cookie');
if (cookieDescriptor && cookieDescriptor.configurable) {
Object.defineProperty(document, 'cookie', {
get: function () {
return cookieDescriptor.get.call(document);
},
set: function (val) {
if (isCookieBlocked(val)) {
console.debug('[Shield] Blocked cookie:', val.split('=')[0]);
return;
}
cookieDescriptor.set.call(document, val);
},
configurable: true,
});
}
// ============================================================
// 5. CLEAN TRACKING PARAMS FROM URL
// Strips known tracking query params on page load.
// Rewrites the URL cleanly without reloading the page.
// ============================================================
const TRACKING_PARAMS = [
'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',
'utm_id', 'utm_source_platform', 'utm_creative_format', 'utm_marketing_tactic',
'fbclid', // Facebook Click ID
'gclid', // Google Click ID
'gclsrc', // Google Click Source
'dclid', // Display Click ID
'msclkid', // Microsoft Click ID
'twclid', // Twitter Click ID
'ttclid', // TikTok Click ID
'mc_eid', // Mailchimp Email ID
'igshid', // Instagram Share ID
'_hsenc', // HubSpot
'_hsmi', // HubSpot
'ref', // Generic referral param (optional — remove if site needs it)
];
function cleanURL() {
const url = new URL(window.location.href);
let changed = false;
TRACKING_PARAMS.forEach(param => {
if (url.searchParams.has(param)) {
url.searchParams.delete(param);
changed = true;
}
});
if (changed) {
console.debug('[Shield] Cleaned tracking params from URL');
window.history.replaceState(null, '', url.toString());
}
}
cleanURL();
// ============================================================
// 6. BLOCK TRACKER SCRIPT INJECTION (MutationObserver)
// Watches the DOM for <script> tags from blocked domains
// and removes them before they execute.
// ============================================================
const BLOCKED_SCRIPT_PATTERNS = BLOCKED_DOMAINS.map(d => d.replace('.', '\\.'));
function isTrackerScript(node) {
if (node.tagName !== 'SCRIPT') return false;
const src = node.src || '';
return BLOCKED_SCRIPT_PATTERNS.some(pattern => src.includes(pattern.replace('\\.', '.')));
}
const observer = new MutationObserver(mutations => {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (isTrackerScript(node)) {
console.debug('[Shield] Removed tracker script:', node.src);
node.remove();
}
// Also check child nodes
if (node.querySelectorAll) {
node.querySelectorAll('script[src]').forEach(script => {
if (isTrackerScript(script)) {
console.debug('[Shield] Removed nested tracker script:', script.src);
script.remove();
}
});
}
}
}
});
observer.observe(document.documentElement, {
childList: true,
subtree: true,
});
// ============================================================
// 7. DISABLE FINGERPRINTING APIs
// Spoofs or disables APIs commonly used to fingerprint
// your browser without your knowledge.
// ============================================================
// 7a. Canvas fingerprinting — add subtle noise to canvas reads
const originalToDataURL = HTMLCanvasElement.prototype.toDataURL;
HTMLCanvasElement.prototype.toDataURL = function (type) {
const ctx = this.getContext('2d');
if (ctx) {
// Add 1px of invisible noise — breaks fingerprint, not visuals
const imageData = ctx.getImageData(0, 0, this.width || 1, this.height || 1);
imageData.data[0] ^= 1;
ctx.putImageData(imageData, 0, 0);
}
return originalToDataURL.apply(this, arguments);
};
// 7b. Battery API — often used for fingerprinting
if (navigator.getBattery) {
navigator.getBattery = () => Promise.reject(new Error('[Shield] Battery API blocked'));
}
// 7c. Hardware concurrency — return a generic value
try {
Object.defineProperty(navigator, 'hardwareConcurrency', {
get: () => 4,
configurable: true,
});
} catch {}
// 7d. Device memory — return generic value
try {
Object.defineProperty(navigator, 'deviceMemory', {
get: () => 4,
configurable: true,
});
} catch {}
// 7e. Connection API — used for fingerprinting network type
try {
Object.defineProperty(navigator, 'connection', {
get: () => undefined,
configurable: true,
});
} catch {}
// ============================================================
// 8. BLOCK TRACKING PIXELS
// 1x1 <img> tags used as silent tracking beacons.
// Removed on DOM ready.
// ============================================================
function removeTrackingPixels() {
document.querySelectorAll('img').forEach(img => {
const src = img.src || '';
const w = img.naturalWidth || img.width;
const h = img.naturalHeight || img.height;
const isPixel = (w <= 2 && h <= 2) && isBlocked(src);
if (isPixel) {
console.debug('[Shield] Removed tracking pixel:', src);
img.remove();
}
});
}
document.addEventListener('DOMContentLoaded', removeTrackingPixels);
// ============================================================
// DONE
// ============================================================
console.info('[Shield] ss.randomkzn.com Privacy & Speed Shield active ✓');
})();