Html-Lock-Hunter

解除网页限制: 恢复文字的选中和复制, 去除复制时的小尾巴, 恢复页面右键菜单. Remove webpage restrictions: restore the selection and copy of text, remove the text tail, and restore the right-click menu.

当前为 2020-04-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Html-Lock-Hunter
  3. // @namespace https://github.com/xcanwin/
  4. // @version 0.6.2
  5. // @description 解除网页限制: 恢复文字的选中和复制, 去除复制时的小尾巴, 恢复页面右键菜单. Remove webpage restrictions: restore the selection and copy of text, remove the text tail, and restore the right-click menu.
  6. // @author xcanwin
  7. // @license MIT
  8. // @supportURL https://github.com/xcanwin/Html-Lock-Hunter/
  9. // @match *://www.bilibili.com/read/*
  10. // @match *://www.360doc.com/*
  11. // @match *://www.cnblogs.com/*
  12. // @match *://read.qidian.com/*
  13. // @match *://shushan.zhangyue.net/*
  14. //
  15. // @match *://*/*
  16. //
  17. // @grant all
  18. // ==/UserScript==
  19.  
  20. (function() {
  21. 'use strict';
  22. //Test in: https://www.cnblogs.com/LyShark/p/12411435.html
  23. //Test in: https://www.bilibili.com/read/cv5496952
  24. //Test in: http://www.360doc.com/content/20/0406/19/1575720_904264035.shtml
  25. //Test in: https://www.cnblogs.com/k8gege/p/11223393.html
  26. //Test in: http://shushan.zhangyue.net/book/89159/13507319/
  27.  
  28. var loop = function(func){
  29. // When reaching the goal, the function should needs to return true to pause the interval.
  30. var loop_time = 10;
  31. func.interval = setInterval(function(){
  32. if (func.time){
  33. if (func.time >= loop_time){
  34. clearInterval(func.interval);
  35. return 0;
  36. }
  37. func.time += 1;
  38. } else {
  39. func.time = 1;
  40. }
  41. //console.log(func.name + ":" + func.time);
  42. if (func()){
  43. clearInterval(func.interval);
  44. return 0;
  45. }
  46. }, 500);
  47. };
  48.  
  49. var main = function(){
  50. Array.prototype.forEach.call(document.getElementsByTagName("*"), function(el) {
  51. ["user-select", "-webkit-user-select", "-moz-user-select", "-ms-user-select"].forEach(xcanwin => {
  52. var filterstyle = document.defaultView.getComputedStyle(el, null)[xcanwin];
  53. if (filterstyle && filterstyle == 'none') {
  54. el.style = xcanwin + ": text !important";
  55. }
  56. });
  57.  
  58. ["onselect", "onselectstart", "oncopy", "onbeforecopy", "oncontextmenu"].forEach(xcanwin => {
  59. el[xcanwin] = function(e) {
  60. e.stopImmediatePropagation();
  61. }
  62. });
  63. });
  64. };
  65. loop(main);
  66. })();