Disable "Alt/Option + Click" shortcut

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Disable "Alt/Option + Click" shortcut
// @namespace    https://vighnesh153.dev/
// @version      2024-08-08
// @description  Disables "Alt/Option + Click" shortcut combo that downloads the link on Chrome
// @author       vighnesh153
// @match        *://*/*
// @icon         https://raw.githubusercontent.com/vighnesh153/vighnesh153-monorepo/main/nodejs-tools/nodejs-chrome-extensions/disable-alt-click-download/images/logo_48x48.png
// @grant        none
// ==/UserScript==

(function () {
  "use strict";

  document.addEventListener("click", (e) => {
    // not clicked on anchor tag
    const closestAnchor = e.target?.closest("a");
    if (!closestAnchor) {
      return;
    }
    // not clicked on alt or option key
    if (!e.altKey) {
      return;
    }

    // disable the "alt/option + click" download shortcut combo
    e.preventDefault();
    console.log(
      `Disabled "alt/option + click" download shortcut combo for link: ${closestAnchor.innerText}`,
    );
  });
})();