Unlock Website Limit

Unlock website events, including right click, selection lock, copy and cut, etc.

  1. // ==UserScript==
  2. // @name Unlock Website Limit
  3. // @name:zh-TW 解鎖網頁事件
  4. // @namespace https://github.snkms.com/
  5. // @version 0.8
  6. // @description Unlock website events, including right click, selection lock, copy and cut, etc.
  7. // @description:zh-TW 使用Javascript解除部分網頁事件,包括鎖右鍵、鎖複製等等
  8. // @author SN-Koarashi (5026)
  9. // @match *://*/*
  10. // @grant none
  11. // @supportURL https://discord.gg/q3KT4hdq8x
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. function unBlockFunc(eventName) {
  18. var onData = "on" + eventName;
  19. if (window.addEventListener) {
  20. window.addEventListener(eventName, function(e) {
  21. for (var n = e.target; n; n = n.parentNode){
  22. n[onData] = null;
  23. }
  24. }, true);
  25. }
  26. window[onData] = null;
  27. document[onData] = null;
  28. if (document.documentElement) document.documentElement[onData] = null;
  29. if (document.body) document.body[onData] = null;
  30. document.body.oncopy = null;
  31. }
  32.  
  33. function ObjectLength(object) {
  34. var length = 0;
  35. for (var key in object) {
  36. if (object.hasOwnProperty(key)) {
  37. length++;
  38. }
  39. }
  40. return length;
  41. };
  42.  
  43. document.addEventListener("DOMContentLoaded", function() {
  44. var hookEvents = {
  45. 0: "contextmenu",
  46. 1: "click",
  47. 2: "mousedown",
  48. 3: "mouseup",
  49. 4: "keydown",
  50. 5: "keyup",
  51. 6: "selectstart",
  52. 7: "select",
  53. 8: "copy",
  54. 9: "cut",
  55. 10: "dragstart"
  56. };
  57.  
  58. for (var i = 0; i < ObjectLength(hookEvents); i++) {
  59. unBlockFunc(hookEvents[i]);
  60. }
  61.  
  62. var css = document.createElement("style");
  63. var style = document.createTextNode("*{-ms-user-select: auto !important;-moz-user-select: auto !important;-webkit-user-select: auto !important;user-select: auto !important;}");
  64.  
  65. css.appendChild(style);
  66. document.body.appendChild(css);
  67. });
  68. })();