NTV Context Menu and Selection Change Remover

Remove context menu and set userSelect to 'text'

Version vom 14.10.2024. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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';
})();