Direct Link/NO href hijack

Basically this script prevents the same site from managing the URL redirection whenever you click on link. It basically extracts href/http link and sends it direct to the URLbar. Keep in mind that this most-likely brake some pages, so use just when you just it was appropriate.

  1. // ==UserScript==
  2. // @name Direct Link/NO href hijack
  3. // @namespace Violentmonkey Scripts
  4. // @include *example.com*
  5. // @grant none
  6. // @version 1.0
  7. // @author -
  8. // @description Basically this script prevents the same site from managing the URL redirection whenever you click on link. It basically extracts href/http link and sends it direct to the URLbar. Keep in mind that this most-likely brake some pages, so use just when you just it was appropriate.
  9. // ==/UserScript==
  10. // Create event listener for all link clicks
  11.  
  12. document.querySelectorAll('a').forEach(link => {
  13. link.addEventListener('click', (e) => {
  14. e.preventDefault();
  15. // Retrieve href and store in targetUrl variable
  16. let targetUrl = e.target.href;
  17. // Output value of targetUrl to console
  18. window.open("" + targetUrl,"_self");
  19.  
  20. });
  21. });