Limegreen external links

Highlight all external links in lime green, works on dynamically added content too.

  1. // ==UserScript==
  2. // @name Limegreen external links
  3. // @description Highlight all external links in lime green, works on dynamically added content too.
  4. // @include *
  5. // @namespace wOxxOm.scripts
  6. // @author wOxxOm
  7. // @version 1.0.2
  8. // @license MIT License
  9. // @grant GM_addStyle
  10. // @run-at document-start
  11. // @require https://greasyfork.org/scripts/12228/code/setMutationHandler.js
  12. // ==/UserScript==
  13.  
  14. GM_addStyle(
  15. 'a.external_link_wOxxOm:link {background-color: rgba(133,255,0,0.7) !important; color:black!important}'+
  16. 'a.external_link_wOxxOm:visited {background-color: rgba(191,255,0,0.7) !important; color:black!important}'
  17. );
  18. setMutationHandler(document, 'a[href*="//"]', function(nodes) {
  19. var hostname = new URL(location.href).hostname;
  20. nodes.forEach(function(n) {
  21. if (new URL(n.href).hostname != hostname)
  22. n.classList.add('external_link_wOxxOm');
  23. });
  24. return true;
  25. });