Imgur.com - copy uploaded image URL to clipboard

Upload image to imgur.com. It's full URL will be automatically copied to clipboard. Simple.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Imgur.com - copy uploaded image URL to clipboard
// @name:pl      Imgur.com - skopiuj adres URL przesłanego obrazka do schowka
// @namespace    http://konieckropka.eu
// @version      1.0.1
// @description  Upload image to imgur.com. It's full URL will be automatically copied to clipboard. Simple.
// @description:pl  Ten prosty skrypcik pozwala zautomatyzować wgrywanie grafik na imgur.com. Po wysłaniu zdjęcia jego przesłany adres URL skopiuje się do schowka, gotowy do użycia. Proste.
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require      https://greatest.deepsurf.us/scripts/383527-wait-for-key-elements/code/Wait_for_key_elements.js?version=701631
// @match        https://imgur.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=imgur.com
// @license      No license
// ==/UserScript==

(function () {
    'use strict';
    waitForKeyElements(`div.UploadPost-file img[src^="https://"]`, copyImageUrlToClipboard);
})();

function copyImageUrlToClipboard() {
    let imageUrl = $("div.UploadPost-file img").attr("src");
    navigator.clipboard.writeText(imageUrl);
    $("div.ToastContainer").css({
        "background-color": "rgba(0, 0, 0, 0.6)",
        "height": "fit-content",
        "padding": "30px",
        "bottom": "70px",
        "top": "unset"
    }).html(`<div>Image URL: ${ imageUrl } copied to Clipboard</div>`);
}