directGelF

direct link to all gelbooru images in search results+

Από την 09/09/2014. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name          directGelF
// @namespace     directGelF
// @version       1.7
// @description   direct link to all gelbooru images in search results+
// @homepage      https://userscripts.org/scripts/show/137366
// @run-at        document-end
// @grant         GM_openInTab
// @match         http://gelbooru.com/*
// @match         http://youhate.us//images/*
// ==/UserScript==

if (typeof GM_openInTab === "undefined")
{
	GM_openInTab = window.open;
}

if(document.location.hostname != "youhate.us")
{
	var els = document.getElementsByClassName("preview");

	for(var x = 0; x < els.length; x++) 
	{
		// Obtaining the final URL of the image
		var dir = els[x].src;
		dir = dir.split("thumbnails")[1] || dir.split("thumbs")[1]; // gelbooru sometimes can't decide one
		dir = dir.split('?')[0].replace("thumbnail_","");
		dir = "http://youhate.us//images" + dir;
		
		// Setting original link to right click
		els[x].setAttribute('id',els[x].parentNode.href); // save url
		els[x].setAttribute('oncontextmenu',"return false;"); // block menu
		els[x].addEventListener('contextmenu', function(aEvent) {GM_openInTab(this.id);window.focus();}, true, true); // R-Click

		// Setting the new href
		els[x].parentNode.href = dir;
	}
}
else  // file extension fix
{
	if(document.title.indexOf("404 - File") == 0)
	{
		if(window.location.href.lastIndexOf(".jpg") != -1)
		{
			window.location.href = window.location.href.replace(".jpg", ".jpeg");
		}
		else if(window.location.href.lastIndexOf(".jpeg") != -1)
		{
			window.location.href = window.location.href.replace(".jpeg", ".png");
		}
		else if(window.location.href.lastIndexOf(".png") != -1)
		{
			window.location.href = window.location.href.replace(".png", ".gif");
		}
		else if(window.location.href.lastIndexOf(".gif") != -1)
		{
			window.location.href = window.location.href.replace(".gif", ".jpg");
		}
	}
}