Highlight JS

Loads the ace code editor when going to a .js file

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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 यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Highlight JS
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Loads the ace code editor when going to a .js file
// @author       pooiod7
// @icon         https://www.google.com/s2/favicons?sz=64&domain=js.org
// @match        *://*/*.js
// @grant        none
// ==/UserScript==

(function() {
    if (!document.body) return;
    fetch(window.location.href).then(r => r.text()).then(t => {
        let trimmed = t.trim().toLowerCase();
        if (trimmed.startsWith('<!doctype html') || trimmed.startsWith('<html')) return;
        document.body.style.margin = '0';
        document.body.innerHTML = '<div id="editor" style="height:100vh;width:100vw;"></div>';
        let script = document.createElement('script');
        script.src = 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.15.2/ace.js';
        script.onload = () => {
            let editor = ace.edit("editor");
            editor.session.setMode("ace/mode/javascript");
            editor.setShowPrintMargin(false);
            editor.setHighlightActiveLine(false);
            let darkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
            editor.setTheme(darkMode ? "ace/theme/monokai" : "ace/theme/tomorrow");
            editor.setValue(t, -1);
        };
        document.body.appendChild(script);
    });
})();