Always Show Copy and Edit Buttons

Make copy and edit buttons always visible on Lambda Chat

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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
    });
})();