GC AIO Plugin: Notepad

Add a notepad to the sidebar on Grundo's Café

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         GC AIO Plugin: Notepad
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add a notepad to the sidebar on Grundo's Café
// @author       https://www.grundos.cafe/userlookup/?user=supercow64
// @match        https://www.grundos.cafe/*
// @icon         https://www.grundos.cafe/static/images/favicon.66a6c5f11278.ico
// @grant        none
// @license      MIT
// ==/UserScript==

const html = `<div class="notepad">
    <b>Notepad</b>
    <textarea id="aio_notepad"></textarea>
</div>`

const defaultText = `Tip: Click "Edit Sidebar" and add this code to make the sidebar prettier

#aio_notepad {
    width: 100%;
    height: 200px;
    border: 1px solid lightblue;
}`

// uncomment for testing
// const localStorage = sessionStorage

async function main() {
    // add the sidebar
    const target = document.querySelector("#aio_sidebar > .dailies")
    if (!target) return
    target.insertAdjacentHTML(`beforebegin`, html)

    // set the notepad text
    const notepad = document.querySelector("#aio_notepad")
    notepad.value = localStorage["aio_notepad"] ?? defaultText
    
    // save notepad changes
    notepad.addEventListener("change", async () => {
        localStorage["aio_notepad"] = notepad.value
    })
}

main()