Directly download image from zerochan.net

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

当前为 2022-11-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Directly download image from zerochan.net
  3. // @namespace https://myanimelist.net/profile/kyoyatempest
  4. // @match https://static.zerochan.net/*
  5. // @version 1.5
  6. // @author kyoyacchi
  7. // @description Downloads image when you click to "download image" on zerochan.net.
  8. // @license none
  9. // @icon https://www.google.com/s2/favicons?domain=zerochan.net
  10. // ==/UserScript==
  11.  
  12.  
  13. window.onload = function (){
  14.  
  15.  
  16. let isim = window.location.href.split("/")[3] || "zerochan.png"
  17. downloadImage(window.location.href,isim)
  18. console.log(`downloaded image: ${isim}`)
  19.  
  20.  
  21. function toDataURL(url) {
  22. return fetch(url).then((response) => {
  23. return response.blob();
  24. }).then(blob => {
  25. return URL.createObjectURL(blob);
  26. });
  27. }
  28.  
  29. async function downloadImage(url,isimcik) {
  30. const a = document.createElement("a");
  31. a.href = await toDataURL(url);
  32. a.download = isimcik
  33. document.body.appendChild(a);
  34. a.click();
  35. document.body.removeChild(a);
  36. }
  37. }
  38.  
  39. //https://stackoverflow.com/a/56041756/19276081