Contenteditable Toggle

Toggle body contenteditable state with menu buttons and force text selection

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name         Contenteditable Toggle
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Toggle body contenteditable state with menu buttons and force text selection
// @author       StructSeeker
// @match        *://*/*
// @grant        GM_registerMenuCommand
// @run-at       document-start
// ==/UserScript==

(function() {
  'use strict';

  // Force global text selection
  function forceTextSelection() {
    const style = document.createElement('style');
    style.innerHTML = `
      * { 
        user-select: text !important; 
        -webkit-user-select: text !important; 
        -moz-user-select: text !important;
        -ms-user-select: text !important;
        cursor: text !important;
      }
    `;
    document.head.appendChild(style);
    console.log("Global caret and text selection forced.");
  }

  // Register menu command to make body contenteditable true
  GM_registerMenuCommand('Enable Contenteditable (true)', function() {
    document.body.contentEditable = 'true';
    console.log('Body contenteditable set to: true');
  });

  // Register menu command to make body contenteditable false
  GM_registerMenuCommand('Disable Contenteditable (false)', function() {
    document.body.contentEditable = 'false';
    console.log('Body contenteditable set to: false');
  });

  // Register menu command to make body contenteditable plaintext-only
  GM_registerMenuCommand('Plaintext Only Contenteditable', function() {
    document.body.contentEditable = 'plaintext-only';
    console.log('Body contenteditable set to: plaintext-only');
  });

  // Register menu command to force text selection globally
  GM_registerMenuCommand('Force Text Selection', function() {
    forceTextSelection();
  });

})();