Payment Screenshot

Делаем скрин перевода

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

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Payment Screenshot
// @namespace    https://lzt.market/
// @version      0.7
// @description  Делаем скрин перевода
// @author       Hash
// @match        https://lzt.market/user/payments
// @require      https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/js/all.min.js
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';

    const faStylesheet = document.createElement('link');
    faStylesheet.rel = 'stylesheet';
    faStylesheet.href = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css';
    document.head.appendChild(faStylesheet);

    window.addEventListener('load', function() {
        const mainContainer = document.querySelector('.marketMainContainer');
        if (!mainContainer) {
            console.error('Main container not found!');
            return;
        }

        const paymentContainer = mainContainer.querySelector('.marketIndex--itemsContainer.MarketItems.marketMyPayments');
        if (!paymentContainer) {
            console.error('Payment container not found!');
            return;
        }

        const paymentItems = paymentContainer.querySelectorAll('.wrapper .item');

        paymentItems.forEach(item => {
            // Create a screenshot button
            const screenshotBtn = document.createElement('button');
            screenshotBtn.innerHTML = '<i class="fa fa-exclamation-triangle"></i> Скриншот';
            screenshotBtn.style.background = 'rgb(52, 43, 28)';
            screenshotBtn.style.color = 'rgb(230, 191, 74)';
            screenshotBtn.style.display = 'flex';
            screenshotBtn.style.alignItems = 'center';
            screenshotBtn.style.margin = '8px';
            screenshotBtn.style.cursor = 'pointer';
            screenshotBtn.style.border = 'none';
            screenshotBtn.style.padding = '5px';
            screenshotBtn.style.borderRadius = '4px';
            screenshotBtn.style.fontSize = '12px';

            item.appendChild(screenshotBtn);

            screenshotBtn.addEventListener('click', function() {
                screenshotBtn.style.display = 'none';
                html2canvas(item, {
                    scale: 2,
                    useCORS: true,
                    backgroundColor: '#272727'
                }).then(canvas => {
                    canvas.toBlob(blob => {
                        const clipboardItem = new ClipboardItem({ 'image/png': blob });

                        navigator.clipboard.write([clipboardItem]).then(() => {
                            XenForo.alert('Скриншот сделан', '', 5000);


                        }).catch(err => {
                            console.error('Ошибка сохранения в буфер обмена:', err);
                            alert('Ошибка при сохранении скриншота в буфер обмена.');
                        });

                        screenshotBtn.style.display = '';
                    });
                });
            });
        });

    }, false);
})();