Niji-gazo Multi Buttons

love, love-list, closeボタンを右下に固定表示

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Niji-gazo Multi Buttons
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  love, love-list, closeボタンを右下に固定表示
// @match        https://niji-gazo.com/*
// @grant        none
// @author       Kdroidwin  
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function createFixedButtons() {
        // 元のボタンを取得
        const closeBtn = document.querySelector('button.pswp__button.pswp__button--close');
        const loveListBtn = document.querySelector('li.icon.love-list.right');
        const loveBtn = document.querySelector('li.icon.love.add-album-item.right');

        if (!closeBtn && !loveListBtn && !loveBtn) return;

        // コンテナ作成
        const container = document.createElement('div');
        container.style.position = 'fixed';
        container.style.bottom = '20px';
        container.style.right = '20px';
        container.style.zIndex = '9999';
        container.style.display = 'flex';
        container.style.gap = '10px'; // ボタン間の間隔

        // closeボタンコピー
        if (closeBtn) {
            const closeClone = closeBtn.cloneNode(true);
            closeClone.style.cursor = 'pointer';
            closeClone.addEventListener('click', e => {
                e.preventDefault();
                closeBtn.click();
            });
            container.appendChild(closeClone); // 左端
        }

        // love-listボタンコピー
        if (loveListBtn) {
            const loveListClone = loveListBtn.cloneNode(true);
            loveListClone.style.cursor = 'pointer';
            loveListClone.addEventListener('click', e => {
                e.preventDefault();
                loveListBtn.click();
            });
            container.appendChild(loveListClone);
        }

        // loveボタンコピー
        if (loveBtn) {
            const loveClone = loveBtn.cloneNode(true);
            loveClone.style.cursor = 'pointer';
            loveClone.addEventListener('click', e => {
                e.preventDefault();
                loveBtn.click();
            });
            container.appendChild(loveClone); // 右端
        }

        document.body.appendChild(container);
    }

    window.addEventListener('load', createFixedButtons);
})();