Greasy Fork is available in English.

避免 bing search 点击文本、选择链接时js打开链接

bing search 点击文本、选择链接时避免js打开链接,可以对文本、链接中的文本用右键了

// ==UserScript==
// @name         避免 bing search 点击文本、选择链接时js打开链接
// @namespace    https://greasyfork.org/zh-CN/users/722555-vveishu
// @version      1.3
// @description  bing search 点击文本、选择链接时避免js打开链接,可以对文本、链接中的文本用右键了
// @author       vveishu
// @match        https://www.bing.com/search?*
// @icon         https://www.bing.com/favicon.ico
// @grant        none
// @run-at       document-body
// ==/UserScript==

(function() {
    'use strict';

    // 使用 MutationObserver 监控并移除目标脚本
    const observer = new MutationObserver((mutations) => {
        for (const mutation of mutations) {
            if (mutation.addedNodes) {
                for (const node of mutation.addedNodes) {
                    if (node.tagName === 'SCRIPT' && node.src.includes('-2EVJNDwymhr08bVch00GwpjiDA.br.js')) {
                        node.remove(); // 移除目标脚本
                        console.log('Blocked script:', node.src);
                    } else if (node.tagName === 'SCRIPT' && node.textContent) {
                        // 检查 script 标签的内容是否包含特定字符串
                        let scriptContent = node.textContent;
                        const targetString = "{'A:rms:answers:Web:SerpKeyboardNavigation':'\\/rp\\/-2EVJNDwymhr08bVch00GwpjiDA.br.js'}";
                        if (scriptContent.includes(targetString)) {
                            // 替换包含特定字符串的部分
                            scriptContent = scriptContent.replace(targetString, '');
                            node.textContent = scriptContent;
                            console.log('Removed specific string from script.');
                        }
                    }
                }
            }
        }
    });

    observer.observe(document.documentElement, { childList: true, subtree: true });
})();