当前位置: 首页 > news >正文

完美解决浏览器不能复制的问题(比如赛氪网的中题库练习题)

仅供复制题库题目进行打印学习使用!

最近想把赛氪网题库中的题目打印出来做练习,发现题库中的题目不能复制,不能在试卷上勾画标记太难受了,而且不能留作材料以后复习,故出此策。
而且Ctrl+P打印出的pdf会缺少题目。(我的打印钱...)

目录

一、问题

二、解决方法

1. Fn+F12打开控制台​编辑

2.输入代码回车

3.复制内容成功


一、问题

正常打开赛氪网题库是无法进行复制的(或者其他网页)。

二、解决方法

1. Fn+F12打开控制台

2.输入代码回车

(function() {// 解除常见禁止操作function unlock() {document.oncontextmenu = null;document.onselectstart = null;document.oncopy = null;document.oncut = null;document.onpaste = null;document.onmousedown = null;document.onmouseup = null;document.body.oncontextmenu = null;document.body.onselectstart = null;document.body.oncopy = null;document.body.oncut = null;document.body.onpaste = null;document.body.onmousedown = null;document.body.onmouseup = null;// 删除禁止选中的CSS样式const css = '* { -webkit-user-select: text !important; -moz-user-select: text !important; -ms-user-select: text !important; user-select: text !important; }';const style = document.createElement('style');style.type = 'text/css';style.appendChild(document.createTextNode(css));document.head.appendChild(style);// 移除网页监听的所有阻止复制的事件["copy", "cut", "paste", "selectstart", "contextmenu", "mousedown", "mouseup", "keydown", "keypress", "keyup"].forEach(function(event) {document.body.addEventListener(event, function(e) {e.stopPropagation();}, true);});// 尝试解除iframe中的限制document.querySelectorAll('iframe').forEach(iframe => {try {const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;iframeDoc.oncontextmenu = null;iframeDoc.onselectstart = null;iframeDoc.oncopy = null;iframeDoc.oncut = null;iframeDoc.onpaste = null;iframeDoc.onmousedown = null;iframeDoc.onmouseup = null;} catch (e) {console.log('iframe无法访问,跨域保护');}});console.log('%c复制限制解除成功!', 'color: green; font-weight: bold;');}unlock();// 监听页面动态生成内容,持续解除const observer = new MutationObserver(unlock);observer.observe(document.body, { childList: true, subtree: true });
})();

3.复制内容成功

相关文章:

  • Spring 数据库编程
  • Redis(二) - Redis命令详解
  • Java 使用 LangChain4j 搭建大模型的 RAG 教程
  • sort和swap函数
  • MODBUS TCP 转 CANOpen
  • C++ 贪吃蛇 Greedy Snake
  • 【React】通过 fetch 发起请求,设置 proxy 处理跨域
  • string函数的应用
  • 基于 BaseRecyclerViewAdapterHelper 4.x 的封装
  • PyTorch快速入门
  • ETL数据集成平台在交通运输行业的五大应用场景
  • 文件包含(详解)
  • 全志H5,NanopiKP1lus移植QT5.12记录
  • 常用的优化算法及横向对比
  • langchain tools源码解析以及扩展
  • 快速使用工具Cursor
  • 【天外之物】线元
  • MacOS怎么显示隐藏文件
  • python-图片分割
  • 慢速率拉伸热变形工艺试验机
  • 教育部增设29种本科新专业,首建战略急需专业超常设置机制
  • 私和人命:清代四川南部县谢相荣投河溺毙一案
  • 从沙漠到都市:贝亲世界地球日特别行动,以桃叶冰爽力开启地球降温之旅
  • 探索未来课堂更多可能,“人工智能课堂分析循证实验室”在沪成立
  • 神舟二十号全系统合练今日展开
  • 上海自然博物馆下月开启中国恐龙大展,还在筹备中国古人类大展