DeviantArt direct download image

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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"});
}