NTV Context Menu and Selection Change Remover

Remove context menu and set userSelect to 'text'

目前为 2024-10-14 提交的版本。查看 最新版本

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