惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
PCI Perspectives
PCI Perspectives
Webroot Blog
Webroot Blog
罗磊的独立博客
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
Last Week in AI
Last Week in AI
美团技术团队
Help Net Security
Help Net Security
The Hacker News
The Hacker News
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
The Register - Security
The Register - Security
IT之家
IT之家
WordPress大学
WordPress大学
Jina AI
Jina AI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Help Net Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
NISL@THU
NISL@THU
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Scott Helme
Scott Helme
V
Vulnerabilities – Threatpost
B
Blog
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
T
The Exploit Database - CXSecurity.com
S
Security Affairs
小众软件
小众软件
Hacker News: Ask HN
Hacker News: Ask HN
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
W
WeLiveSecurity
A
Arctic Wolf
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence

博客园 - jack_Meng

油候脚本中,使用GM_info对象,打印脚本信息 高中免费电子教辅资料合集 Windows防火墙关闭445端口:Windows在防火墙禁用echo-reply(type 0)、time-exceeded(type 11)、destination-unreachable(type 3)类型的ICMP包 WinForm 双屏开发中屏幕适配与窗口定位 高考志愿填报之计算机类专业院校报考指南(2026版) WebSocket 快速入门教程(附示例源码) 自动生成项目工具--AutoBuilder,一键干掉80%的重复CRUD工作 C#/.NET/.NET Core优秀项目和框架2026年5月简报 在Win10系统中,默认使用照片查看器 C#实现控制台多区域输出 解决: 您的连接不是私密连接,您目前无法访问 因为此网站使用了 HSTS 小说下载 网页版时间,可全屏显示 个人笔记本连接公共WIFI的安全措施 追更 HelloGitHub 一整年,年度盘点 基于Rust开发的m3u8下载器M3U8Quicker:支持断点续传、边下边播 新写了个直播录制工具,可录制抖音快手斗鱼直播 bing 每日一图 --- 桌面壁纸 一款基于 C# 开发的 Windows 10/11 系统增强优化工具 适合个人的免费域名 语雀里存了三年的笔记,导出到了本地插件----YuqueOut C# 也能像 Python 一样写脚本 | .NET 10 构建基于文件的应用 js 双击页面 开始/暂停 页面滚动 使用bat批量给txt追加内容 Python摄像头监控:运动检测+自动录像+时间水印 【译】告别繁琐查错:认识下新的 Visual Studio Debugger Agent Workflow 好消息,在 Visual Studio 中可以免费使用 GitHub Copilot 了! [C#] 零依赖高性能跨平台 Web 胶水库 -- PicoServer 我的第一款独立产品--TaskManager 写 EF Core 查询,优化查询语句 最新.NET新手入门学习网站合集(2026更新版) Avalonia UI:.NET 跨平台桌面开发的“真香”选择 一个 txt 生成并保存 mp3的 Python 脚本
使用油候脚本,移除页面无法选择文字
jack_Meng · 2026-07-25 · via 博客园 - jack_Meng

在浏览页面的时候,页面上使用了禁用选择文字,禁用了右键等功能,找豆包给了一个解决方案,如下:

方案 1:解绑 document 上所有 selectstart 事件(最简单)

// jQuery 解绑document所有selectstart绑定
$(document).unbind('selectstart');

// 顺带把右键、拖拽一并清掉
$(document).unbind('contextmenu dragstart mousedown');

// 再强制修复CSS不能选中问题
$('body, *').css({
    'user-select': 'auto',
    '-webkit-user-select': 'auto'
});

方案 2:精准只解绑那一个匿名函数(严谨版)

如果页面其他代码也绑定了 selectstart,不想全部清空,只能保存原函数引用再解绑,但匿名函数无法直接获取,只能用 jQuery 内部清理:

// 清空document上jQuery托管的所有事件(慎用,会清掉所有jQuery绑定事件)
$(document).unbind();

方案 3:不用管解绑,直接强行重写事件拦截(终极覆盖)

不管它绑了多少层 jQuery 事件、原生 addEventListener,直接覆盖:

// 原生事件置空
document.onselectstart = null;
document.oncontextmenu = null;

// 阻止jQuery再次绑定生效
Object.defineProperty(document, 'onselectstart', {
    set: function() {},
    get: function() { return null; }
});

// 全局CSS放开选中
document.querySelectorAll('*').forEach(el => {
    el.style.userSelect = 'auto';
    el.style.webkitUserSelect = 'auto';
});

方案 4:彻底根治:禁用 JavaScript(推荐一劳永逸)

  1. F12 打开开发者工具 → 右上角设置图标
  2. Settings → Debugger → 取消 Enable JavaScript
  3. 刷新页面,所有 jQuery 绑定、原生事件全部失效,CSS 限制也可手动修改,百分百可以选中文字。

补充小知识

  1. .bind() 对应解绑 .unbind()
  2. 新版 jQuery .on() 对应解绑 .off()
  3. 原生 addEventListener 只能通过相同函数引用 removeEventListener,匿名函数无法单个移除;
  4. 绝大多数不能选文字,CSS user-select: none 才是大头,只清事件不改 CSS 依然选不动。

======================================================================================

个人使用

版本1

主要是移除页面上的jQuery的绑定的事件

// ==UserScript==
// @name         moveSelect
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http*://shyahs.chneic.sh.cn/*


// @icon         https://www.google.com/s2/favicons?sz=64&domain=doubao.com
// @grant        none
// ==/UserScript==


(function (){
    'use strict';
    // Your code here...

    $(document).ready(function(){
        // 在此处执行希望在页面加载完成后执行的操作
        console.log("moveSelect==========页面加载完成")
        //setTimeout(unbindSelect,1000);
        unbindSelect();

    });

})();



function unbindSelect()
{
    // 主要解决延安中学网站无法选择的问题,jQuery 解绑document所有selectstart绑定, 顺带把右键、拖拽一并清掉
    $(document).unbind('selectstart contextmenu dragstart mousedown');
    // 再强制修复CSS不能选中问题
    $('body, *').css({
        'user-select': 'auto',
        '-webkit-user-select': 'auto'
    });
    console.log("moveSelect==========解绑document所有selectstart绑定")

    // GM_info 内置对象,不需要额外权限
    console.log('当前脚本名称:', GM_info.script.name);
    console.log('脚本信息:', GM_info.script);
    console.log('脚本完整信息:', GM_info);
}

View Code

版本2

增加统一日志打印的功能

// ==UserScript==
// @name         moveSelect
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http*://*
// @match        http*://shyahs.chneic.sh.cn/*

// @icon         https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @grant        none
// ==/UserScript==


(function (){
    'use strict';
    // Your code here...

    $(document).ready(function(){
        // 在此处执行希望在页面加载完成后执行的操作
        log("==========页面加载完成事件")
        //setTimeout(unbindSelect,1000);
        unbindSelect();

    });

})();

//匿名函数调用日志
(()=>{
    log('匿名函数内容');
})();

//* 统一日志打印
//* @param  {...any} args 要打印的内容
function log(...args) {
    const fnName = new Error().stack.split('\n')[2].match(/at (\w+)/)[1];
    console.log(`[${GM_info.script.name}]-[${fnName}]`, ...args);
}


function unbindSelect()
{
    // 主要解决延安中学网站无法选择的问题,jQuery 解绑document所有selectstart绑定, 顺带把右键、拖拽一并清掉
    $(document).unbind('selectstart contextmenu dragstart mousedown');
    // 再强制修复CSS不能选中问题
    $('body, *').css({
        'user-select': 'auto',
        '-webkit-user-select': 'auto'
    });
    log("==========解绑document所有selectstart绑定")
}

View Code