Copy URL Button

Adds a button to copy the URL of the current page

2024-05-06 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Copy URL Button
// @namespace    http://yourwebsite.com
// @version      1.0
// @description  Adds a button to copy the URL of the current page
// @author       FunkyJustin
// @match        https://gelbooru.com/*
// @match        https://danbooru.donmai.us/*
// @match        https://www.pixiv.net/en/*
// @grant        none
// @license MIT


// ==/UserScript==

(function() {
    'use strict';

    // Create a button element
    var copyButton = document.createElement('button');
    copyButton.textContent = 'Copy URL';
    copyButton.style.position = 'fixed';
    copyButton.style.top = '10px'; // Adjust top position as needed
    copyButton.style.left = '60%'; // Adjust left position as needed
    copyButton.style.padding = '10px';
    copyButton.style.border = 'none';
    copyButton.style.background = 'rgba(0, 0, 0, 0.5)';
    copyButton.style.color = '#fff';
    copyButton.style.cursor = 'pointer';
    copyButton.style.opacity = '0.3'; // Initial opacity

    // Append the button to the body
    document.body.appendChild(copyButton);

    // Function to copy the current page URL to the clipboard
    function copyURL() {
        var url = window.location.href;
        navigator.clipboard.writeText(url)
            .then(function() {
                console.log('URL copied to clipboard: ' + url);
            })
            .catch(function(error) {
                console.error('Failed to copy URL: ', error);
            });
    }

    // Event listeners for mouse hover
    copyButton.addEventListener('mouseover', function() {
        copyButton.style.opacity = '1'; // Make the button opaque on hover
    });

    copyButton.addEventListener('mouseout', function() {
        copyButton.style.opacity = '0.3'; // Make the button semi-transparent when not hovering
    });

    // Event listener for click to copy URL
    copyButton.addEventListener('click', function() {
        copyURL();
    });
})();