Quozio Panel Image Copier

Adds a button next to the quote to copy the image

// ==UserScript==
// @name         Quozio Panel Image Copier
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a button next to the quote to copy the image
// @author       fishcat2431
// @match        https://quozio.com/quote/*
// @grant        GM_setClipboard
// @license      GNU General Public License v3.0
// ==/UserScript==

(function() {
    'use strict';

    function addCopyButton() {
        const panel = document.getElementsByClassName("quote-edit-image-panel text-center small-scroll")[0];
        if (!panel) return;

        const img = panel.querySelector("img");
        if (!img) return;

        if (document.getElementById("copyImageSrcBtn")) return;

        const btn = document.createElement("button");
        btn.id = "copyImageSrcBtn";
        btn.textContent = "Copy Image URL";
        btn.style.marginLeft = "10px";
        btn.style.padding = "5px 10px";
        btn.style.cursor = "pointer";

        btn.addEventListener("click", function() {
            GM_setClipboard(img.src);
            btn.textContent = "Copied!";
            setTimeout(() => btn.textContent = "Copy Image URL", 1500);
        });

        panel.parentNode.insertBefore(btn, panel.nextSibling);
    }

    addCopyButton();
    const observer = new MutationObserver(addCopyButton);
    observer.observe(document.body, { childList: true, subtree: true });
})();