Directly download image from zerochan.net

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

目前为 2022-11-07 提交的版本。查看 最新版本

// ==UserScript==
// @name        Directly download image from zerochan.net
// @namespace   https://myanimelist.net/profile/kyoyatempest
// @match       https://static.zerochan.net/*
// @version     1.2
// @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)
  console.log(`downloaded image: ${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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址