ywzhaiqi / userscript

本人原创或修改的 GM 脚本,包括小说阅读脚本等。
https://greasyfork.org/zh-CN/users/145-ywzhaiqi
546 stars 166 forks source link

Copy and select text in chapter of qidian #49

Closed t2hv33 closed 9 years ago

t2hv33 commented 9 years ago

Hi ywzhaiqi, I need a script can select and copy text in free chapter of qidian. Look like this. http://read.qidian.com/BookReader/*.aspx In all of your script what script have this function Thanks anyway.

ywzhaiqi commented 9 years ago
(function(){var doc=document;var bd=doc.body;bd.onselectstart=bd.oncopy=bd.onpaste=bd.onkeydown=bd.oncontextmenu=bd.onmousemove=bd.onselectstart=bd.ondragstart=doc.onselectstart=doc.oncopy=doc.onpaste=doc.onkeydown=doc.oncontextmenu=null;doc.onselectstart=doc.oncontextmenu=doc.onmousedown=doc.onkeydown=function (){return true;};with(document.wrappedJSObject||document){onmouseup=null;onmousedown=null;oncontextmenu=null;}var arAllElements=document.getElementsByTagName('*');for(var i=arAllElements.length-1;i>=0;i--){var elmOne=arAllElements[i];with(elmOne.wrappedJSObject||elmOne){onmouseup=null;onmousedown=null;}}var head=document.getElementsByTagName('head')[0];if(head){var style=document.createElement('style');style.type='text/css';style.innerHTML="html,*{-moz-user-select:auto!important;}";head.appendChild(style);}void(0);})();
t2hv33 commented 9 years ago

It's only working when web is loading. When web is load: I can selected text. But when web load completed, I can't. Can you make a script working with this domain. http://read.qidian.com/BookReader/*.aspx Best regards,

ywzhaiqi commented 9 years ago
// ==UserScript==
// @name         Qidian copy
// @namespace    http://your.homepage/
// @version      0.1
// @description  enter something useful
// @author       You
// @match        http://read.qidian.com/BookReader/*,*.aspx
// @grant        none
// ==/UserScript==

function run() {
    var doc=document;var bd=doc.body;bd.onselectstart=bd.oncopy=bd.onpaste=bd.onkeydown=bd.oncontextmenu=bd.onmousemove=bd.onselectstart=bd.ondragstart=doc.onselectstart=doc.oncopy=doc.onpaste=doc.onkeydown=doc.oncontextmenu=null;doc.onselectstart=doc.oncontextmenu=doc.onmousedown=doc.onkeydown=function (){return true;};with(document.wrappedJSObject||document){onmouseup=null;onmousedown=null;oncontextmenu=null;}var arAllElements=document.getElementsByTagName('*');for(var i=arAllElements.length-1;i>=0;i--){var elmOne=arAllElements[i];with(elmOne.wrappedJSObject||elmOne){onmouseup=null;onmousedown=null;}}var head=document.getElementsByTagName('head')[0];if(head){var style=document.createElement('style');style.type='text/css';style.innerHTML="html,*{-moz-user-select:auto!important;}";head.appendChild(style);}void(0);

    jQuery(document).off("selectstart").off("contextmenu");
}

run()
window.addEventListener('load', run);
t2hv33 commented 9 years ago

hope you have a really good weekend. It's work very good. :+1: