Greasy Fork

Greasy Fork is available in English.

Prevent Search and Copy Popup on ScienceDirect

阻止弹出“Search”和“Copy”弹窗,仅在包含sciencedirect或science-direct的网站上运行

当前为 2024-09-22 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Prevent Search and Copy Popup on ScienceDirect
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  阻止弹出“Search”和“Copy”弹窗,仅在包含sciencedirect或science-direct的网站上运行
// @author       YourName
// @match        *://*.sciencedirect.com/*
// @match        *://*.science-direct.com/*
// @match        *://*sciencedirect*/*
// @match        *://*science-direct*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=example.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 阻止触发弹窗的事件
    function preventPopupEvents(event) {
        event.stopPropagation();  // 阻止事件冒泡
        console.log('Popup event prevented:', event.type);
    }

    // 阻止选中文本后的事件,防止弹窗
    document.addEventListener('mouseup', preventPopupEvents, true);
    document.addEventListener('selectionchange', preventPopupEvents, true);

    // 如果弹窗已经存在,移除它
    function removePopup() {
        const popup = document.querySelector('.search-for-selected-text');
        if (popup) {
            popup.remove();
            console.log('Search and Copy popup removed.');
        }
    }

    // 页面加载时移除已经存在的弹窗
    window.addEventListener('load', function() {
        // 初次移除弹窗
        removePopup();

        // 设置定时器,确保弹窗不再出现
        setInterval(removePopup, 500);
    });
})();