DeviantArt direct download image

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

  1. // ==UserScript==
  2. // @name DeviantArt direct download image
  3. // @namespace devart
  4. // @include http://*.deviantart.com/*
  5. // @match http://*.deviantart.com/*
  6. // @grant unsafeWindow
  7. // @version 0.0.1.20140803173200
  8. // @description Makes "download image" open in same window not in new little one
  9. // ==/UserScript==
  10.  
  11. function ev(q){return document.evaluate(q,document.body,null,9,null).singleNodeValue;}
  12.  
  13. if (window.location.href.match('http:\/\/.*\.deviantart\.com\/.*art\/.*'))
  14. {
  15. var alink = ev('.//a[contains(@class,"download")]');
  16. if (alink)
  17. {
  18. alink.outerHTML = alink.outerHTML.replace("return D", "return window.location.href=this; D");
  19. }
  20. }
  21.  
  22. // they made some stupid background-loading instead of normal one, switching back to normal
  23. if (typeof unsafeWindow === "undefined"){unsafeWindow = window;}
  24. if (typeof exportFunction === "undefined")
  25. {
  26. unsafeWindow.window.history.__proto__.pushState= function (a,b,url)
  27. {
  28. window.location.href = url;
  29. }
  30. }
  31. else // FF 31
  32. {
  33. function Opn(a,b,url)
  34. {
  35. window.location.href = url;
  36. }
  37. exportFunction(Opn, unsafeWindow.window.history.__proto__, {defineAs: "pushState"});
  38. }