Directly download image from zerochan.net

Downloads image when you click to "download image" on zerochan.net.

As of 31.10.2022. See апошняя версія.

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        Directly download image from zerochan.net
// @namespace   https://myanimelist.net/profile/kyoyatempest
// @match       https://static.zerochan.net/*
// @version     1.1
// @author      kyoyacchi
// @description Downloads image when you click to "download image" on zerochan.net.
// @license gpl-3.0
// ==/UserScript==


window.onload = function (){


let isim = window.location.href.split("/")[3] || "zerochan.png"
 downloadImage(window.location.href,isim)

let dogrula = window.confirm("Wanna go back to zerochan after downloading image?")
if (dogrula) {

  setTimeout(() => {
    window.history.back()
  }, 10000) //ten secs.
}



}






function downloadImage(url, name){
      fetch(url)
        .then(resp => resp.blob())
        .then(blob => {
            const url = window.URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.style.display = 'none';
            a.href = url;

            a.download = name;
            document.body.appendChild(a);
            a.click();
            window.URL.revokeObjectURL(url);
        })
        .catch(() => alert('An error occured.'));

}

// https://stackoverflow.com/a/68722398/19276081