Telegram 无限制转发删除

Telegram 突破按钮限制(转发与删除)脚本,适合网页端telegram使用。

// ==UserScript==
// @name         Telegram 无限制转发删除
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Telegram 突破按钮限制(转发与删除)脚本,适合网页端telegram使用。
// @author       啤酒花
// @license      GNU GPLv3
// @match        https://web.telegram.org/*
// @match        https://webk.telegram.org/*
// @match        https://webz.telegram.org/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to enable buttons
    function enableButtons() {
        // Select the forward button
        const forwardButton = document.querySelector('button.selection-container-forward');
        const deleteButton = document.querySelector('button.selection-container-delete');

        // Remove 'disabled=""' attribute if it exists
        if (forwardButton) {
            forwardButton.removeAttribute('disabled');
        }
        if (deleteButton) {
            deleteButton.removeAttribute('disabled');
        }
    }

    // Initial check when the page loads
    enableButtons();

    // MutationObserver to watch for DOM changes and re-enable buttons
    const observer = new MutationObserver(() => {
        enableButtons();
    });

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