Pastebin Paste Auto Submit with Clipboard Permission

Automatically paste clipboard content and submit it on dpaste Pastebin, retrying if clipboard permission is denied.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Pastebin Paste Auto Submit with Clipboard Permission
// @namespace    fiverr.com/web_coder_nsd
// @version      1.3
// @description  Automatically paste clipboard content and submit it on dpaste Pastebin, retrying if clipboard permission is denied.
// @author       NoushadBug
// @match        https://dpaste.org/?autopaste=true
// @icon         https://dpaste.org/static/favicon.png
// @grant        none
// @license MIT
// ==/UserScript==

(async function () {
    'use strict';

    async function handleClipboard() {
        try {
            // Request permission for clipboard read if not granted
            const permissionStatus = await navigator.permissions.query({ name: 'clipboard-read' });
            if (permissionStatus.state === 'denied') {
                console.warn('Clipboard read access is denied. Requesting access...');
                alert('Clipboard read access is required. Please allow it in your browser settings.');
                return; // Exit if access is denied
            }

            // Get clipboard content
            const clipboardText = await navigator.clipboard.readText();
            console.log('Clipboard content retrieved:', clipboardText);

            document.querySelector('[name="expires"]').value='2592000'

            // Find the textarea and set its value
            const textarea = document.querySelector('textarea');
            if (textarea) {
                textarea.value = clipboardText;
                console.log('Pasted clipboard content into the textarea.');
            } else {
                console.error('Textarea not found on the page.');
                return;
            }

            // Find and click the submit button
            const submitButton = document.querySelector('button[type="submit"]');
            if (submitButton) {
                submitButton.click();
                console.log('Clicked the submit button.');
            } else {
                console.error('Submit button not found on the page.');
            }
        } catch (error) {
            console.error('Error handling clipboard or interacting with the page:', error);
        }
    }

    // Trigger clipboard handling once the page loads
    window.addEventListener('load', async () => {
        try {
            await handleClipboard();
        } catch (error) {
            console.error('An error occurred while attempting to process the clipboard:', error);
        }
    });
})();