User Notes

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

当前为 2023-08-21 提交的版本,查看 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址