Advertisement
jcunews

DisableURLPopupOnLinkHover.user.js

Sep 4th, 2020 (edited)
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Disable URL Popup On Link Hover (Experimental)
  3. // @namespace    https://greasyfork.org/en/users/85671-jcunews
  4. // @version      1.0.1
  5. // @license      AGPLv3
  6. // @author       jcunews
  7. // @description  Reference: https://www.reddit.com/r/operabrowser/comments/im6r5d/why_when_i_hover_over_anything_does_it_show_the/
  8. // @match        *://*/*
  9. // @grant        none
  10. // @run-at       document-start
  11. // ==/UserScript==
  12.  
  13. (() => {
  14.   function delHref(e) {
  15.     e.removeAttribute("href");
  16.   }
  17.   function doclick() {
  18.     this.setAttribute("href", this.dataset.orghref);
  19.     setTimeout(delHref, 100, this);
  20.   }
  21.   function patchLink(a, h, s) {
  22.     if (h = a.getAttribute("href")) {
  23.       s = getComputedStyle(a);
  24.       a.style.color = s.color;
  25.       a.style.cursor = s.cursor;
  26.       a.style.textDecoration = s.textDecoration;
  27.       a.dataset.orghref = h;
  28.       a.removeAttribute("href");
  29.       a.addEventListener("click", doclick, true);
  30.     }
  31.   }
  32.   (new MutationObserver(recs => {
  33.     recs.forEach(rec => {
  34.       rec.addedNodes.forEach(node => {
  35.         if (node.nodeType === Node.ELEMENT_NODE) {
  36.           if (node.tagName === "A") patchLink(node);
  37.           node.querySelectorAll("A").forEach(patchLink);
  38.         }
  39.       });
  40.     });
  41.   })).observe(document, {childList: true, subtree: true});
  42. })();
  43.  
Advertisement
RAW Paste Data Copied
Advertisement