Disable Site Restriction On Page Operations

Disable site restrictions which prevent users on performing clipboard operations, text selection, page printing (experimental), and opening the Right-Click context menu. To open the Right-Click context menu use SHIFT+RightClick (the default; configurable in the script code).

Від 03.10.2019. Дивіться остання версія.

  1. // ==UserScript==
  2. // @name Disable Site Restriction On Page Operations
  3. // @namespace https://greasyfork.org/en/users/85671-jcunews
  4. // @version 1.0.2
  5. // @license AGPLv3
  6. // @author jcunews
  7. // @description Disable site restrictions which prevent users on performing clipboard operations, text selection, page printing (experimental), and opening the Right-Click context menu. To open the Right-Click context menu use SHIFT+RightClick (the default; configurable in the script code).
  8. // @match *://*/*
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (() => {
  14. //=== CONFIGURATION BEGIN ===
  15.  
  16. //Setting for Right-Click. At least either SHIFT or CTRL should be set to true.
  17. let useShift = true;
  18. let useCtrl = false;
  19.  
  20. //=== CONFIGURATION END ===
  21.  
  22. let epd = Event.prototype.preventDefault;
  23. Event.prototype.preventDefault = function() {
  24. let a;
  25. switch (this.type) {
  26. case "cut":
  27. case "copy":
  28. case "selectstart":
  29. return;
  30. case "paste":
  31. if (a = document.activeElement) {
  32. while (a && a.classList && !a.classList.contains("CodeMirror")) a = a.parentNode;
  33. if (a) break;
  34. }
  35. return;
  36. case "contextmenu":
  37. if ((this.shiftKey === useShift) && (this.ctrlKey === useCtrl)) return;
  38. }
  39. return epd.apply(this, arguments);
  40. };
  41. addEventListener("load", () => {
  42. document.body.appendChild(document.createElement("STYLE")).innerHTML = `
  43. @media print {
  44. html, body { opacity: 1 !important; visibility: visible !important }
  45. html { display: ${getComputedStyle(document.documentElement).display} !important }
  46. body { display: ${getComputedStyle(document.body).display} !important }
  47. }
  48. * {
  49. user-select: auto !important; -moz-user-select: auto !important; -webkit-user-select: auto !important; -ms-user-select: auto !important;
  50. }
  51. `;
  52. });
  53. })();