NTV Context Menu and Selection Change Remover

Remove context menu and set userSelect to 'text'

As of 2024-10-14. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         NTV Context Menu and Selection Change Remover
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Remove context menu and set userSelect to 'text'
// @author       Iso
// @match        https://*.ntv.co.jp/*
// @grant        none
// @run-at       document-body
// @license MIT
// ==/UserScript==

/**
 * Override the default oncontextmenu event on the document
 * to disable the context menu completely.
 */
Object.defineProperty(document, 'oncontextmenu', {
  get: function () { return null },  // Return null to indicate no context menu
  set: function() {}                  // Ignore any attempts to set the context menu
});

/**
 * Set user-select property on the document body to 'text'
 * to allow text selection.
 * This function runs when the document body loads.
 */
document.body.onload = (function() {
    'use strict';  // Enable strict mode for cleaner code

    // Initialize the body style object
    document.body.style = {};

    // Set the user-select CSS property to 'text', allowing users to select text
    document.body.style.userSelect = 'text';
})();