Always Show Copy and Edit Buttons

Make copy and edit buttons always visible on Lambda Chat

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Always Show Copy and Edit Buttons
// @namespace    http://tampermonkey.net/
// @version      0.3
// @license MIT
// @description  Make copy and edit buttons always visible on Lambda Chat
// @match        https://lambda.chat/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to modify buttons visibility
    function makeButtonsVisible() {
        // Select all copy button containers
        const copyButtons = document.querySelectorAll('.invisible.md\\:group-hover\\:visible');
        
        // Select all edit/branch buttons with the specific classes
        const editButtons = document.querySelectorAll('.group-hover\\:block.md\\:hidden');

        // Make copy buttons visible
        copyButtons.forEach(button => {
            button.classList.remove('invisible');
            button.classList.add('visible');
            button.style.opacity = '1';
        });

        // Make edit buttons visible
        editButtons.forEach(button => {
            button.classList.remove('md:hidden');
            button.style.display = 'block';
            // Remove group-hover:block since we want it always visible
            button.classList.remove('group-hover:block');
        });
    }

    // Run initially
    makeButtonsVisible();

    // Create observer to handle dynamically added buttons
    const observer = new MutationObserver(() => {
        makeButtonsVisible();
    });

    // Start observing the document for added nodes
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();