GGn User Notes

Adds per-user notes box to profile.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         GGn User Notes
// @namespace    https://greasyfork.org
// @version      1.0
// @description  Adds per-user notes box to profile.
// @match        https://gazellegames.net/user.php*
// @grant        GM_getValue
// @grant        GM_setValue
// ==/UserScript==

(async function () {
    'use strict';

    const userId = new URLSearchParams(location.search).get('id');
    if (!userId) return;
    const header = document.getElementById('username');
    if (!header) return;
    const anchor = header.querySelector('#tip_user')?.previousElementSibling || header.lastElementChild || header;

    const key = `user_notes_${userId}`;

    const notesToggle = document.createElement('a');
    notesToggle.href = '#';
    notesToggle.textContent = '[Notes]';

    const wrapper = document.createElement('span');
    wrapper.className = 'user_notes';
    wrapper.style.marginLeft = '0.2em';
    wrapper.appendChild(notesToggle);

    const notesTextbox = document.createElement('div');
    notesTextbox.style.marginTop = '6px';
    notesTextbox.hidden = true;

    const textarea = document.createElement('textarea');
    textarea.style.width = '98%';
    textarea.style.minHeight = '80px';
    textarea.style.resize = 'vertical';
    textarea.style.fontSize = '0.8em';
    textarea.value = await GM_getValue(key, '');

    textarea.oninput = () => GM_setValue(key, textarea.value);

    notesTextbox.appendChild(textarea);
    header.appendChild(notesTextbox);

    notesToggle.onclick = (e) => {
        e.preventDefault();
        notesTextbox.toggleAttribute('hidden');
    };

    anchor.insertAdjacentElement('afterend', wrapper);
})();