User Notes

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

La data de 21-08-2023. Vezi ultima versiune.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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();