SHARE
TWEET

facebook link tracking remover

emerginginstance Jun 30th, 2020 (edited) 929 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         fbclid, data-lynx-uri, __xts__ remover
  3. // @namespace    http://tampermonkey.net/
  4. // @version      1.3
  5. // @description  removes tracking from all links, probably  only works on firefox with tracking protection, actively updated 02/07/2020
  6. // @match        https://www.facebook.com/*
  7. // @run-at       document-idle
  8. // ==/UserScript==
  9.  
  10. (function () {
  11.   "use strict";
  12.  
  13.   const callback = function (mutationsList, observer) {
  14.     try {
  15.       document
  16.         .querySelectorAll("a[href*=fbclid]")
  17.         .forEach((a) => (a.href = a.href.split("fbclid")[0]));
  18.  
  19.       document
  20.         .querySelectorAll('a[data-lynx-uri*="l.facebook"]')
  21.         .forEach((a) => a.setAttribute("data-lynx-uri", a.href));
  22.        
  23.         document
  24.         .querySelectorAll('a[href*="__xts__"]')
  25.         .forEach((a) => a.setAttribute("href", a.href.split('__xts__')[0]));
  26.     } catch (e) {
  27.       console.warn("fbclid, data-lynx-uri, __xts__ remover", "script error", e);
  28.     }
  29.   };
  30.  
  31.   // Create an observer instance linked to the callback function
  32.   const observer = new MutationObserver(callback);
  33.  
  34.   // Start observing the target node for configured mutations
  35.   observer.observe(document.body, {
  36.     attributes: true,
  37.     childList: true,
  38.     subtree: true,
  39.   });
  40. })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top