Example Commands for Programmable Notepad

adds a >hello, >aahhh, and >random command to Programmable Notepad by CCN0

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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        Example Commands for Programmable Notepad
// @namespace   ccn0
// @author      CCN0
// @version     1
// @icon        https://ccn0.net/things/notepad/favicon.png
// @match       *://ccn0.net/things/notepad/programmable*
// @match       *://127.0.0.1:8000/things/notepad/programmable*
// @description adds a >hello, >aahhh, and >random command to Programmable Notepad by CCN0
// ==/UserScript==

(function() {
    NP.help.hello = {
        text: "returns world"
    };
    COMMANDS.hello = (inf) => {
        replaceLine(NP.cursorPosition[0], "world");
    };

    NP.help.aahhh = {
        args: "<amount?>",
        text: "plays aahhh #SoundletsPlus"
    };
    COMMANDS.aahhh = (inf) => {
        const playSound = () => {
            const snd = new Audio();
            snd.src = 'https://ccn0.github.io/img/audio/plus/aahhh.mp3';
            snd.playbackRate = 1;
            snd.play();
        };

        if (inf.argsExist && !isNaN(inf.args[0])) {
            for (let i = 0; i < Number(inf.args[0]); i++) {
                playSound();
            };
        } else {
            playSound();
        };
    };

    COMMANDS.random = (inf) => {
        let max = 1;
        if (inf.argsExist && !isNaN(inf.args[0])) {
            max = Number(inf.args[0]);
        }
        const rand = Math.random() * max;
        replaceLine(NP.cursorPosition[0], `${rand}`);
    };
    NP.help.random = {
        args: "<max?>",
        text: "returns a random number (0-1 default or 0-max)"
    };
})();