Anti-Fingerprinting Shield Plus – Advanced Privacy Protection

Anti-Fingerprinting Shield Plus enhances your online privacy by spoofing and blocking various browser fingerprinting techniques. It randomizes or disables elements like canvas, WebGL, audio context, language, timezone, CPU cores, screen dimensions, and sensor APIs to make your browser fingerprint less unique and more resistant to tracking.

目前為 2025-04-30 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Anti-Fingerprinting Shield Plus – Advanced Privacy Protection
// @namespace    https://365devnet.eu/userscripts
// @version      1.1
// @description  Anti-Fingerprinting Shield Plus enhances your online privacy by spoofing and blocking various browser fingerprinting techniques. It randomizes or disables elements like canvas, WebGL, audio context, language, timezone, CPU cores, screen dimensions, and sensor APIs to make your browser fingerprint less unique and more resistant to tracking.
// @match        *://*/*
// @grant        none
// @license      MIT
// @run-at       document-start
// ==/UserScript==

(function () {
  'use strict';
  console.log('[AFS+] Advanced Anti-Fingerprinting Shield is active');

  // ===== RANDOMIZATION POOLS =====
  const platforms = ['Win32', 'Linux x86_64', 'MacIntel', 'FreeBSD'];
  const languages = ['en-US', 'nl-NL', 'fr-FR', 'de-DE', 'sv-SE'];
  const timezones = ['UTC', 'Europe/Amsterdam', 'America/New_York', 'Asia/Tokyo'];
  const userAgents = [
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15',
    'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
  ];
  const cores = [2, 4, 6, 8];
  const screenWidths = [1920, 1680, 1366];
  const screenHeights = [1080, 1050, 768];

  // ===== RANDOMIZED SESSION VALUES =====
  const spoofed = {
    platform: pick(platforms),
    language: pick(languages),
    languages: [pick(languages), 'en'],
    timezone: pick(timezones),
    userAgent: pick(userAgents),
    cores: pick(cores),
    screenWidth: pick(screenWidths),
    screenHeight: pick(screenHeights)
  };

  function pick(arr) {
    return arr[Math.floor(Math.random() * arr.length)];
  }

  // ===== LANGUAGE & PLATFORM =====
  spoofProperty(navigator, 'language', () => spoofed.language);
  spoofProperty(navigator, 'languages', () => spoofed.languages);
  spoofProperty(navigator, 'platform', () => spoofed.platform);

  // ===== USER AGENT =====
  spoofProperty(navigator, 'userAgent', () => spoofed.userAgent);

  // ===== CPU CORES =====
  spoofProperty(navigator, 'hardwareConcurrency', () => spoofed.cores);

  // ===== TOUCH =====
  spoofProperty(navigator, 'maxTouchPoints', () => 1);
  window.TouchEvent = undefined;
  window.ontouchstart = undefined;

  // ===== TIMEZONE =====
  try {
    const original = Intl.DateTimeFormat.prototype.resolvedOptions;
    Intl.DateTimeFormat.prototype.resolvedOptions = function () {
      const options = original.call(this);
      options.timeZone = spoofed.timezone;
      return options;
    };
  } catch (e) {}

  // ===== SCREEN SIZE & WINDOW =====
  spoofProperty(window.screen, 'width', () => spoofed.screenWidth);
  spoofProperty(window.screen, 'height', () => spoofed.screenHeight);
  spoofProperty(window, 'innerWidth', () => spoofed.screenWidth);
  spoofProperty(window, 'innerHeight', () => spoofed.screenHeight - 40);

  // ===== PLUGINS & MEDIA DEVICES =====
  spoofProperty(navigator, 'plugins', () => []);
  spoofProperty(navigator, 'mediaDevices', () => ({
    enumerateDevices: () => Promise.resolve([])
  }));

  // ===== BATTERY API BLOCK =====
  delete navigator.getBattery;

  // ===== AUDIO FINGERPRINT SPOOFING =====
  const AudioContext = window.AudioContext || window.webkitAudioContext;
  if (AudioContext) {
    const original = AnalyserNode.prototype.getFloatFrequencyData;
    AnalyserNode.prototype.getFloatFrequencyData = function (array) {
      original.call(this, array);
      for (let i = 0; i < array.length; i++) {
        array[i] += Math.random() * 0.1;
      }
    };
  }

  // ===== CANVAS SPOOFING =====
  const originalGetImageData = CanvasRenderingContext2D.prototype.getImageData;
  CanvasRenderingContext2D.prototype.getImageData = function (x, y, w, h) {
    const imageData = originalGetImageData.call(this, x, y, w, h);
    for (let i = 0; i < imageData.data.length; i += 4) {
      imageData.data[i] ^= 1;
      imageData.data[i + 1] ^= 1;
      imageData.data[i + 2] ^= 1;
    }
    return imageData;
  };

  // ===== WEBGL SPOOFING =====
  const originalGLGetParameter = WebGLRenderingContext.prototype.getParameter;
  WebGLRenderingContext.prototype.getParameter = function (param) {
    const spoofMap = {
      37445: 'FakeVendor Inc.',            // UNMASKED_VENDOR_WEBGL
      37446: 'Virtual GPU Renderer',       // UNMASKED_RENDERER_WEBGL
      3379: 4096,                           // MAX_TEXTURE_SIZE
      35661: 8                              // MAX_COMBINED_TEXTURE_IMAGE_UNITS
    };
    return spoofMap[param] || originalGLGetParameter.call(this, param);
  };

  // ===== SENSOR API BLOCK =====
  window.DeviceMotionEvent = undefined;
  window.DeviceOrientationEvent = undefined;

  // ===== BEFOREUNLOAD BLOCK =====
  window.addEventListener('beforeunload', e => {
    e.stopImmediatePropagation();
    e.preventDefault();
    return undefined;
  }, true);

  // ===== UTILITY =====
  function spoofProperty(obj, prop, getter) {
    try {
      Object.defineProperty(obj, prop, {
        get: getter,
        configurable: true
      });
    } catch (e) {}
  }
})();