最近老是遇到不让复制的网页,所以在网上找来脚本来解除限制
完整代码如下
(function(window) {
var eventArr = ['contextmenu', 'dragstart', 'mouseup', 'copy', 'beforecopy', 'selectstart', 'select', 'keydown'];
function runScript(window) {
var document = window["document"],
$ = window["jQuery"],
unbind = function(ele) {
eventArr.forEach(function(evt) {
ele['on' + evt] = null;
if ($) {
$(ele).unbind(evt);
}
try {
if (/frame/i.test(ele.tagName)) {
runScript(ele.contentWindow);
}
} catch (err) {}
});
};
[window, document].forEach(unbind);
for (var i = 0, all = document.all, len = all.length; i < len; i++) {
var ele = all[i];
if (ele && ele.nodeType === 1) {
unbind(ele);
}
}
}
runScript(window);
})(window);
压缩后代码如下
javascript:(function(c){function e(a){var b=a.document,f=a.jQuery,g=function(a){h.forEach(function(b){a["on"+b]=null;f&&f(a).unbind(b);try{/frame/i.test(a.tagName)&&e(a.contentWindow)}catch(c){}})};[a,b].forEach(g);a=0;for(var b=b.all,c=b.length;a<c;a++){var d=b[a];d&&1===d.nodeType&&g(d)}}var h="contextmenu dragstart mouseup copy beforecopy selectstart select keydown".split(" ");e(c)})(window);
将其添加为书签即可,然后再遇到禁止右键的网页,点击一下,即可解除限制。
网友评论