网页限制解除(改)

通杀大部分网站,可以解除禁止复制、剪切、选择文本、右键菜单的限制。原作者cat73,因为和搜索跳转脚本冲突,遂进行了改动。

  1. // ==UserScript==
  2. // @namespace https://gf.qytechs.cn/zh-CN/users/106222-qxin-i
  3. // @name 网页限制解除(改)
  4. // @name:en Remove web limits(modified)
  5. // @name:zh 网页限制解除(改)
  6. // @name:ja ウェブの規制緩和(変更)
  7. // @author Cat73 & iqxin(修改)
  8. // @contributor iqxin
  9. // @description 通杀大部分网站,可以解除禁止复制、剪切、选择文本、右键菜单的限制。原作者cat73,因为和搜索跳转脚本冲突,遂进行了改动。
  10. // @description:en Pass to kill most of the site, you can lift the restrictions prohibited to copy, cut, select the text, right-click menu.revised version
  11. // @description:zh 通杀大部分网站,可以解除禁止复制、剪切、选择文本、右键菜单的限制。原作者cat73,因为和搜索跳转脚本冲突,遂进行了改动
  12. // @description:zh-TW 通殺大部分網站,可以解除禁止復制、剪切、選擇文本、右鍵菜單的限制。
  13. // @description:ja サイトのほとんどを殺すために渡し、あなたは、コピー切り取り、テキスト、右クリックメニューを選択することは禁止の制限を解除することができます。
  14. // @description 原作者https://www.github.com/Cat7373/,因为和搜索跳转脚本冲突,遂进行了改动
  15. // @homepageURL https://cat7373.github.io/remove-web-limits/
  16. // @supportURL https://gf.qytechs.cn/zh-CN/scripts/28497
  17. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAABpElEQVR4nO3Vv2uUQRDG8c/ebSMWqay0trATAxrUSi1S2AiWFoJYpNCgoBjURsHWJKeNRfAvsDgFixQqKdPZ2ViEiCJYBOQu8f1hEXO59713j7MUfLZ6d2a/O8vMO0OzDnin9Ku2Mjvuaw07xgSAYEVXe2indMhj92zpKJLnBhF8MDeye9hn6zbN70eRiqCw02Bra3up8BBLu1FEBxsBucXqW4csz0ULe4jorSCMuPU89boRELDMHiI6Y8V65bbCUTccc70RkaOwKLOg0IkyXa9qTjOu2LAs6NZuD86hrdTyxRNTkUqqdhXlHrngGRVEZsMpJwex9DxIZSHYclesIb65LCoHgIs66UJq6btDBZHZrPh8V6YBOX66LbOkTGckBYimBW2FVTNeuOZNyrFJ236Yl4NSy5SbVm1PDvhodqgyMledTdRlAtDzqfL9tfkwUtyaRkv9LwFj9B/w7wPycXOhqlJ0yZHKPChMi5MCiM47XhsopbVJAUHfrYbmN/EToN+02eLPfz9OYyZhFJzW1Jn3lTsxaKQjCkp52jy45r1ZvSbTb9M0d4PBozGZAAAAAElFTkSuQmCC
  18. // @version 4.4.8
  19. // @license LGPLv3
  20. // @match *://*/*
  21. // @exclude *www.bilibili.com/video*
  22. // @exclude *www.bilibili.com/v*
  23. // @exclude *www.bilibili.com/s/*
  24. // @exclude *www.bilibili.com/bangumi*
  25. // @exclude https://www.bilibili.com/medialist/play/*
  26. // @exclude *www.youtube.com/watch*
  27. // @exclude *www.panda.tv*
  28. // @exclude *www.github.com*
  29. // @exclude https://lanhuapp.com/*
  30. // @exclude https://www.douyu.com/*
  31. // @exclude https://www.zhihu.com/signin?*
  32. // @exclude https://tieba.baidu.com/*
  33. // @exclude https://v.qq.com/*
  34. // @exclude *.taobao.com/*
  35. // @exclude *tmall.com*
  36. // @exclude *signin*
  37. // @connect eemm.me
  38. // @grant GM_getValue
  39. // @grant GM_setValue
  40. // @grant GM_addStyle
  41. // @grant GM_deleteValue
  42. // @grant GM_xmlhttpRequest
  43. // @grant GM_setClipboard
  44. // @grant GM_registerMenuCommand
  45. // @run-at document-start
  46. // ==/UserScript==
  47. (function() {
  48. 'use strict';
  49. var settingData = {
  50. "status":1,
  51. "version" : 0.1,
  52. "message" : "啦啦啦,啦啦啦,我是卖报的小行家",
  53. "positionTop":"0",
  54. "positionLeft":"0",
  55. "positionRight":"auto",
  56. "addBtn" : true,
  57. "connectToTheServer" : false,
  58. "waitUpload":[],
  59. "currentURL":"null",
  60. "shortcut":3,
  61. // 域名规则列表
  62. "rules" : {
  63. "rule_def": {
  64. "name": "default",
  65. "hook_eventNames": "contextmenu|select|selectstart|copy|cut|dragstart|mousemove|beforeunload",
  66. "unhook_eventNames": "mousedown|mouseup|keydown|keyup",
  67. "dom0": true,
  68. "hook_addEventListener": true,
  69. "hook_preventDefault": true,
  70. "hook_set_returnValue": true,
  71. "add_css": true
  72. },
  73. "rule_plus": {
  74. "name": "default",
  75. "hook_eventNames": "contextmenu|select|selectstart|copy|cut|dragstart|mousedown|mouseup|mousemove|beforeunload",
  76. "unhook_eventNames": "keydown|keyup",
  77. "dom0": true,
  78. "hook_addEventListener": true,
  79. "hook_preventDefault": true,
  80. "hook_set_returnValue": true,
  81. "add_css": true
  82. },
  83. "rule_zhihu": {
  84. "name": "default",
  85. "hook_eventNames": "contextmenu|select|selectstart|copy|cut|dragstart|mousemove",
  86. "unhook_eventNames": "keydown|keyup",
  87. "dom0": true,
  88. "hook_addEventListener": true,
  89. "hook_preventDefault": true,
  90. "hook_set_returnValue": true,
  91. "add_css": true
  92. }
  93. },
  94. "data": [
  95. "b.faloo.com",
  96. "bbs.coocaa.com",
  97. "book.hjsm.tom.com",
  98. "book.zhulang.com",
  99. "book.zongheng.com",
  100. "chokstick.com",
  101. "chuangshi.qq.com",
  102. "city.udn.com",
  103. "cutelisa55.pixnet.net",
  104. "huayu.baidu.com",
  105. "imac.hk",
  106. "life.tw",
  107. "luxmuscles.com",
  108. "news.missevan.com",
  109. "read.qidian.com",
  110. "www.15yan.com",
  111. "www.17k.com",
  112. "www.18183.com",
  113. "www.360doc.com",
  114. "www.coco01.net",
  115. "www.eyu.com",
  116. "www.hongshu.com",
  117. "www.hongxiu.com",
  118. "www.imooc.com",
  119. "www.jjwxc.net",
  120. "www.readnovel.com",
  121. "www.tadu.com",
  122. "www.xxsy.net",
  123. "www.z3z4.com",
  124. "www.zhihu.com",
  125. "yuedu.163.com",
  126. "www.ppkao.com",
  127. "movie.douban.com",
  128. "www.ruiwen.com",
  129. "vipreader.qidian.com",
  130. "www.pigai.org",
  131. "www.shangc.net",
  132. "www.myhtlmebook.com",
  133. "www.yuque.com",
  134. "www.longmabookcn.com",
  135. "www.alphapolis.co.jp",
  136. "www.sdifen.com",
  137. "votetw.com",
  138. "boke112.com",
  139. "www.myhtebooks.com",
  140. "www.xiegw.cn",
  141. "chuangshi.qq.com",
  142. "www.uta-net.com",
  143. "www.bimiacg.net",
  144. "www.dianyuan.com",
  145. "origenapellido.com",
  146. "3g.163.com",
  147. "www.lu-xu.com",
  148. "leetcode.cn",
  149. "www.jianbiaoku.com",
  150. "www.soyoung.com",
  151. "doc.guandang.net",
  152. "www.51dongshi.com",
  153. "m.haodf.com",
  154. "www.daodoc.com",
  155. "www.wcqjyw.com",
  156. "www.szxx.com.cn",
  157. ]
  158. }
  159. var rwl_userData = null;
  160. var hostname = window.location.hostname;
  161. var btn_node = null;
  162. var rule = null;
  163. var list = null;
  164. var hasFrame = false;
  165. // 储存名称
  166. var storageName = "iqxinStorageName";
  167. // 要处理的 event 列表
  168. var hook_eventNames, unhook_eventNames, eventNames;
  169. // 储存被 Hook 的函数
  170. var EventTarget_addEventListener = EventTarget.prototype.addEventListener;
  171. var document_addEventListener = document.addEventListener;
  172. var Event_preventDefault = Event.prototype.preventDefault;
  173. // 查看本地是否存在旧数据
  174. rwl_userData = GM_getValue("rwl_userData");
  175. if(!rwl_userData){
  176. rwl_userData = settingData
  177. // GM_setValue("rwl_userData",rwl_userData);
  178. }
  179. // 自动更新数据
  180. for(let value in settingData){
  181. if(!rwl_userData.hasOwnProperty(value)){
  182. rwl_userData[value] = settingData[value];
  183. GM_setValue("rwl_userData",rwl_userData);
  184. }
  185. }
  186. version_up_3_to_4();
  187. // 获取黑名单网站
  188. list = get_black_list();
  189. // 添加按钮
  190. // if(rwl_userData.addBtn){
  191. addBtn(); // 添加
  192. btn_node = document.getElementById("black_node");
  193. var timer = setInterval(function(){
  194. if(document.getElementById("black_node")){
  195. clearInterval(timer);
  196. qxinStart();
  197. } else {
  198. addBtn();
  199. }
  200. },500)
  201. // }
  202. GM_registerMenuCommand("复制限制解除 设置", setMenu)
  203. var userSetting = GM_getValue("rwl_userData");
  204. // // ------------------------------函数 func
  205. function qxinStart(){
  206. console.log("脚本: 复制限制解除(改) --- 开始执行 --- 发布者: qxin --- GitHub: https://github.com/qxinGitHub/Remove-web-limits-");
  207. addDragEven();
  208. setBtnClick();
  209. // 检查是否在黑名单中
  210. if(check_black_list(list,hostname)){
  211. try {
  212. if(rwl_userData.addBtn){
  213. btn_node.checked = true;
  214. }
  215. } catch (e) {
  216. console.error("脚本rwl-错误:\n btn_node : %s\n%s\n脚本rwl-错误位置: btn_node.checked = true;",btn_node,e);
  217. } finally {
  218. init();
  219. }
  220. }
  221. }
  222. //添加按钮 func
  223. function addBtn(){
  224. var node = document.createElement("remove-web-limits-iqxin");
  225. node.id = "rwl-iqxin";
  226. node.className = "rwl-exempt";
  227. // 再次打开窗口小于之前窗口的情况,导致按钮出现在可视窗口之外
  228. var screenClientHeight = document.documentElement.clientHeight;
  229. var tempHeight;
  230. if (rwl_userData.positionTop>screenClientHeight){
  231. tempHeight = screenClientHeight -40;
  232. } else{
  233. tempHeight = rwl_userData.positionTop;
  234. }
  235. // 改变窗口大小的情况
  236. window.onresize=function(){
  237. var screenClientHeight = document.documentElement.clientHeight;
  238. var tempHeight;
  239. if (rwl_userData.positionTop>screenClientHeight){
  240. tempHeight = screenClientHeight -40;
  241. } else{
  242. tempHeight = rwl_userData.positionTop;
  243. }
  244. node.style.top = tempHeight + "px";
  245. }
  246. tempHeight = tempHeight<0?0:tempHeight
  247. node.style.cssText = "position:fixed;top:"+tempHeight+"px;left:"+rwl_userData.positionLeft+"px;right:"+rwl_userData.positionRight+"px;";
  248. // node.innerHTML = '<label><input type="checkbox" name="" id="black_node">黑名单</label><qxinbutton id="delete">delete</btton>';
  249. // node.innerHTML = '<label>限制解除 <input type="checkbox" name="" id="black_node"></label>';
  250. node.innerHTML = '<qxinbutton type="qxinbutton" id="rwl-setbtn"> set </qxinbutton> <lalala style="cursor:move; font-size:12px;">限制解除</lalala> <input type="checkbox" name="" id="black_node" >';
  251. if(window.self === window.top){
  252. if (document.querySelector("body")){
  253. document.body.appendChild(node);
  254. } else {
  255. document.documentElement.appendChild(node);
  256. }
  257. }
  258. node.addEventListener("mouseover",function(){
  259. node.classList.add("rwl-active-iqxin");
  260. });
  261. node.addEventListener("mouseleave",function(){
  262. setTimeout(function(){
  263. node.classList.remove("rwl-active-iqxin");
  264. black_check(black_node.checked);
  265. },100)
  266. });
  267. var style = document.createElement("style");
  268. style.type="text/css";
  269. var styleInner = "#rwl-iqxin{" +
  270. "position:fixed;" +
  271. "transform:translate(-95%,0);" +
  272. "width:85px;" +
  273. "height:25px;" +
  274. "font-size:12px;" +
  275. "font-weight: 500;" +
  276. "font-family:Verdana, Arial, '宋体';" +
  277. "color:#fff;" +
  278. "background:#333;" +
  279. "z-index:2147483647;" +
  280. "margin: 0;" +
  281. "opacity:0.05;" +
  282. "transition:0.3s;" +
  283. "overflow:hidden;" +
  284. "user-select:none;" +
  285. "text-align:center;" +
  286. "white-space:nowrap;" +
  287. "line-height:25px;" +
  288. "padding:0 16px;" +
  289. "border:1px solid #ccc;" +
  290. "border-width:1px 1px 1px 0;" +
  291. "border-bottom-right-radius:5px;" +
  292. "box-sizing: content-box;" +
  293. "}" +
  294. "#rwl-iqxin input{" +
  295. "margin: 0;" +
  296. "padding: 0;" +
  297. "vertical-align:middle;" +
  298. "-webkit-appearance:checkbox !important;" +
  299. "-moz-appearance:checkbox;" +
  300. "position: static;" +
  301. "clip: auto;" +
  302. "opacity: 1;" +
  303. "cursor: pointer;" +
  304. "}" +
  305. "#rwl-iqxin.rwl-active-iqxin{" +
  306. "left: 0px;" +
  307. "transform:translate(0,0);" +
  308. "opacity: 0.9;" +
  309. "height: 32px;" +
  310. "line-height: 32px" +
  311. "}" +
  312. "#rwl-iqxin label{" +
  313. "margin:0;" +
  314. "padding:0;" +
  315. "font-weight:500;" +
  316. "}" +
  317. "#rwl-iqxin #rwl-setbtn{" +
  318. "margin: 0 4px 0 0;" +
  319. "padding: 0 0 0 4px;" +
  320. "border: none;" +
  321. "border-radius: 2px;" +
  322. "cursor: pointer;" +
  323. "background: #fff;" +
  324. "color: #000;" +
  325. "}" +
  326. " "
  327. if(!rwl_userData.addBtn){
  328. var styleTemp = "#rwl-iqxin{display:none}";
  329. style.innerHTML = styleInner + styleTemp;
  330. } else {
  331. style.innerHTML = styleInner;
  332. }
  333. if(document.querySelector("#rwl-iqxin")){
  334. // console.log("通过style插入");
  335. document.querySelector("#rwl-iqxin").appendChild(style);
  336. } else {
  337. // console.log("通过GM插入");
  338. GM_addStyle(styleInner);
  339. }
  340. };
  341. // 给按钮绑定点击事件
  342. function setBtnClick(){
  343. document.querySelector("#rwl-setbtn").addEventListener("click",setMenu);
  344. }
  345. // 菜单
  346. function setMenu(){
  347. var oldEditBox = document.querySelector("#rwl-setMenu");
  348. if(oldEditBox){
  349. oldEditBox.parentNode.removeChild(oldEditBox);
  350. return;
  351. }
  352. var userSetting = GM_getValue("rwl_userData");
  353. var upload_checked = userSetting.connectToTheServer?"checked":"";
  354. var btnchecked = userSetting.addBtn?'checked':''
  355. var odom = document.createElement("div");
  356. odom.id = "rwl-setMenu";
  357. odom.style.cssText ="position: fixed;" +
  358. "top: 100px;" +
  359. "left: 50px;" +
  360. "padding: 10px;" +
  361. "background: #fff;" +
  362. "border-radius: 4px;";
  363. GM_addStyle("#rwl-setMenuSave," +
  364. "#rwl-reset," +
  365. "#rwl-setMenuClose{" +
  366. "margin: 0;" +
  367. "padding: 0 2px;" +
  368. "border: none;" +
  369. "border-radius: 2px;" +
  370. "cursor: pointer;" +
  371. "background: #fff;" +
  372. "color: #000;" +
  373. "}" +
  374. "#rwl-reset{" +
  375. "border: 1px solid #666;" +
  376. "}" +
  377. "#rwl-setMenuSave{" +
  378. "border: 1px solid green;" +
  379. "}" +
  380. "#rwl-setMenuClose{" +
  381. "border: 1px solid red;" +
  382. "}" +
  383. "#rwl-setMenu{" +
  384. "text-align:left;" +
  385. "font-size:14px;" +
  386. "z-index:999999;" +
  387. "border: 1px solid cornflowerblue;" +
  388. "}" +
  389. "#rwl-setMenu p{" +
  390. "margin:5px auto;" +
  391. "}" +
  392. " ")
  393. var innerH = "" +
  394. "<p>距离顶部距离(单位 像素) <input id='positiontop' type='text' value=" + userSetting.positionTop + "></p>" + "" +
  395. // "<laberl> <p>允许上传黑名单<input id='uploadchecked' type='checkbox' " + upload_checked + "></p>" + "</laberl>" +
  396. "<p id='rwl-shortcuts' title='快捷键'>快捷键:" +
  397. "<select id='rwl-shortcut'>" +
  398. "<option value='off'" + (userSetting.shortcut == 0?"selected":"") + ">关闭</option>" +
  399. "<option value='f1'" + (userSetting.shortcut == 1?"selected":"") + "> F1 </option>" +
  400. "<option value='ctrlf1'" + (userSetting.shortcut == 2?"selected":"") + ">ctrl + F1</option>" +
  401. "<option value='ctrlc'" + (userSetting.shortcut == 3?"selected":"") + ">ctrl + C</option>" +
  402. "</select>" +
  403. "</p> " +
  404. "<laberl> <p>显示按钮<input id='btnchecked' type='checkbox' " + btnchecked + "> 点击脚本管理扩展可以再次打开设置</p>" + "</laberl>" +
  405. "<p>问题反馈地址: <a target='_blank' href='https://github.com/qxinGitHub/Remove-web-limits-'>GitHub(qxin)</a>, <a target='_blank' href='https://gf.qytechs.cn/zh-CN/scripts/28497-remove-web-limits-modified'>GreasyFork(qxin)</a> </P>" +
  406. "<p>项目原作者为 <a target='_blank' href='https://cat7373.github.io/remove-web-limits/'>cat7373</a>, <a target='_blank' href='https://github.com/Cat7373/remove-web-limits'>项目主页</a> </P>" +
  407. "<p>能力有限,不能每个网站都能完美</P>" +
  408. "<p>如若反馈,务必带上详细网址</P>" +
  409. "<p> </P>" +
  410. // "<p><s>显示按钮(待添加)</s></p>" +
  411. // "<p><s>按钮透明度(待添加)</s></p>" +
  412. // "<p><s>快速复制(待添加)</s></p>" +
  413. // "<p><s>其他 (待添加)</s></p>" +
  414. "<p>数据存储方式为JSON,如若在此修改,注意引号逗号</P>" +
  415. "<textarea wrap='off' cols='45' rows='20' style='overflow:auto;border-radius:4px;'>" + JSON.stringify(userSetting.data,false,4) + "</textarea>" +
  416. "<br>" +
  417. "<qxinbutton id='rwl-reset'>清空设置</qxinbutton> &nbsp;&nbsp;&nbsp;" +
  418. "<qxinbutton id='rwl-setMenuSave'>保存</qxinbutton> &nbsp;&nbsp;&nbsp;" +
  419. "<qxinbutton id='rwl-setMenuClose' onclick='this.parentNode.parentNode.removeChild(this.parentNode);' title='如果无法关闭 请刷新界面' >关闭</qxinbutton> &nbsp;&nbsp;&nbsp;" +
  420. "<span style='font-size:0.7em;'>--| qxin v4.4.8 2022-12-13 |--</span>" +
  421. ""
  422. "";
  423. odom.innerHTML = innerH;
  424. document.body.appendChild(odom);
  425. document.querySelector("#rwl-setMenuSave").addEventListener("click",saveSetting);
  426. document.querySelector("#rwl-setMenuClose").addEventListener("click",closeMenu);
  427. document.querySelector("#rwl-reset").addEventListener("click",rwlReset);
  428. }
  429. // 保存选项
  430. function saveSetting(){
  431. var positionTop = document.querySelector("#rwl-setMenu #positiontop").value;
  432. // var uploadChecked = document.querySelector("#rwl-setMenu #uploadchecked").checked;
  433. var shortcut = document.querySelector("#rwl-setMenu #rwl-shortcut").selectedIndex;
  434. var addBtnChecked = document.querySelector("#rwl-setMenu #btnchecked").checked;
  435. var codevalue = document.querySelector("#rwl-setMenu textarea").value;
  436. if(codevalue){
  437. var userSetting = GM_getValue("rwl_userData");
  438. userSetting.addBtn = addBtnChecked;
  439. userSetting.data = JSON.parse(codevalue);
  440. userSetting.positionTop = parseInt(positionTop);
  441. userSetting.shortcut = parseInt(shortcut);
  442. // userSetting.connectToTheServer = uploadChecked;
  443. GM_setValue("rwl_userData",userSetting);
  444. // 刷新页面
  445. setTimeout(function(){
  446. window.location.reload();
  447. },300);
  448. } else {
  449. alert("输入为空");
  450. // this.reset();
  451. }
  452. closeMenu();
  453. }
  454. // 复原菜单
  455. function rwlReset(){
  456. GM_deleteValue("rwl_userData");
  457. window.location.reload();
  458. }
  459. //关闭菜单
  460. function closeMenu(){
  461. var oldEditBox = document.querySelector("#rwl-setMenu");
  462. if(oldEditBox){
  463. oldEditBox.parentNode.removeChild(oldEditBox);
  464. return;
  465. }
  466. }
  467. // 增加拖拽事件 进行绑定
  468. function addDragEven(){
  469. setTimeout(function(){
  470. try {
  471. dragBtn()
  472. } catch (e) {
  473. console.error("dragBtn函数 报错");
  474. }
  475. },1000)
  476. // dragBtn(); // 增加拖动事件
  477. }
  478. // 增加拖动事件 func
  479. function dragBtn(){
  480. var rwl_node = document.querySelector("#rwl-iqxin");
  481. rwl_node.addEventListener("mousedown",function(event){
  482. rwl_node.style.transition = "null";
  483. var disX = event.clientX - rwl_node.offsetLeft;
  484. var disY = event.clientY - rwl_node.offsetTop;
  485. var move = function(event){
  486. rwl_node.style.left = event.clientX - disX + "px" ;
  487. rwl_node.style.top = event.clientY - disY + "px" ;
  488. }
  489. document.addEventListener("mousemove",move);
  490. document.addEventListener("mouseup",function(){
  491. rwl_node.style.transition = "0.3s";
  492. document.removeEventListener("mousemove",move);
  493. // 此函数内所有的注释语句都是有用的
  494. // 开启后,可拖动到屏幕右侧,但尚未添加css
  495. // 在上面添加 rwl-active-iqxin 的地方加上判断左右,在加上相应的css即可
  496. // 懒 2018-04-18 21:51:32
  497. // var bodyWidth = document.body.clientWidth;
  498. var rwl_nodeWidth = rwl_node.offsetLeft + rwl_node.offsetWidth/2;
  499. // if(rwl_nodeWidth > bodyWidth/2){
  500. // rwl_node.style.left = "auto";
  501. // rwl_node.style.right = 0;
  502. // rwl_userData.positionLeft = "auto";
  503. // rwl_userData.positionRight = "0";
  504. // } else {
  505. rwl_node.style.right = rwl_userData.positionRight = "auto";
  506. rwl_node.style.left = rwl_userData.positionLeft = 0;
  507. // }
  508. rwl_userData.positionTop = rwl_node.offsetTop;
  509. GM_setValue("rwl_userData",rwl_userData);
  510. })
  511. })
  512. }
  513. // 初始化 init func 这里才是核心
  514. function init() {
  515. // 针对个别网站采取不同的策略
  516. rule = clear();
  517. // 设置 event 列表
  518. hook_eventNames = rule.hook_eventNames.split("|");
  519. // TODO Allowed to return value
  520. unhook_eventNames = rule.unhook_eventNames.split("|");
  521. eventNames = hook_eventNames.concat(unhook_eventNames);
  522. // 调用清理 DOM0 event 方法的循环
  523. if(rule.dom0) {
  524. setInterval(clearLoop, 10 * 1000);
  525. setTimeout(clearLoop, 1500);
  526. window.addEventListener('load', clearLoop, true);
  527. clearLoop();
  528. }
  529. // hook addEventListener //导致搜索跳转失效的原因
  530. if(rule.hook_addEventListener) {
  531. EventTarget.prototype.addEventListener = addEventListener;
  532. document.addEventListener = addEventListener;
  533. if(hasFrame){
  534. for(let i = 0;i<hasFrame.length;i++){
  535. hasFrame[i].contentWindow.document.addEventListener = addEventListener;
  536. }
  537. }
  538. }
  539. // hook preventDefault
  540. if(rule.hook_preventDefault) {
  541. Event.prototype.preventDefault = function() {
  542. if(hook_eventNames.indexOf(this.type) < 0) {
  543. Event_preventDefault.apply(this, arguments);
  544. }
  545. };
  546. if(hasFrame){
  547. for(let i = 0;i<hasFrame.length;i++){
  548. hasFrame[i].contentWindow.Event.prototype.preventDefault = function() {
  549. if(hook_eventNames.indexOf(this.type) < 0) {
  550. Event_preventDefault.apply(this, arguments);
  551. }
  552. };
  553. }
  554. }
  555. }
  556. // Hook set returnValue
  557. if(rule.hook_set_returnValue) {
  558. Event.prototype.__defineSetter__('returnValue', function() {
  559. if(this.returnValue !== true && hook_eventNames.indexOf(this.type) >= 0) {
  560. this.returnValue = true;
  561. }
  562. });
  563. }
  564. // 添加CSS // console.debug('url: ' + url, 'storageName:' + storageName, 'rule: ' + rule.name);
  565. if(rule.add_css) {
  566. 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;}');
  567. } //else {
  568. //GM_addStyle('html, :not([class*="rwl-exempt"]) {-webkit-user-select:text!important; -moz-user-select:text!important;}');
  569. //}
  570. }
  571. // Hook addEventListener proc
  572. function addEventListener(type, func, useCapture) {
  573. var _addEventListener = this === document ? document_addEventListener : EventTarget_addEventListener;
  574. if(hook_eventNames.indexOf(type) >= 0) {
  575. _addEventListener.apply(this, [type, returnTrue, useCapture]);
  576. } else if(unhook_eventNames.indexOf(type) >= 0) {
  577. var funcsName = storageName + type + (useCapture ? 't' : 'f');
  578. if(this[funcsName] === undefined) {
  579. this[funcsName] = [];
  580. _addEventListener.apply(this, [type, useCapture ? unhook_t : unhook_f, useCapture]);
  581. }
  582. this[funcsName].push(func);
  583. } else {
  584. _addEventListener.apply(this, arguments);
  585. }
  586. }
  587. // 清理循环
  588. function clearLoop() {
  589. rule = clear() // 对于动态生成的节点,随时检测
  590. var elements = getElements();
  591. for(var i in elements) {
  592. for(var j in eventNames) {
  593. var name = 'on' + eventNames[j];
  594. // ;?未解决
  595. // 2018-04-02 elements中会有字符串出现,原版不会,问题不明,根本原因尚未解决
  596. // 相关反馈 https://gf.qytechs.cn/zh-CN/forum/discussion/36014
  597. // 问题版本号 v3.0.7
  598. // 问题补充 之前可以使用,具体版本未测(2018-04-02 21:27:53),原版可以使用
  599. if(Object.prototype.toString.call(elements[i])=="[object String]"){
  600. continue;
  601. }
  602. // console.log(elements[i])
  603. // if(typeof elements[i][name] === "object"){
  604. // console.log(typeof elements[i][name])
  605. // }
  606. if(elements[i][name] !== null && elements[i][name] !== onxxx) {
  607. if(unhook_eventNames.indexOf(eventNames[j]) >= 0) {
  608. elements[i][storageName + name] = elements[i][name];
  609. elements[i][name] = onxxx;
  610. } else {
  611. elements[i][name] = null;
  612. }
  613. }
  614. }
  615. }
  616. document.onmousedown = function(){return true;};
  617. }
  618. // 返回true的函数
  619. function returnTrue(e) {
  620. return true;
  621. }
  622. function unhook_t(e) {
  623. return unhook(e, this, storageName + e.type + 't');
  624. }
  625. function unhook_f(e) {
  626. return unhook(e, this, storageName + e.type + 'f');
  627. }
  628. function unhook(e, self, funcsName) {
  629. var list = self[funcsName];
  630. for(var i in list) {
  631. list[i](e);
  632. }
  633. e.returnValue = true;
  634. return true;
  635. }
  636. function onxxx(e) {
  637. var name = storageName + 'on' + e.type;
  638. this[name](e);
  639. e.returnValue = true;
  640. return true;
  641. }
  642. // 获取所有元素 包括document
  643. function getElements() {
  644. var elements = Array.prototype.slice.call(document.getElementsByTagName('*'));
  645. elements.push(document);
  646. // 循环所有 frame 窗口
  647. var frames = document.querySelectorAll("frame")
  648. if(frames){
  649. hasFrame = frames;
  650. var frames_element;
  651. for (let i = 0;i<frames.length;i++){
  652. frames_element = Array.prototype.slice.call(frames[i].contentWindow.document.querySelectorAll("*"))
  653. elements.push(frames[i].contentWindow.document)
  654. elements = elements.concat(frames_element);
  655. }
  656. }
  657. return elements;
  658. };
  659. // 获取黑名单网站 Func
  660. function get_black_list(){
  661. // 之前版本可能导致存储空的字符串
  662. // 2018-06-11 15:11:44 保留,当容错处理
  663. var data_temp = rwl_userData.data;
  664. data_temp = data_temp.filter(function(item){
  665. return item.length>1;
  666. })
  667. return data_temp;
  668. }
  669. // 检查是否存在于黑名单中 返回位置 func
  670. function check_black_list(list,host){
  671. for(let i=0;i<list.length;i++){
  672. if(~hostname.indexOf(list[i])){
  673. return i+1; //万一匹配到第一个,返回0
  674. }
  675. }
  676. return false;
  677. }
  678. // 鼠标点击后按钮后 检查是否在黑名单
  679. function black_check(bool){
  680. var list = GM_getValue("rwl_userData").data
  681. var check = check_black_list(list,hostname);
  682. if (bool && !check) {
  683. list = list.concat(hostname);
  684. // console.log("选中 不在黑名单, 增加",hostname,list);
  685. rwl_userData.waitUpload.push(hostname); //准备上传
  686. rwl_userData.currentURL = window.location.href;
  687. // console.log("after: ",rwl_userData.waitUpload)
  688. saveData(list);
  689. init();
  690. }else if(!bool && check){
  691. list.splice(check-1,1);
  692. saveData(list);
  693. // 刷新页面
  694. setTimeout(function(){
  695. window.location.reload(true);
  696. console.log("刷新页面loading");
  697. },350);
  698. }else{
  699. return false;
  700. }
  701. }
  702. // 保存本地数据,并将数据上传至服务器
  703. function saveData(lists){
  704. lists = lists.filter(function(item){
  705. return item.length>1;
  706. })
  707. // 更新数据
  708. rwl_userData.data = lists.sort();
  709. // 将本地黑名单上传
  710. // if (rwl_userData.waitUpload.length > 0 && rwl_userData.connectToTheServer){
  711. // // console.log("rwl : 上传...",rwl_userData.waitUpload);
  712. // // console.log("rwl : 开始上传-----");
  713. // GM_xmlhttpRequest({
  714. // method: "POST",
  715. // // url: "http://127.0.0.1:8000/tool/testajax/",
  716. // url: "http://eemm.me/tool/rwl_upload/",
  717. // data: JSON.stringify(rwl_userData),
  718. // headers: {
  719. // "Content-Type": "application/x-www-form-urlencoded"
  720. // },
  721. // onload: function(response) {
  722. // // console.log("rwl : 上传成功----");
  723. // }
  724. // });
  725. // rwl_userData.waitUpload = [];
  726. // }
  727. GM_setValue("rwl_userData",rwl_userData);
  728. return rwl_userData;
  729. }
  730. // 数组去重
  731. function unique(arr) {
  732. var ret = []
  733. for (var i = 0; i < arr.length; i++) {
  734. var item = arr[i]
  735. if (ret.indexOf(item) === -1) {
  736. ret.push(item)
  737. }
  738. }
  739. return ret;
  740. }
  741. // 复制到剪贴板
  742. function setClipboard(){
  743. var text_obj = window.getSelection();
  744. var text = text_obj.toString();
  745. GM_setClipboard(text);
  746. }
  747. // 快捷键 F1(ctrl+f1) 复制
  748. function hotkey() {
  749. var a = window.event.keyCode;
  750. // if ((a == 112) && (event.ctrlKey)) {
  751. if (a == 112 && userSetting.shortcut == 1) {
  752. event.preventDefault();
  753. setClipboard();
  754. event.keyCode=0;
  755. event.returnValue=false;
  756. return false;
  757. } else if (a == 112 && (event.ctrlKey) && userSetting.shortcut == 2){
  758. setClipboard();
  759. } else if((a == 67) && (event.ctrlKey) && userSetting.shortcut == 3){
  760. setClipboard();
  761. }else {
  762. console.log("关闭了快捷键");
  763. }
  764. }
  765. document.onkeydown = hotkey; //当onkeydown 事件发生时调用hotkey函数
  766. // 部分网站采用了其他的防复制手段
  767. function clear(){
  768. // console.log("进入clear",hostname,rwl_userData.rules);
  769. switch (hostname){
  770. case "chuangshi.qq.com": clear_chuangshi();break;
  771. case "votetw.com": clear_votetw();break;
  772. case "www.myhtebooks.com": clear_covers(".fullimg");break;
  773. case "www.z3z4.com": clear_covers(".moviedownaddiv"); break;
  774. case "huayu.baidu.com": clear_covers("#jqContextMenu"); break;
  775. case "www.myhtlmebook.com": clear_covers("img.fullimg"); break;
  776. case "www.szxx.com.cn": clear_covers("img#adCover"); break;
  777. case "zhihu.com":
  778. case "www.zhihu.com": return rwl_userData.rules.rule_zhihu; break;
  779. case "t.bilibili.com": clear_link_bilibili(); break;
  780. case "www.uslsoftware.com": clear_covers(".protect_contents-overlay");clear_covers(".protect_alert"); return rwl_userData.rules.rule_plus; break;
  781. case "www.longmabookcn.com": clear_covers(".fullimg"); return rwl_userData.rules.rule_plus; break;
  782. case "boke112.com": return rwl_userData.rules.rule_plus; break;
  783. case "www.shangc.net": return rwl_userData.rules.rule_plus; break;
  784. // 去除弹窗
  785. case "www.daodoc.com": clear_marks(".marks"); break;
  786. case "www.wcqjyw.com": clear_marks(".marks"); break;
  787. case "www.jianbiaoku.com": clear_marks(".layui-layer-shade"); break;
  788. }
  789. return rwl_userData.rules.rule_def;
  790. }
  791. // 去除覆盖层
  792. function clear_covers(ele){
  793. var odiv = document.querySelector(ele);
  794. if(odiv){
  795. odiv.parentNode.removeChild(odiv);
  796. }
  797. }
  798. // b站将文字嵌套在链接中
  799. function clear_link_bilibili(){
  800. var odiv = document.querySelector(".description");
  801. if(odiv){
  802. var tDiv = odiv.querySelector(".content-ellipsis");
  803. var aDiv = odiv.querySelector("a");
  804. odiv.appendChild(tDiv);
  805. }
  806. }
  807. // https://votetw.com/wiki/%E6%9E%97%E6%99%BA%E5%A0%85
  808. // 会创建多个无id,无class的div,覆盖在文字上层
  809. function clear_votetw(){
  810. var odivs = document.querySelectorAll(".mw-parser-output>div")
  811. odivs.forEach(function(value){
  812. value.setAttribute("style","");
  813. })
  814. }
  815.  
  816. // 去除弹窗, 复制后会出现弹窗提示, 但实际已经复制成功
  817. function clear_marks(node){
  818. GM_addStyle(`
  819. ${node} {
  820. display: none !important;
  821. }
  822. `)
  823. }
  824. // 创世中文网
  825. function clear_chuangshi(){
  826. console.log("创世中文网 开始执行");
  827.  
  828. // JS 汉字与Unicode码的相互转化
  829. // https://www.cnblogs.com/wwlhome/p/5650744.html
  830. function tounicode(data)
  831. {
  832. if(data == '') return '请输入汉字';
  833. var str ='';
  834. for(var i=0;i<data.length;i++)
  835. {
  836. str+="\\u"+parseInt(data[i].charCodeAt(0),10).toString(16);
  837. }
  838. return str;
  839. }
  840. function tohanzi(data)
  841. {
  842. if(data == '') return '请输入十六进制unicode';
  843. data = data.split("\\u");
  844. var str ='';
  845. for(var i=0;i<data.length;i++)
  846. {
  847. str+=String.fromCharCode(parseInt(data[i],16).toString(10));
  848. }
  849. return str;
  850. }
  851. // javascript中的replace函数同时替换多个字符串
  852. // https://bbs.csdn.net/topics/320097246
  853. Array.prototype.each = function(trans) {
  854.     for (var i=0; i<this.length; i++)
  855.         this[i] = trans(this[i], i, this);
  856.     return this;
  857. };
  858. Array.prototype.map = function(trans) {
  859.     return [].concat(this).each(trans);
  860. };
  861. RegExp.escape = function(str) {
  862.     return new String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
  863. };
  864. function properties(obj) {
  865.     var props = [];
  866.     for (var p in obj) props.push(p);
  867.     return props;
  868. }
  869. // ---------------------------------------------
  870. var bookreadercontent = document.querySelector(".bookreadercontent");
  871. if(bookreadercontent){
  872. var str = bookreadercontent.innerText;
  873. var strUnicode = tounicode(str);
  874. var replacements = {"e2af":"4e09","e2af":"4e0b","e2c9":"4e3b","e2d6":"4e48","e2b2":"4e4b","e2a6":"4e5f","e294":"4e8b","e2e9":"4e8c","e30a":"4e8e","e292":"4e94","e298":"4e9b","e2a2":"4ee3","e2f0":"4f46","e30e":"4f4d","e305":"4f53","e296":"4f5c","e2d3":"4f60","e2db":"4f7f","e29b":"516c","e2b0":"5176","e2ed":"51fa","e2eb":"5206","e2f1":"5229","e307":"5230","e2ce":"5236","e2e6":"524d","e2ea":"529b","e2a8":"52a0","e2a5":"5316","e2bd":"5341","e302":"539f","e2df":"53bb","e2c7":"53c8","e303":"53cd","e2ac":"53d1","e2f8":"53ea","e30b":"5404","e29c":"5408","e2d7":"540c","e2d8":"540e","e306":"5411","e2c5":"547d","e2b4":"56db","e2f9":"56e0","e2ca":"5730","e2ef":"5916","e2bc":"591a","e301":"5929","e29a":"597d","e2b7":"5b50","e2cc":"5b83","e2ee":"5b9a","e2ff":"5bb6","e2e8":"5c0f","e2d4":"5c31","e2d5":"5c55","e2a1":"5de5","e2a0":"5e73","e2fe":"5e74","e2c4":"5e76","e2c8":"5ea6","e2ae":"5efa","e304":"5f62","e291":"5f88","e2e2":"5f97","e2f2":"5fc3","e295":"6027","e2d9":"60c5","e2be":"60f3","e2c3":"610f","e30d":"6210","e2ba":"6216","e2fa":"6240","e29e":"628a","e2a7":"63d0","e2d2":"653f","e2ad":"6599","e2cd":"65b0","e2f3":"65b9"};
  875. var regex = new RegExp(properties(replacements).map(RegExp.escape).join("|"), "g");
  876. strUnicode = strUnicode.replace(regex, function($0) { return replacements[$0]; });
  877. // console.log(strUnicode)
  878. strUnicode = strUnicode.replace("u0","");
  879. str = tohanzi(strUnicode);
  880. bookreadercontent.innerText = str;
  881. }
  882.  
  883.  
  884. }
  885. // 3.x.x 过渡 4.x.x 版本
  886. function version_up_3_to_4(){
  887. var old_version = GM_getValue("black_list");
  888. if(!old_version){return};
  889. rwl_userData.data = unique(rwl_userData.data.concat(old_version.data));
  890. GM_setValue("rwl_userData",rwl_userData);
  891. GM_deleteValue("black_list");
  892. GM_deleteValue("rwl_userdata");
  893. }
  894. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址