Html-Lock-Hunter

解除网页限制: 恢复文字的选中和复制, 去除复制时的小尾巴, 恢复页面右键菜单.

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

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