NTV Context Menu and Selection Change Remover

Remove context menu and set userSelect to 'text'

  1. // ==UserScript==
  2. // @name NTV Context Menu and Selection Change Remover
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Remove context menu and set userSelect to 'text'
  6. // @author Iso
  7. // @match https://*.ntv.co.jp/*
  8. // @grant none
  9. // @run-at document-body
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. /**
  14. * Override the default oncontextmenu event on the document
  15. * to disable the context menu completely.
  16. */
  17. Object.defineProperty(document, 'oncontextmenu', {
  18. get: function () { return null }, // Return null to indicate no context menu
  19. set: function() {} // Ignore any attempts to set the context menu
  20. });
  21.  
  22. /**
  23. * Set user-select property on the document body to 'text'
  24. * to allow text selection.
  25. * This function runs when the document body loads.
  26. */
  27. document.body.onload = (function() {
  28. 'use strict'; // Enable strict mode for cleaner code
  29.  
  30. // Initialize the body style object
  31. document.body.style = {};
  32.  
  33. // Set the user-select CSS property to 'text', allowing users to select text
  34. document.body.style.userSelect = 'text';
  35. })();