Disable "Alt/Option + Click" shortcut

Disables "Alt/Option + Click" shortcut combo that downloads the link on Chrome

  1. // ==UserScript==
  2. // @name Disable "Alt/Option + Click" shortcut
  3. // @namespace https://vighnesh153.dev/
  4. // @version 2024-08-08
  5. // @description Disables "Alt/Option + Click" shortcut combo that downloads the link on Chrome
  6. // @author vighnesh153
  7. // @match *://*/*
  8. // @icon https://raw.githubusercontent.com/vighnesh153/vighnesh153-monorepo/main/nodejs-tools/nodejs-chrome-extensions/disable-alt-click-download/images/logo_48x48.png
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. "use strict";
  14.  
  15. document.addEventListener("click", (e) => {
  16. // not clicked on anchor tag
  17. const closestAnchor = e.target?.closest("a");
  18. if (!closestAnchor) {
  19. return;
  20. }
  21. // not clicked on alt or option key
  22. if (!e.altKey) {
  23. return;
  24. }
  25.  
  26. // disable the "alt/option + click" download shortcut combo
  27. e.preventDefault();
  28. console.log(
  29. `Disabled "alt/option + click" download shortcut combo for link: ${closestAnchor.innerText}`,
  30. );
  31. });
  32. })();