delete';
- // node.innerHTML = '';
- node.innerHTML = ' set 限制解除 ';
- if(window.self === window.top){
- if (document.querySelector("body")){
- document.body.appendChild(node);
- } else {
- document.documentElement.appendChild(node);
- }
- }
- node.addEventListener("mouseover",function(){
- node.classList.add("rwl-active-iqxin");
- });
- node.addEventListener("mouseleave",function(){
- setTimeout(function(){
- node.classList.remove("rwl-active-iqxin");
- black_check(black_node.checked);
- },100)
- });
-
- var style = document.createElement("style");
- style.type="text/css";
-
- var styleInner = "#rwl-iqxin{" +
- "position:fixed;" +
- "transform:translate(-95px,0);" +
- "width:85px;" +
- "height:25px;" +
- "font-size:12px;" +
- "font-weight: 500;" +
- "font-family:Verdana, Arial, '宋体';" +
- "color:#fff;" +
- "background:#333;" +
- "z-index:2147483647;" +
- "margin: 0;" +
- "opacity:0.05;" +
- "transition:0.3s;" +
- "overflow:hidden;" +
- "user-select:none;" +
- "text-align:center;" +
- "white-space:nowrap;" +
- "line-height:25px;" +
- "padding:0 16px;" +
- "border:1px solid #ccc;" +
- "border-width:1px 1px 1px 0;" +
- "border-bottom-right-radius:5px;" +
- "box-sizing: content-box;" +
- "}" +
- "#rwl-iqxin input{" +
- "margin: 0;" +
- "padding: 0;" +
- "vertical-align:middle;" +
- "-webkit-appearance:checkbox;" +
- "-moz-appearance:checkbox;" +
- "position: static;" +
- "clip: auto;" +
- "opacity: 1;" +
- "cursor: pointer;" +
- "}" +
- "#rwl-iqxin.rwl-active-iqxin{" +
- "left: 0px;" +
- "transform:translate(0,0);" +
- "opacity: 0.9;" +
- "height: 32px;" +
- "line-height: 32px" +
- "}" +
- "#rwl-iqxin label{" +
- "margin:0;" +
- "padding:0;" +
- "font-weight:500;" +
- "}" +
- "#rwl-iqxin #rwl-setbtn{" +
- "margin: 0 4px 0 0;" +
- "padding: 0 0 0 4px;" +
- "border: none;" +
- "border-radius: 2px;" +
- "cursor: pointer;" +
- "background: #fff;" +
- "color: #000;" +
- "}" +
- " "
-
- if(!rwl_userData.addBtn){
- var styleTemp = "#rwl-iqxin{display:none}";
- style.innerHTML = styleInner + styleTemp;
- } else {
- style.innerHTML = styleInner;
- }
- if(document.querySelector("#rwl-iqxin")){
- // console.log("通过style插入");
- document.querySelector("#rwl-iqxin").appendChild(style);
- } else {
- // console.log("通过GM插入");
- GM_addStyle(styleInner);
- }
- };
-
- // 给按钮绑定点击事件
- function setBtnClick(){
- document.querySelector("#rwl-setbtn").addEventListener("click",setMenu);
- }
-
- // 菜单
- function setMenu(){
- var oldEditBox = document.querySelector("#rwl-setMenu");
- if(oldEditBox){
- oldEditBox.parentNode.removeChild(oldEditBox);
- return;
- }
- var userSetting = GM_getValue("rwl_userData");
- var upload_checked = userSetting.connectToTheServer?"checked":"";
- var btnchecked = userSetting.addBtn?'checked':''
-
- var odom = document.createElement("div");
- odom.id = "rwl-setMenu";
- odom.style.cssText ="position: fixed;" +
- "top: 100px;" +
- "left: 50px;" +
- "padding: 10px;" +
- "background: #fff;" +
- "border-radius: 4px;";
- GM_addStyle("#rwl-setMenuSave," +
- "#rwl-reset," +
- "#rwl-setMenuClose{" +
- "margin: 0;" +
- "padding: 0 2px;" +
- "border: none;" +
- "border-radius: 2px;" +
- "cursor: pointer;" +
- "background: #fff;" +
- "color: #000;" +
- "}" +
- "#rwl-reset{" +
- "border: 1px solid #666;" +
- "}" +
- "#rwl-setMenuSave{" +
- "border: 1px solid green;" +
- "}" +
- "#rwl-setMenuClose{" +
- "border: 1px solid red;" +
- "}" +
- "#rwl-setMenu{" +
- "text-align:left;" +
- "font-size:14px;" +
- "z-index:999999;" +
- "border: 1px solid cornflowerblue;" +
- "}" +
- "#rwl-setMenu p{" +
- "margin:5px auto;" +
- "}" +
- " ")
- var innerH = "" +
- "距离顶部距离(单位 像素)
" + "" +
- // " 允许上传黑名单
" + "" +
- "快捷键:" +
- "" +
- "
" +
- " 显示按钮 点击脚本管理扩展可以再次打开设置
" + "" +
- "问题反馈地址: GitHub(qxin), GreasyFork(qxin)
" +
- "项目原作者为 cat7373, 项目主页
" +
- "能力有限,不能每个网站都能完美
" +
- "如若反馈,务必带上详细网址
" +
- "
" +
- // "显示按钮(待添加)
" +
- // "按钮透明度(待添加)
" +
- // "快速复制(待添加)
" +
- // "其他 (待添加)
" +
- "数据存储方式为JSON,如若在此修改,注意引号逗号
" +
- "" +
- "
" +
- "清空设置 " +
- " " +
- " " +
- "--| qxin v4.4.5 2021-03-19 |--" +
- ""
- "";
- odom.innerHTML = innerH;
- document.body.appendChild(odom);
-
- document.querySelector("#rwl-setMenuSave").addEventListener("click",saveSetting);
- document.querySelector("#rwl-setMenuClose").addEventListener("click",closeMenu);
- document.querySelector("#rwl-reset").addEventListener("click",rwlReset);
-
- }
-
- // 保存选项
- function saveSetting(){
- var positionTop = document.querySelector("#rwl-setMenu #positiontop").value;
- // var uploadChecked = document.querySelector("#rwl-setMenu #uploadchecked").checked;
- var shortcut = document.querySelector("#rwl-setMenu #rwl-shortcut").selectedIndex;
- var addBtnChecked = document.querySelector("#rwl-setMenu #btnchecked").checked;
- var codevalue = document.querySelector("#rwl-setMenu textarea").value;
- if(codevalue){
- var userSetting = GM_getValue("rwl_userData");
-
- userSetting.addBtn = addBtnChecked;
- userSetting.data = JSON.parse(codevalue);
- userSetting.positionTop = parseInt(positionTop);
- userSetting.shortcut = parseInt(shortcut);
- // userSetting.connectToTheServer = uploadChecked;
-
- GM_setValue("rwl_userData",userSetting);
- // 刷新页面
- setTimeout(function(){
- window.location.reload();
- },300);
- } else {
- alert("输入为空");
- // this.reset();
- }
- closeMenu();
- }
- // 复原菜单
- function rwlReset(){
- GM_deleteValue("rwl_userData");
- window.location.reload();
- }
-
- //关闭菜单
- function closeMenu(){
- var oldEditBox = document.querySelector("#rwl-setMenu");
- if(oldEditBox){
- oldEditBox.parentNode.removeChild(oldEditBox);
- return;
- }
- }
-
- // 增加拖拽事件 进行绑定
- function addDragEven(){
- setTimeout(function(){
- try {
- dragBtn()
- } catch (e) {
- console.error("dragBtn函数 报错");
- }
- },1000)
- // dragBtn(); // 增加拖动事件
- }
-
- // 增加拖动事件 func
- function dragBtn(){
- var rwl_node = document.querySelector("#rwl-iqxin");
- rwl_node.addEventListener("mousedown",function(event){
- rwl_node.style.transition = "null";
- var disX = event.clientX - rwl_node.offsetLeft;
- var disY = event.clientY - rwl_node.offsetTop;
-
- var move = function(event){
- rwl_node.style.left = event.clientX - disX + "px" ;
- rwl_node.style.top = event.clientY - disY + "px" ;
- }
-
- document.addEventListener("mousemove",move);
- document.addEventListener("mouseup",function(){
- rwl_node.style.transition = "0.3s";
- document.removeEventListener("mousemove",move);
- // 此函数内所有的注释语句都是有用的
- // 开启后,可拖动到屏幕右侧,但尚未添加css
- // 在上面添加 rwl-active-iqxin 的地方加上判断左右,在加上相应的css即可
- // 懒 2018-04-18 21:51:32
- // var bodyWidth = document.body.clientWidth;
- var rwl_nodeWidth = rwl_node.offsetLeft + rwl_node.offsetWidth/2;
- // if(rwl_nodeWidth > bodyWidth/2){
- // rwl_node.style.left = "auto";
- // rwl_node.style.right = 0;
- // rwl_userData.positionLeft = "auto";
- // rwl_userData.positionRight = "0";
- // } else {
- rwl_node.style.right = rwl_userData.positionRight = "auto";
- rwl_node.style.left = rwl_userData.positionLeft = 0;
- // }
- rwl_userData.positionTop = rwl_node.offsetTop;
- GM_setValue("rwl_userData",rwl_userData);
-
- })
- })
- }
-
- // 初始化 init func 这里才是核心
- function init() {
- // 针对个别网站采取不同的策略
- rule = clear();
- // 设置 event 列表
- hook_eventNames = rule.hook_eventNames.split("|");
- // TODO Allowed to return value
- unhook_eventNames = rule.unhook_eventNames.split("|");
- eventNames = hook_eventNames.concat(unhook_eventNames);
-
- // 调用清理 DOM0 event 方法的循环
- if(rule.dom0) {
- setInterval(clearLoop, 10 * 1000);
- setTimeout(clearLoop, 1500);
- window.addEventListener('load', clearLoop, true);
- clearLoop();
- }
-
- // hook addEventListener //导致搜索跳转失效的原因
- if(rule.hook_addEventListener) {
- EventTarget.prototype.addEventListener = addEventListener;
- document.addEventListener = addEventListener;
-
- if(hasFrame){
- for(let i = 0;i= 0) {
- this.returnValue = true;
- }
- });
- }
-
- // 添加CSS // console.debug('url: ' + url, 'storageName:' + storageName, 'rule: ' + rule.name);
- if(rule.add_css) {
- GM_addStyle('html, :not([class*="rwl-exempt"]) {-webkit-user-select:text!important; -moz-user-select:text!important;} :not([class*="rwl-exempt"]) ::selection {color:#fff; background:#3390FF!important;}');
- } //else {
- //GM_addStyle('html, :not([class*="rwl-exempt"]) {-webkit-user-select:text!important; -moz-user-select:text!important;}');
- //}
- }
-
- // Hook addEventListener proc
- function addEventListener(type, func, useCapture) {
- var _addEventListener = this === document ? document_addEventListener : EventTarget_addEventListener;
- if(hook_eventNames.indexOf(type) >= 0) {
- _addEventListener.apply(this, [type, returnTrue, useCapture]);
- } else if(unhook_eventNames.indexOf(type) >= 0) {
- var funcsName = storageName + type + (useCapture ? 't' : 'f');
-
- if(this[funcsName] === undefined) {
- this[funcsName] = [];
- _addEventListener.apply(this, [type, useCapture ? unhook_t : unhook_f, useCapture]);
- }
-
- this[funcsName].push(func);
- } else {
- _addEventListener.apply(this, arguments);
- }
- }
-
- // 清理循环
- function clearLoop() {
- rule = clear() // 对于动态生成的节点,随时检测
- var elements = getElements();
-
- for(var i in elements) {
- for(var j in eventNames) {
- var name = 'on' + eventNames[j];
-
- // ;?未解决
- // 2018-04-02 elements中会有字符串出现,原版不会,问题不明,根本原因尚未解决
- // 相关反馈 https://greasyfork.org/zh-CN/forum/discussion/36014
- // 问题版本号 v3.0.7
- // 问题补充 之前可以使用,具体版本未测(2018-04-02 21:27:53),原版可以使用
- if(Object.prototype.toString.call(elements[i])=="[object String]"){
- continue;
- }
-
- // console.log(elements[i])
- // if(typeof elements[i][name] === "object"){
- // console.log(typeof elements[i][name])
- // }
- if(elements[i][name] !== null && elements[i][name] !== onxxx) {
- if(unhook_eventNames.indexOf(eventNames[j]) >= 0) {
- elements[i][storageName + name] = elements[i][name];
- elements[i][name] = onxxx;
- } else {
- elements[i][name] = null;
- }
- }
- }
- }
-
- document.onmousedown = function(){return true;};
- }
-
- // 返回true的函数
- function returnTrue(e) {
- return true;
- }
- function unhook_t(e) {
- return unhook(e, this, storageName + e.type + 't');
- }
- function unhook_f(e) {
- return unhook(e, this, storageName + e.type + 'f');
- }
- function unhook(e, self, funcsName) {
- var list = self[funcsName];
- for(var i in list) {
- list[i](e);
- }
-
- e.returnValue = true;
- return true;
- }
- function onxxx(e) {
- var name = storageName + 'on' + e.type;
- this[name](e);
-
- e.returnValue = true;
- return true;
- }
-
- // 获取所有元素 包括document
- function getElements() {
- var elements = Array.prototype.slice.call(document.getElementsByTagName('*'));
- elements.push(document);
-
- // 循环所有 frame 窗口
- var frames = document.querySelectorAll("frame")
- if(frames){
- hasFrame = frames;
- var frames_element;
- for (let i = 0;i1;
- })
- return data_temp;
- }
-
- // 检查是否存在于黑名单中 返回位置 func
- function check_black_list(list,host){
- for(let i=0;i1;
- })
-
- // 更新数据
- rwl_userData.data = lists.sort();
-
- // 将本地黑名单上传
- // if (rwl_userData.waitUpload.length > 0 && rwl_userData.connectToTheServer){
- // // console.log("rwl : 上传...",rwl_userData.waitUpload);
- // // console.log("rwl : 开始上传-----");
- // GM_xmlhttpRequest({
- // method: "POST",
- // // url: "http://127.0.0.1:8000/tool/testajax/",
- // url: "http://eemm.me/tool/rwl_upload/",
- // data: JSON.stringify(rwl_userData),
- // headers: {
- // "Content-Type": "application/x-www-form-urlencoded"
- // },
- // onload: function(response) {
- // // console.log("rwl : 上传成功----");
- // }
- // });
- // rwl_userData.waitUpload = [];
- // }
-
- GM_setValue("rwl_userData",rwl_userData);
- return rwl_userData;
- }
-
- // 数组去重
- function unique(arr) {
- var ret = []
- for (var i = 0; i < arr.length; i++) {
- var item = arr[i]
- if (ret.indexOf(item) === -1) {
- ret.push(item)
- }
- }
- return ret;
- }
-
- // 复制到剪贴板
- function setClipboard(){
- var text_obj = window.getSelection();
- var text = text_obj.toString();
- GM_setClipboard(text);
-
- }
-
- // 快捷键 F1(ctrl+f1) 复制
- function hotkey() {
- var a = window.event.keyCode;
- // if ((a == 112) && (event.ctrlKey)) {
- if (a == 112 && userSetting.shortcut == 1) {
- event.preventDefault();
- setClipboard();
- event.keyCode=0;
- event.returnValue=false;
- return false;
- } else if (a == 112 && (event.ctrlKey) && userSetting.shortcut == 2){
- setClipboard();
- } else if((a == 67) && (event.ctrlKey) && userSetting.shortcut == 3){
- setClipboard();
- }else {
- console.log("关闭了快捷键");
- }
- }
- document.onkeydown = hotkey; //当onkeydown 事件发生时调用hotkey函数
-
- // 部分网站采用了其他的防复制手段
- function clear(){
- // console.log("进入clear",hostname,rwl_userData.rules);
- switch (hostname){
- case "chuangshi.qq.com": clear_chuangshi();break;
- case "votetw.com": clear_votetw();break;
- case "www.myhtebooks.com": clear_covers(".fullimg");break;
- case "www.z3z4.com": clear_covers(".moviedownaddiv"); break;
- case "huayu.baidu.com": clear_covers("#jqContextMenu"); break;
- case "www.myhtlmebook.com": clear_covers("img.fullimg"); break;
- case "zhihu.com":
- case "www.zhihu.com": return rwl_userData.rules.rule_zhihu; break;
- case "t.bilibili.com": clear_link_bilibili(); break;
- case "www.uslsoftware.com": clear_covers(".protect_contents-overlay");clear_covers(".protect_alert"); return rwl_userData.rules.rule_plus; break;
- case "www.longmabookcn.com": clear_covers(".fullimg"); return rwl_userData.rules.rule_plus; break;
- case "boke112.com": return rwl_userData.rules.rule_plus; break;
- case "www.shangc.net": return rwl_userData.rules.rule_plus; break;
- }
- return rwl_userData.rules.rule_def;
- }
- // 去除覆盖层
- function clear_covers(ele){
- var odiv = document.querySelector(ele);
- if(odiv){
- odiv.parentNode.removeChild(odiv);
- }
- }
- // b站将文字嵌套在链接中
- function clear_link_bilibili(){
- var odiv = document.querySelector(".description");
- if(odiv){
- var tDiv = odiv.querySelector(".content-ellipsis");
- var aDiv = odiv.querySelector("a");
- odiv.appendChild(tDiv);
- }
- }
- // https://votetw.com/wiki/%E6%9E%97%E6%99%BA%E5%A0%85
- // 会创建多个无id,无class的div,覆盖在文字上层
- function clear_votetw(){
- var odivs = document.querySelectorAll(".mw-parser-output>div")
- odivs.forEach(function(value){
- value.setAttribute("style","");
- })
- }
-
- // 创世中文网
- function clear_chuangshi(){
- console.log("创世中文网 开始执行");
-
- // JS 汉字与Unicode码的相互转化
- // https://www.cnblogs.com/wwlhome/p/5650744.html
- function tounicode(data)
- {
- if(data == '') return '请输入汉字';
- var str ='';
- for(var i=0;iscreenClientHeight){
+ tempHeight = screenClientHeight -40;
+ } else{
+ tempHeight = rwl_userData.positionTop;
+ }
+ // 改变窗口大小的情况
+ window.onresize=function(){
+ var screenClientHeight = document.documentElement.clientHeight;
+ var tempHeight;
+
+ if (rwl_userData.positionTop>screenClientHeight){
+ tempHeight = screenClientHeight -40;
+ } else{
+ tempHeight = rwl_userData.positionTop;
+ }
+
+ node.style.top = tempHeight + "px";
+ }
+
+ tempHeight = tempHeight<0?0:tempHeight
+ node.style.cssText = "position:fixed;top:"+tempHeight+"px;left:"+rwl_userData.positionLeft+"px;right:"+rwl_userData.positionRight+"px;";
+ // node.innerHTML = 'delete';
+ // node.innerHTML = '';
+ node.innerHTML = ' set 限制解除 ';
+ if(window.self === window.top){
+ if (document.querySelector("body")){
+ document.body.appendChild(node);
+ } else {
+ document.documentElement.appendChild(node);
+ }
+ }
+ node.addEventListener("mouseover",function(){
+ node.classList.add("rwl-active-iqxin");
+ });
+ node.addEventListener("mouseleave",function(){
+ setTimeout(function(){
+ node.classList.remove("rwl-active-iqxin");
+ black_check(black_node.checked);
+ },100)
+ });
+
+ var style = document.createElement("style");
+ style.type="text/css";
+
+ var styleInner = "#rwl-iqxin{" +
+ "position:fixed;" +
+ "transform:translate(-95px,0);" +
+ "width:85px;" +
+ "height:25px;" +
+ "font-size:12px;" +
+ "font-weight: 500;" +
+ "font-family:Verdana, Arial, '宋体';" +
+ "color:#fff;" +
+ "background:#333;" +
+ "z-index:2147483647;" +
+ "margin: 0;" +
+ "opacity:0.05;" +
+ "transition:0.3s;" +
+ "overflow:hidden;" +
+ "user-select:none;" +
+ "text-align:center;" +
+ "white-space:nowrap;" +
+ "line-height:25px;" +
+ "padding:0 16px;" +
+ "border:1px solid #ccc;" +
+ "border-width:1px 1px 1px 0;" +
+ "border-bottom-right-radius:5px;" +
+ "box-sizing: content-box;" +
+ "}" +
+ "#rwl-iqxin input{" +
+ "margin: 0;" +
+ "padding: 0;" +
+ "vertical-align:middle;" +
+ "-webkit-appearance:checkbox;" +
+ "-moz-appearance:checkbox;" +
+ "position: static;" +
+ "clip: auto;" +
+ "opacity: 1;" +
+ "cursor: pointer;" +
+ "}" +
+ "#rwl-iqxin.rwl-active-iqxin{" +
+ "left: 0px;" +
+ "transform:translate(0,0);" +
+ "opacity: 0.9;" +
+ "height: 32px;" +
+ "line-height: 32px" +
+ "}" +
+ "#rwl-iqxin label{" +
+ "margin:0;" +
+ "padding:0;" +
+ "font-weight:500;" +
+ "}" +
+ "#rwl-iqxin #rwl-setbtn{" +
+ "margin: 0 4px 0 0;" +
+ "padding: 0 0 0 4px;" +
+ "border: none;" +
+ "border-radius: 2px;" +
+ "cursor: pointer;" +
+ "background: #fff;" +
+ "color: #000;" +
+ "}" +
+ " "
+
+ if(!rwl_userData.addBtn){
+ var styleTemp = "#rwl-iqxin{display:none}";
+ style.innerHTML = styleInner + styleTemp;
+ } else {
+ style.innerHTML = styleInner;
+ }
+ if(document.querySelector("#rwl-iqxin")){
+ // console.log("通过style插入");
+ document.querySelector("#rwl-iqxin").appendChild(style);
+ } else {
+ // console.log("通过GM插入");
+ GM_addStyle(styleInner);
+ }
+ };
+
+ // 给按钮绑定点击事件
+ function setBtnClick(){
+ document.querySelector("#rwl-setbtn").addEventListener("click",setMenu);
+ }
+
+ // 菜单
+ function setMenu(){
+ var oldEditBox = document.querySelector("#rwl-setMenu");
+ if(oldEditBox){
+ oldEditBox.parentNode.removeChild(oldEditBox);
+ return;
+ }
+ var userSetting = GM_getValue("rwl_userData");
+ var upload_checked = userSetting.connectToTheServer?"checked":"";
+ var btnchecked = userSetting.addBtn?'checked':''
+
+ var odom = document.createElement("div");
+ odom.id = "rwl-setMenu";
+ odom.style.cssText ="position: fixed;" +
+ "top: 100px;" +
+ "left: 50px;" +
+ "padding: 10px;" +
+ "background: #fff;" +
+ "border-radius: 4px;";
+ GM_addStyle("#rwl-setMenuSave," +
+ "#rwl-reset," +
+ "#rwl-setMenuClose{" +
+ "margin: 0;" +
+ "padding: 0 2px;" +
+ "border: none;" +
+ "border-radius: 2px;" +
+ "cursor: pointer;" +
+ "background: #fff;" +
+ "color: #000;" +
+ "}" +
+ "#rwl-reset{" +
+ "border: 1px solid #666;" +
+ "}" +
+ "#rwl-setMenuSave{" +
+ "border: 1px solid green;" +
+ "}" +
+ "#rwl-setMenuClose{" +
+ "border: 1px solid red;" +
+ "}" +
+ "#rwl-setMenu{" +
+ "text-align:left;" +
+ "font-size:14px;" +
+ "z-index:999999;" +
+ "border: 1px solid cornflowerblue;" +
+ "}" +
+ "#rwl-setMenu p{" +
+ "margin:5px auto;" +
+ "}" +
+ " ")
+ var innerH = "" +
+ "距离顶部距离(单位 像素)
" + "" +
+ // " 允许上传黑名单
" + "" +
+ "快捷键:" +
+ "" +
+ "
" +
+ " 显示按钮 点击脚本管理扩展可以再次打开设置
" + "" +
+ "问题反馈地址: GitHub(qxin), GreasyFork(qxin)
" +
+ "项目原作者为 cat7373, 项目主页
" +
+ "能力有限,不能每个网站都能完美
" +
+ "如若反馈,务必带上详细网址
" +
+ "
" +
+ // "显示按钮(待添加)
" +
+ // "按钮透明度(待添加)
" +
+ // "快速复制(待添加)
" +
+ // "其他 (待添加)
" +
+ "数据存储方式为JSON,如若在此修改,注意引号逗号
" +
+ "" +
+ "
" +
+ "清空设置 " +
+ " " +
+ " " +
+ "--| qxin v4.4.5 2021-03-19 |--" +
+ ""
+ "";
+ odom.innerHTML = innerH;
+ document.body.appendChild(odom);
+
+ document.querySelector("#rwl-setMenuSave").addEventListener("click",saveSetting);
+ document.querySelector("#rwl-setMenuClose").addEventListener("click",closeMenu);
+ document.querySelector("#rwl-reset").addEventListener("click",rwlReset);
+
+ }
+
+ // 保存选项
+ function saveSetting(){
+ var positionTop = document.querySelector("#rwl-setMenu #positiontop").value;
+ // var uploadChecked = document.querySelector("#rwl-setMenu #uploadchecked").checked;
+ var shortcut = document.querySelector("#rwl-setMenu #rwl-shortcut").selectedIndex;
+ var addBtnChecked = document.querySelector("#rwl-setMenu #btnchecked").checked;
+ var codevalue = document.querySelector("#rwl-setMenu textarea").value;
+ if(codevalue){
+ var userSetting = GM_getValue("rwl_userData");
+
+ userSetting.addBtn = addBtnChecked;
+ userSetting.data = JSON.parse(codevalue);
+ userSetting.positionTop = parseInt(positionTop);
+ userSetting.shortcut = parseInt(shortcut);
+ // userSetting.connectToTheServer = uploadChecked;
+
+ GM_setValue("rwl_userData",userSetting);
+ // 刷新页面
+ setTimeout(function(){
+ window.location.reload();
+ },300);
+ } else {
+ alert("输入为空");
+ // this.reset();
+ }
+ closeMenu();
+ }
+ // 复原菜单
+ function rwlReset(){
+ GM_deleteValue("rwl_userData");
+ window.location.reload();
+ }
+
+ //关闭菜单
+ function closeMenu(){
+ var oldEditBox = document.querySelector("#rwl-setMenu");
+ if(oldEditBox){
+ oldEditBox.parentNode.removeChild(oldEditBox);
+ return;
+ }
+ }
+
+ // 增加拖拽事件 进行绑定
+ function addDragEven(){
+ setTimeout(function(){
+ try {
+ dragBtn()
+ } catch (e) {
+ console.error("dragBtn函数 报错");
+ }
+ },1000)
+ // dragBtn(); // 增加拖动事件
+ }
+
+ // 增加拖动事件 func
+ function dragBtn(){
+ var rwl_node = document.querySelector("#rwl-iqxin");
+ rwl_node.addEventListener("mousedown",function(event){
+ rwl_node.style.transition = "null";
+ var disX = event.clientX - rwl_node.offsetLeft;
+ var disY = event.clientY - rwl_node.offsetTop;
+
+ var move = function(event){
+ rwl_node.style.left = event.clientX - disX + "px" ;
+ rwl_node.style.top = event.clientY - disY + "px" ;
+ }
+
+ document.addEventListener("mousemove",move);
+ document.addEventListener("mouseup",function(){
+ rwl_node.style.transition = "0.3s";
+ document.removeEventListener("mousemove",move);
+ // 此函数内所有的注释语句都是有用的
+ // 开启后,可拖动到屏幕右侧,但尚未添加css
+ // 在上面添加 rwl-active-iqxin 的地方加上判断左右,在加上相应的css即可
+ // 懒 2018-04-18 21:51:32
+ // var bodyWidth = document.body.clientWidth;
+ var rwl_nodeWidth = rwl_node.offsetLeft + rwl_node.offsetWidth/2;
+ // if(rwl_nodeWidth > bodyWidth/2){
+ // rwl_node.style.left = "auto";
+ // rwl_node.style.right = 0;
+ // rwl_userData.positionLeft = "auto";
+ // rwl_userData.positionRight = "0";
+ // } else {
+ rwl_node.style.right = rwl_userData.positionRight = "auto";
+ rwl_node.style.left = rwl_userData.positionLeft = 0;
+ // }
+ rwl_userData.positionTop = rwl_node.offsetTop;
+ GM_setValue("rwl_userData",rwl_userData);
+
+ })
+ })
+ }
+
+ // 初始化 init func 这里才是核心
+ function init() {
+ // 针对个别网站采取不同的策略
+ rule = clear();
+ // 设置 event 列表
+ hook_eventNames = rule.hook_eventNames.split("|");
+ // TODO Allowed to return value
+ unhook_eventNames = rule.unhook_eventNames.split("|");
+ eventNames = hook_eventNames.concat(unhook_eventNames);
+
+ // 调用清理 DOM0 event 方法的循环
+ if(rule.dom0) {
+ setInterval(clearLoop, 10 * 1000);
+ setTimeout(clearLoop, 1500);
+ window.addEventListener('load', clearLoop, true);
+ clearLoop();
+ }
+
+ // hook addEventListener //导致搜索跳转失效的原因
+ if(rule.hook_addEventListener) {
+ EventTarget.prototype.addEventListener = addEventListener;
+ document.addEventListener = addEventListener;
+
+ if(hasFrame){
+ for(let i = 0;i= 0) {
+ this.returnValue = true;
+ }
+ });
+ }
+
+ // 添加CSS // console.debug('url: ' + url, 'storageName:' + storageName, 'rule: ' + rule.name);
+ if(rule.add_css) {
+ GM_addStyle('html, :not([class*="rwl-exempt"]) {-webkit-user-select:text!important; -moz-user-select:text!important;} :not([class*="rwl-exempt"]) ::selection {color:#fff; background:#3390FF!important;}');
+ } //else {
+ //GM_addStyle('html, :not([class*="rwl-exempt"]) {-webkit-user-select:text!important; -moz-user-select:text!important;}');
+ //}
+ }
+
+ // Hook addEventListener proc
+ function addEventListener(type, func, useCapture) {
+ var _addEventListener = this === document ? document_addEventListener : EventTarget_addEventListener;
+ if(hook_eventNames.indexOf(type) >= 0) {
+ _addEventListener.apply(this, [type, returnTrue, useCapture]);
+ } else if(unhook_eventNames.indexOf(type) >= 0) {
+ var funcsName = storageName + type + (useCapture ? 't' : 'f');
+
+ if(this[funcsName] === undefined) {
+ this[funcsName] = [];
+ _addEventListener.apply(this, [type, useCapture ? unhook_t : unhook_f, useCapture]);
+ }
+
+ this[funcsName].push(func);
+ } else {
+ _addEventListener.apply(this, arguments);
+ }
+ }
+
+ // 清理循环
+ function clearLoop() {
+ rule = clear() // 对于动态生成的节点,随时检测
+ var elements = getElements();
+
+ for(var i in elements) {
+ for(var j in eventNames) {
+ var name = 'on' + eventNames[j];
+
+ // ;?未解决
+ // 2018-04-02 elements中会有字符串出现,原版不会,问题不明,根本原因尚未解决
+ // 相关反馈 https://greasyfork.org/zh-CN/forum/discussion/36014
+ // 问题版本号 v3.0.7
+ // 问题补充 之前可以使用,具体版本未测(2018-04-02 21:27:53),原版可以使用
+ if(Object.prototype.toString.call(elements[i])=="[object String]"){
+ continue;
+ }
+
+ // console.log(elements[i])
+ // if(typeof elements[i][name] === "object"){
+ // console.log(typeof elements[i][name])
+ // }
+ if(elements[i][name] !== null && elements[i][name] !== onxxx) {
+ if(unhook_eventNames.indexOf(eventNames[j]) >= 0) {
+ elements[i][storageName + name] = elements[i][name];
+ elements[i][name] = onxxx;
+ } else {
+ elements[i][name] = null;
+ }
+ }
+ }
+ }
+
+ document.onmousedown = function(){return true;};
+ }
+
+ // 返回true的函数
+ function returnTrue(e) {
+ return true;
+ }
+ function unhook_t(e) {
+ return unhook(e, this, storageName + e.type + 't');
+ }
+ function unhook_f(e) {
+ return unhook(e, this, storageName + e.type + 'f');
+ }
+ function unhook(e, self, funcsName) {
+ var list = self[funcsName];
+ for(var i in list) {
+ list[i](e);
+ }
+
+ e.returnValue = true;
+ return true;
+ }
+ function onxxx(e) {
+ var name = storageName + 'on' + e.type;
+ this[name](e);
+
+ e.returnValue = true;
+ return true;
+ }
+
+ // 获取所有元素 包括document
+ function getElements() {
+ var elements = Array.prototype.slice.call(document.getElementsByTagName('*'));
+ elements.push(document);
+
+ // 循环所有 frame 窗口
+ var frames = document.querySelectorAll("frame")
+ if(frames){
+ hasFrame = frames;
+ var frames_element;
+ for (let i = 0;i1;
+ })
+ return data_temp;
+ }
+
+ // 检查是否存在于黑名单中 返回位置 func
+ function check_black_list(list,host){
+ for(let i=0;i1;
+ })
+
+ // 更新数据
+ rwl_userData.data = lists.sort();
+
+ // 将本地黑名单上传
+ // if (rwl_userData.waitUpload.length > 0 && rwl_userData.connectToTheServer){
+ // // console.log("rwl : 上传...",rwl_userData.waitUpload);
+ // // console.log("rwl : 开始上传-----");
+ // GM_xmlhttpRequest({
+ // method: "POST",
+ // // url: "http://127.0.0.1:8000/tool/testajax/",
+ // url: "http://eemm.me/tool/rwl_upload/",
+ // data: JSON.stringify(rwl_userData),
+ // headers: {
+ // "Content-Type": "application/x-www-form-urlencoded"
+ // },
+ // onload: function(response) {
+ // // console.log("rwl : 上传成功----");
+ // }
+ // });
+ // rwl_userData.waitUpload = [];
+ // }
+
+ GM_setValue("rwl_userData",rwl_userData);
+ return rwl_userData;
+ }
+
+ // 数组去重
+ function unique(arr) {
+ var ret = []
+ for (var i = 0; i < arr.length; i++) {
+ var item = arr[i]
+ if (ret.indexOf(item) === -1) {
+ ret.push(item)
+ }
+ }
+ return ret;
+ }
+
+ // 复制到剪贴板
+ function setClipboard(){
+ var text_obj = window.getSelection();
+ var text = text_obj.toString();
+ GM_setClipboard(text);
+
+ }
+
+ // 快捷键 F1(ctrl+f1) 复制
+ function hotkey() {
+ var a = window.event.keyCode;
+ // if ((a == 112) && (event.ctrlKey)) {
+ if (a == 112 && userSetting.shortcut == 1) {
+ event.preventDefault();
+ setClipboard();
+ event.keyCode=0;
+ event.returnValue=false;
+ return false;
+ } else if (a == 112 && (event.ctrlKey) && userSetting.shortcut == 2){
+ setClipboard();
+ } else if((a == 67) && (event.ctrlKey) && userSetting.shortcut == 3){
+ setClipboard();
+ }else {
+ console.log("关闭了快捷键");
+ }
+ }
+ document.onkeydown = hotkey; //当onkeydown 事件发生时调用hotkey函数
+
+ // 部分网站采用了其他的防复制手段
+
+ //删除:百度文库选中后的弹窗
+ //我直接把div文件删了
+ function removeWenkuBaidu(){
+ var paras =document.getElementsByClassName("tips-wrap");
+ while(paras[0]) {
+ paras[0].parentNode.removeChild(paras[0]);
+ }
+ }
+
+ //删除文字选中类的弹窗,待添加
+ function removeExtraBars(){
+ console.log("here");
+ console.log(hostname);
+ if (hostname.indexOf("wenku.baidu") != -1)
+ removeWenkuBaidu();
+ }
+
+
+
+ function clear(){
+ removeExtraBars();
+ // console.log("进入clear",hostname,rwl_userData.rules);
+ switch (hostname){
+ case "chuangshi.qq.com": clear_chuangshi();break;
+ case "votetw.com": clear_votetw();break;
+ case "www.myhtebooks.com": clear_covers(".fullimg");break;
+ case "www.z3z4.com": clear_covers(".moviedownaddiv"); break;
+ case "huayu.baidu.com": clear_covers("#jqContextMenu"); break;
+ case "www.myhtlmebook.com": clear_covers("img.fullimg"); break;
+ case "zhihu.com":
+ case "www.zhihu.com": return rwl_userData.rules.rule_zhihu; break;
+ case "t.bilibili.com": clear_link_bilibili(); break;
+ case "www.uslsoftware.com": clear_covers(".protect_contents-overlay");clear_covers(".protect_alert"); return rwl_userData.rules.rule_plus; break;
+ case "www.longmabookcn.com": clear_covers(".fullimg"); return rwl_userData.rules.rule_plus; break;
+ case "boke112.com": return rwl_userData.rules.rule_plus; break;
+ case "www.shangc.net": return rwl_userData.rules.rule_plus; break;
+ }
+ return rwl_userData.rules.rule_def;
+ }
+ // 去除覆盖层
+ function clear_covers(ele){
+ var odiv = document.querySelector(ele);
+ if(odiv){
+ odiv.parentNode.removeChild(odiv);
+ }
+ }
+ // b站将文字嵌套在链接中
+ function clear_link_bilibili(){
+ var odiv = document.querySelector(".description");
+ if(odiv){
+ var tDiv = odiv.querySelector(".content-ellipsis");
+ var aDiv = odiv.querySelector("a");
+ odiv.appendChild(tDiv);
+ }
+ }
+ // https://votetw.com/wiki/%E6%9E%97%E6%99%BA%E5%A0%85
+ // 会创建多个无id,无class的div,覆盖在文字上层
+ function clear_votetw(){
+ var odivs = document.querySelectorAll(".mw-parser-output>div")
+ odivs.forEach(function(value){
+ value.setAttribute("style","");
+ })
+ }
+
+ // 创世中文网
+ function clear_chuangshi(){
+ console.log("创世中文网 开始执行");
+
+ // JS 汉字与Unicode码的相互转化
+ // https://www.cnblogs.com/wwlhome/p/5650744.html
+ function tounicode(data)
+ {
+ if(data == '') return '请输入汉字';
+ var str ='';
+ for(var i=0;i