Tracking Hash Remover

This removes the random fragment identifiers used to track you.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @author       James Edward Lewis II
// @name         Tracking Hash Remover
// @namespace    greasyfork.org
// @version      0.0.1
// @description  This removes the random fragment identifiers used to track you.
// @grant        none
// @include      *
// @license MIT
// @copyright    2015+, James Edward Lewis II
// @run-at       document-start
// ==/UserScript==

(function trackingHashRemover(window, undefined) {
  'use strict';
  var trackPattern = /^#?\.[a-zA-Z0-9]{8,}/, interval;
  function removeHash(hsh) {
    var subst, idx;
    if (typeof hsh === 'symbol') hsh = '';
    hsh += '';
    idx = hsh.indexOf('#');
    if (idx !== -1) {
      subst = hsh.slice(idx);
      if (trackPattern.test(subst)) return hsh.slice(0, idx);
      else return hsh;
    } else return '';
  }
  function locHashRemover() {
    var hsh = location.hash;
    if (trackPattern.test(hsh)) location.hash = '';
    else {
      clearInterval(interval);
      interval = null;
    }
  }
  function removeHashes() {
    var links = document.getElementsByTagName('a'),
      forms = document.getElementsByTagName('form'), i;
    interval = interval || setInterval(locHashRemover, 16);
    for (i in links)
      if (links.hasOwnProperty(i))
        i.hash = removeHash(i.hash);
    for (i in forms)
      if(forms.hasOwnProperty(i))
        i.action = removeHash(i.action);
  }
  function dclRemover() {
    document.removeEventListener('DOMContentLoaded', dclRemover, false);
    removeHashes();
  }
  function loadRemover() {
    window.removeEventListener('load', loadRemover, false);
    removeHashes();
  }
  removeHashes();
  document.addEventListener('readystatechange', removeHashes, false);
  document.addEventListener('DOMContentLoaded', dclRemover, false);
  window.addEventListener('load', loadRemover, false);
  window.addEventListener('hashchange', removeHashes, false);
}(window));