Downloads image when you click to download icon on zerochan.net.
// ==UserScript==
// @name Directly download image from zerochan.net
// @namespace https://myanimelist.net/profile/kyoyatempest
// @match https://www.zerochan.net/*
// @version 4.0
// @author kyoyacchi
// @description Downloads image when you click to download icon on zerochan.net.
// @license none
// @icon https://www.zerochan.net/favicon.ico
// @supportURL https://github.com/kyoyacchi/zerochan-downloader/issues
// ==/UserScript==
(function () {
"use strict";
const downloadBtn = document.querySelector(".download-button");
if (!downloadBtn) return;
const imageUrl = downloadBtn.href;
const fileName = imageUrl.split("/")[3] || "zerochan.png";
downloadBtn.addEventListener("click", async (e) => {
e.preventDefault();
const blob = await fetch(imageUrl).then((r) => r.blob());
const objectUrl = URL.createObjectURL(blob);
const a = Object.assign(document.createElement("a"), {
href: objectUrl,
download: fileName,
});
document.body.appendChild(a);
a.click();
a.remove();
URL.revokeObjectURL(objectUrl);
});
})();