Select and Copy Gallery URLs

Select and copy multiple gallery URLs by clicking on elements

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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         Select and Copy Gallery URLs
// @namespace    Violentmonkey Scripts
// @version      1.2
// @description  Select and copy multiple gallery URLs by clicking on elements
// @author       K0ng2
// @match        *://*.e*hentai.org/*
// @grant        GM_setClipboard
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let isSelecting = false;
    let selectedGalleries = new Set();

    // Create the "Select Galleries" button
    const selectButton = document.createElement('button');
    selectButton.innerText = 'Select Galleries';
    selectButton.style.position = 'fixed';
    selectButton.style.top = '10px';
    selectButton.style.left = '10px';
    selectButton.style.zIndex = 1000;
    selectButton.style.padding = '10px';
    selectButton.style.backgroundColor = '#4CAF50';
    selectButton.style.color = 'white';
    selectButton.style.border = 'none';
    selectButton.style.cursor = 'pointer';
    document.body.appendChild(selectButton);

    // Create the "Finish" button
    const finishButton = document.createElement('button');
    finishButton.innerText = 'Finish';
    finishButton.style.position = 'fixed';
    finishButton.style.top = '10px';
    finishButton.style.left = '130px';
    finishButton.style.zIndex = 1000;
    finishButton.style.padding = '10px';
    finishButton.style.backgroundColor = '#f44336';
    finishButton.style.color = 'white';
    finishButton.style.border = 'none';
    finishButton.style.cursor = 'pointer';
    finishButton.style.display = 'none';
    document.body.appendChild(finishButton);

    // Function to toggle selection mode
    selectButton.addEventListener('click', () => {
        isSelecting = !isSelecting;
        if (isSelecting) {
            finishButton.style.display = 'block';
            selectButton.innerText = 'Cancel';
            enableSelection();
        } else {
            finishButton.style.display = 'none';
            selectButton.innerText = 'Select Galleries';
            disableSelection();
            selectedGalleries.clear();
        }
    });

    // Function to enable selection
    function enableSelection() {
        const gridElements = document.querySelectorAll('.gl1t');
        gridElements.forEach(element => {
            element.style.cursor = 'pointer';
            element.addEventListener('click', selectGallery);
        });
    }

    // Function to disable selection
    function disableSelection() {
        const gridElements = document.querySelectorAll('.gl1t');
        gridElements.forEach(element => {
            element.style.cursor = 'default';
            element.removeEventListener('click', selectGallery);
            element.style.backgroundColor = ''; // Reset background color
        });
    }

    // Function to handle gallery selection
    function selectGallery(event) {
        event.preventDefault(); // Prevent the default anchor click behavior

        const element = event.currentTarget;
        const url = element.querySelector('a').href;

        if (selectedGalleries.has(url)) {
            selectedGalleries.delete(url);
            element.style.backgroundColor = ''; // Reset background color
        } else {
            selectedGalleries.add(url);
            element.style.backgroundColor = 'yellow'; // Change background color to indicate selection
        }
    }

    // Function to copy selected URLs
    finishButton.addEventListener('click', () => {
        const urls = Array.from(selectedGalleries).join('\n');
        GM_setClipboard(urls);
        alert('Copied URLs:\n' + urls);
        finishButton.style.display = 'none';
        selectButton.innerText = 'Select Galleries';
        disableSelection();
        selectedGalleries.clear();
    });
})();