Copy Image Link from Tmall

Copy image link from Tmall product pages

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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 Image Link from Tmall
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Copy image link from Tmall product pages
// @author       max5555
// @license      MIT
// @match        https://detail.tmall.com/item.htm*
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';

    // Function to create and show the notification
    function showNotification(message) {
        var notification = document.createElement('div');
        notification.innerText = message;
        notification.style.position = 'fixed';
        notification.style.bottom = '80px';
        notification.style.left = '20px';
        notification.style.backgroundColor = 'lightgreen';
        notification.style.padding = '10px';
        notification.style.zIndex = '1000';
        document.body.appendChild(notification);
        setTimeout(() => notification.remove(), 1000); // Auto-hide after 1 second
    }

    // Function to copy image link
    function copyImageLink() {
        var image = document.querySelector('.descV8-singleImage img');
        if (image && image.dataset.src) {
            GM_setClipboard(image.dataset.src);
            showNotification('Image link copied!');
        } else {
            showNotification('Image not found!');
        }
    }

    // Create and place the button
    var button = document.createElement('button');
    button.innerText = 'Copy Image Link';
    button.style.position = 'fixed';
    button.style.bottom = '40px';
    button.style.left = '20px';
    button.style.padding = '5px';
    button.style.background = 'rgba(0, 0, 0, 0.7)';
    button.style.color = 'white';
    button.style.zIndex = '10000';
    button.onclick = copyImageLink;
    document.body.appendChild(button);
})();