僅供復制題庫題目進行打印學習使用!
最近想把賽氪網題庫中的題目打印出來做練習,發現題庫中的題目不能復制,不能在試卷上勾畫標記太難受了,而且不能留作材料以后復習,故出此策。
而且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 });
})();