Greasy Fork is available in English.

超简易解除网页限制

解除网页的复制 、拖动 、选中 、右键 、粘贴等限制。没有多余的代码,仅28行,尽量做到不占资源.

< Feedback on 超简易解除网页限制

Question/comment

§
Posted:

代码可精减到16行

框架(iframe)之类的元素不需要处理,脚本管理器会在其环境下执行脚本!!

var $ = window.jQuery,
events = ['contextmenu', 'dragstart', 'mouseup', 'copy', 'beforecopy', 'selectstart', 'select', 'keydown'];
function unbind(ele) {
    events.forEach(function (evt) {
        ele['on' + evt] = null;
        if ($) $(ele).unbind(evt);
    });
};
function runScript() {
    [window, document].forEach(unbind);
    events.forEach.call(document.querySelectorAll('*'), unbind);
}
window.onload = runScript;
window.onhashchange = function () {
    setTimeout(runScript, 300);
};

Post reply

Sign in to post a reply.