Imgur open image in new tab

Allows favoriting single images from dumps

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

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

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==
// @name         Imgur open image in new tab
// @namespace    http://cactuspie.com
// @version      1.0
// @description  Allows favoriting single images from dumps
// @author       CactusPie
// @match        https://imgur.com/gallery/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    $(document.body).on("mousedown mouseup click focus blur", "img[src^='//i.imgur.com'],video", e => {
		let url;

		if(e.target.tagName.toUpperCase() === "VIDEO") {
			url = e.target.children[0].src;
		} else {
			url = e.target.src;
		}

        if(e.which === 2) {
            const imgName = url.substr(url.lastIndexOf('/') + 1);
            let imgId = imgName.substr(0, imgName.indexOf("."));
            if(imgId.endsWith('g')) {
				imgId = imgId.substr(0, imgId.length - 1);
            }
            window.open(`https://imgur.com/${imgId}`, '_blank');
        }
    });
})();