Disable Mailto Links

Disable all mailto links on web pages

目前為 2025-01-28 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Disable Mailto Links
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Disable all mailto links on web pages
// @include      *
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to disable mailto links
    function disableMailtoLinks() {
        const links = document.querySelectorAll('a[href^="mailto:"]');
        links.forEach(link => {
            link.addEventListener('click', function(event) {
                event.preventDefault();
            });
            link.style.pointerEvents = 'none'; // Optional: visually indicate the link is disabled
            link.style.color = 'gray'; // Optional: change link color to show it's disabled
        });
    }

    // Run the function on page load
    window.addEventListener('load', disableMailtoLinks);
})();