DeviantArt direct download image

Makes "download image" open in same window not in new little one

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name           DeviantArt direct download image
// @namespace      devart
// @include        http://*.deviantart.com/*
// @match          http://*.deviantart.com/*
// @grant          unsafeWindow
// @version 0.0.1.20140803173200
// @description Makes "download image" open in same window not in new little one
// ==/UserScript==

function ev(q){return document.evaluate(q,document.body,null,9,null).singleNodeValue;}

if (window.location.href.match('http:\/\/.*\.deviantart\.com\/.*art\/.*')) 
{
    var alink = ev('.//a[contains(@class,"download")]');
    if (alink) 
	{
        alink.outerHTML = alink.outerHTML.replace("return D", "return window.location.href=this; D");
    }   
}

// they made some stupid background-loading instead of normal one, switching back to normal
if (typeof unsafeWindow === "undefined"){unsafeWindow = window;}
if (typeof exportFunction === "undefined")
{
	unsafeWindow.window.history.__proto__.pushState= function (a,b,url)
	{
		window.location.href = url;
	}
}
else // FF 31
{
	function Opn(a,b,url)
	{
		window.location.href = url;
	}
	exportFunction(Opn, unsafeWindow.window.history.__proto__, {defineAs: "pushState"});
}