Link Sanitizer

Clean up unnecessary hyperlink redirections and link shims

Author
cloux
Daily installs
0
Total installs
1,453
Ratings
10 0 2
Version
1.1.9
Created
2018-11-23
Updated
2022-02-02
License
WTFPL 2.0
Applies to
All sites

About

Link Sanitizer is a simple and efficient userscript for Violentmonkey and Greasemonkey browser addons. It will "sanitize" links on all webpages using a simple set of common rules. This includes removing trackers, link shims, and other bloated hyperlink redirects. In addition to this script, it is a good idea to use Privacy Badger, who specializes on some nasty Facebook and Google deeplink trackers.

Installation

  1. Install Violentmonkey or Greasemonkey userscript manager addon in your browser.
  2. Open Link Sanitizer file. Your userscript manager should recognize and install it.

Known Issues

Userscripts and Content Security Policies

Userscripts won't work on websites implementing restrictive Content Security Policies (e.g. addons.mozilla.org, github.com, or twitter.com). Currently the only way to make ViolentMonkey or GreaseMonkey work on all sites is to disable the CSP protection, which is generally not recommended.

The corresponding setting in Firefox about:config is:

security.csp.enable = false

On Chrome, the CSP can be overridden by extensions Content Security Policy Override, UnXSS or Caspr Enforcer.

The development progress on this issue for Mozilla is here, the discussion on Greasemonkey code is here.

Firefox addons on "superior" domains

Mozilla decided that Firefox simply disables addons for domains which are regarded as superior to user and his freedom. These domains are unsurprisingly owned by Mozilla. To get rid of this nasty "superior domain list" and enable addons everywhere, set in about:config:

extensions.webextensions.restrictedDomains = ""

Firefox and AddonManagerAPI on addons.mozilla.org

Addons are also disabled for the addons.mozilla.org domain, which can access the hidden AddonManagerWebAPI exposed by Firefox. This Firefox behavior is hardcoded. To make userscripts work on addons.mozilla.org, first turn off Firefox and then add into the ~/.mozilla/firefox/PROFILE.default/prefs.js file:

user_pref("privacy.resistFingerprinting.block_mozAddonManager", true);

NOTE: Your path to the prefs.js might differ. See mozillazine article or dev docs on editing user preferences.

NOTE: This setting is hidden and not available in about:config, it has to be added into the prefs.js manually.

NOTE: You will be able to install plugins as usual, but the addons.mozilla.org website will not be able to see which addons are already installed or otherwise manipulate them.

Compatibility

Tested with Violentmonkey and Greasemonkey on Firefox 60,61,63 and Chromium 70. Tampermonkey was not tested due to its cumbersome legal status, see https://tampermonkey.net/eula.php.

Author

This userscript is maintained by cloux@rote.ch

License

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published here: http://www.wtfpl.net/about.