You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除点击任意文本时弹出的GitHub定义与引用弹窗?

移除GitHub文本点击弹出的定义/引用弹窗方法
  • 临时解决(单次生效)
    打开浏览器开发者工具(按F12),切换到控制台(Console),输入以下代码回车即可:

    // 移除已弹出的弹窗并阻止新弹窗触发
    document.addEventListener('click', e => {
      const hoverCard = document.querySelector('.hover-card');
      if (hoverCard) hoverCard.remove();
      if (e.target.closest('[data-hovercard-type]')) {
        e.stopPropagation();
        e.preventDefault();
      }
    }, true);
    
    // 强制隐藏弹窗样式
    const style = document.createElement('style');
    style.textContent = '.hover-card { display: none !important; }';
    document.head.appendChild(style);
    

    执行后就能正常选中、复制文本,不会触发弹窗。

  • 永久解决(自动生效)
    安装Tampermonkey(油猴)浏览器扩展,新建一个脚本,粘贴以下代码并保存:

    // ==UserScript==
    // @name         禁用GitHub悬浮弹窗
    // @namespace    http://tampermonkey.net/
    // @version      0.1
    // @description  阻止GitHub点击文本时弹出的定义/引用弹窗,支持纯文本选中复制
    // @author       自定义名称
    // @match        https://github.com/*
    // @match        https://gist.github.com/*
    // @grant        none
    // ==/UserScript==
    
    (function() {
        'use strict';
    
        // 全局隐藏弹窗样式
        const style = document.createElement('style');
        style.textContent = '.hover-card { display: none !important; }';
        document.head.appendChild(style);
    
        // 拦截弹窗触发事件
        document.addEventListener('click', e => {
            const trigger = e.target.closest('[data-hovercard-type], .js-hovercard-trigger');
            if (trigger) {
                e.stopPropagation();
                e.preventDefault();
            }
        }, true);
    })();
    

    之后访问GitHub及Gist页面时,脚本会自动禁用弹窗功能。

内容的提问来源于stack exchange,提问作者Probosckie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 09:10:35