wallhavenClick

Try to copy the real pic url into clipboard when the preview clicked!

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @license      MIT
// @name         wallhavenClick
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Try to copy the real pic url into clipboard when the preview clicked!
// @author       RyanZ
// @match        *://*.wallhaven.cc/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=warriorz.click
// @grant        none
// @require      https://static.hdslb.com/js/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...

    $("a").on('click', function(e) {
        console.log(e);
        var url = this.href;
        url = url.replace("wallhaven.cc", "w.wallhaven.cc");
        url = url.replace("w/", "full/");
        var e6s = this.href.split("/");
        var picid = e6s[e6s.length - 1];
        var picid2 = picid.substr(0, 2);
        var poa = this.closest("figure");
        var fmt = ".jpg";
        if (poa.innerHTML.indexOf("PNG") != -1) fmt = ".png";
        url = url.replace(picid, picid2 + "/wallhaven-" + picid + fmt);
        var iptUrl = document.createElement("input");
        iptUrl.setAttribute("value", "" + url);
        document.body.appendChild(iptUrl);
        iptUrl.select();
        document.execCommand("copy");
        document.body.removeChild(iptUrl);
    });
})();