Payment Screenshot

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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);
})();