User Notes

Отображение заметки о пользоватале в его профиле

Versione datata 21/08/2023. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         User Notes
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Отображение заметки о пользоватале в его профиле
// @match        https://zelenka.guru/*
// @icon         https://zelenka.guru/data/avatars/l/2259/2259792.jpg?1690711557
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

function addNote(element = null){
    let input = $('<input type="text" id="link_input" placeholder="none" autocomplete="off" style="background: rgb(0, 0, 0, 0) !important; color: rgb(214, 214, 214);border: 0; width: -webkit-fill-available; padding: 3px 0 1px">');
    if (!element) {
        let pageTop = $('.page_top');
        pageTop[0].insertBefore(input[0], pageTop[0].lastChild);

        var currentLink = window.location.href;
        console.log(currentLink)
    }
    else {
        let userStatus = element.querySelector('.userTitleBlurb');
        userStatus.after(input[0]);
        var currentLink = element.querySelector('a[href]').href;
    }

    let storedLink = GM_getValue(currentLink, '');
    input.val(storedLink);

    input.keypress(function(e) {
        if (e.which === 13) {
            let value = $(this).val();
            GM_setValue(currentLink, value);
            XenForo.alert('Изменения сохранены', '', 2000);
        }
    });
}

window.onload = function() {
    const observer = new MutationObserver(function(mutationsList) {
        for (let mutation of mutationsList) {
            for (let addedNode of mutation.addedNodes) {
                if (addedNode instanceof HTMLElement && addedNode.classList.contains('modal')) {
                    addNote(addedNode);
                }
            }
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });
};

addNote();