Anti-Disabler

Restore context menus on sites that try to disable them

  1. // ==UserScript==
  2. // @name Anti-Disabler
  3. // @namespace https://gf.qytechs.cn/en/users/10166-moriarty
  4. // @description Restore context menus on sites that try to disable them
  5. // @include http://*
  6. // @include https://*
  7. // @exclude http://*.google.com/*
  8. // @exclude https://*.google.com/*
  9. // @exclude http://*.youtube.com/*
  10. // @exclude http://youtube.com/*
  11. // @exclude https://*.youtube.com/*
  12. // @exclude https://youtube.com/*
  13. // @exclude http://*.facebook.com/*
  14. // @exclude https://*.facebook.com/*
  15. // @exclude http://gf.qytechs.cn/*
  16. // @exclude https://gf.qytechs.cn/*
  17. // @exclude http://*.deviantart.com/*
  18. // @exclude http://www.jslint.com/*
  19. // @exclude https://www.jslint.com/*
  20. // @exclude file:///*/perf.html*
  21. // @exclude http://ninjakiwi.com/*
  22. // @exclude https://ninjakiwi.com/*
  23. // @exclude http://jsfiddle.net/*
  24. // @exclude https://jsfiddle.net/*
  25. // @exclude http://*.wikipedia.org/*
  26. // @exclude https://*.wikipedia.org/*
  27. // @exclude http://*.codefelony.com/*
  28. // @exclude https://*.codefelony.com/*
  29. // @exclude https://codefelony.com/*
  30. // @require https://gf.qytechs.cn/scripts/9003-codefelony-js-library/code/CodeFelony%20JS%20Library.js?version=44596
  31. // @copyright CodeFelony
  32. // @version 1.0.1
  33. // @run-at document-start
  34. // ==/UserScript==
  35.  
  36. (function () {
  37.  
  38. 'use strict';
  39.  
  40. var events_blacklist = [
  41. 'onmousedown',
  42. 'onmouseup',
  43. 'oncontextmenu',
  44. 'onselectstart',
  45. 'ondragstart',
  46. 'ondrag',
  47. 'ondragenter',
  48. 'ondragleave',
  49. 'ondragover',
  50. 'ondrop',
  51. 'ondragend'
  52. ],
  53. rEventBlacklist = new RegExp( events_blacklist.join('|').replace(/^on/g, ''), 'i' ),
  54. oldAEL, win;
  55.  
  56. // unwraps the element so we can use its methods freely
  57. function unwrap(elem) {
  58. if (elem) {
  59. if (typeof XPCNativeWrapper === 'function' && typeof XPCNativeWrapper.unwrap === 'function') {
  60. return XPCNativeWrapper.unwrap(elem);
  61. } else if (elem.wrappedJSObject) {
  62. return elem.wrappedJSObject;
  63. }
  64. }
  65.  
  66. return elem;
  67. }
  68.  
  69. win = unwrap(window);
  70.  
  71. // don't let blacklisted events get added by addEventListener
  72. oldAEL = win.Element.prototype.addEventListener; // store a reference to the original addEventListener
  73. win.Element.prototype.addEventListener = function () {
  74. if ( !rEventBlacklist.test(name) ) {
  75. return oldAEL.apply(this, arguments);
  76. }
  77. };
  78.  
  79. // remove other listeners when the page loads
  80. CFL.runAt('interactive', function (event) {
  81. var all = document.getElementsByTagName('*'),
  82. doc = win.document,
  83. body = win.document.body,
  84. isPrototype = typeof doc.observe === 'function' && typeof doc.stopObserving === 'function',
  85. len, e, i, jQall, jQdoc;
  86.  
  87. events_blacklist.forEach(function (event) {
  88. doc[event] = null;
  89. body.removeAttribute(event);
  90. if (isPrototype === true) {
  91. doc.stopObserving(event); // disable Prototype observation
  92. }
  93. });
  94.  
  95. // Disabling of specific elements
  96. for (i = 0, len = all.length; i < len; i += 1) {
  97.  
  98. e = unwrap( all[i] );
  99.  
  100. events_blacklist.forEach(function (event) {
  101. e[event] = null;
  102. e.removeAttribute(event);
  103. });
  104.  
  105. if (e.style.MozUserSelect === 'none') {
  106. e.style.MozUserSelect = 'text';
  107. }
  108.  
  109. }
  110.  
  111. // Disabling by jQuery
  112. if (typeof win.$ === 'function' && typeof win.$.prototype.unbind === 'function') {
  113. jQall = win.$('*');
  114. jQdoc = win.$(doc);
  115. events_blacklist.forEach(function (event) {
  116. jQall.unbind(event);
  117. jQdoc.unbind(event);
  118. });
  119. }
  120.  
  121. if (typeof win.jQuery === 'function' && typeof win.jQuery.prototype.unbind === 'function') {
  122. win.jQuery(win).unbind('keypress'); // Remove keyboard blocking - comment line out if you don't want it
  123. }
  124.  
  125. if (typeof win.ProtectImg !== 'undefined') {
  126. win.ProtectImg = function () {
  127. return true;
  128. };
  129. }
  130. });
  131.  
  132. }());

QingJ © 2025

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