Greasy Fork is available in English.

Directly download image from zerochan.net

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

  1. // ==UserScript==
  2. // @name Directly download image from zerochan.net
  3. // @namespace https://myanimelist.net/profile/kyoyatempest
  4. // @match https://www.zerochan.net/*
  5. // @version 2.0
  6. // @author kyoyacchi
  7. // @description Downloads image when you click to download icon on zerochan.net.
  8. // @license none
  9. // @icon https://www.zerochan.net/favicon.ico
  10. // @supportURL https://github.com/kyoyacchi/zerochan-downloader/issues
  11. // ==/UserScript==
  12.  
  13. let urlcik = window.location.href.split("/")[3]
  14. let nan = isNaN(urlcik) ? false : true
  15. window.onload = function (){
  16. /////
  17. function toDataURL(url) {
  18. return fetch(url).then((response) => {
  19. return response.blob();
  20. }).then(blob => {
  21. return URL.createObjectURL(blob);
  22. });
  23. }
  24.  
  25. async function downloadImage(url,isimcik) {
  26. const a = document.createElement("a");
  27. a.href = await toDataURL(url);
  28. a.download = isimcik
  29. document.body.appendChild(a);
  30. a.click();
  31. document.body.removeChild(a);
  32. }
  33. /////
  34.  
  35.  
  36.  
  37.  
  38. function crumb () {
  39. let kirinti = document.querySelector(".breadcrumb")
  40. if (kirinti) {
  41. kirinti.remove();
  42. console.log("Removed left top corner button")
  43. } else {
  44. return
  45. }
  46. }
  47.  
  48. crumb();//bonus
  49.  
  50. let static = window.location.href.split("/")[2]
  51. if (static == "www.zerochan.net") {
  52.  
  53.  
  54. var buton = document.getElementsByClassName("download-button")[0]
  55.  
  56.  
  57.  
  58. let link = buton.href
  59. let yedek = []
  60. yedek.push(link)
  61. let name = link.split("/")[3] || "zerochan.png"
  62.  
  63. yedek.push(name)
  64.  
  65.  
  66. buton.addEventListener("click", function(e) {
  67.  
  68. e.preventDefault();
  69. downloadImage(yedek[0],yedek[1])
  70. console.log(`downloaded image: ${yedek[1]||"??"}`)
  71. let titl = []
  72. titl.push(document.title)
  73.  
  74. setTimeout(() => {
  75. document.title = "Image downloaded."
  76. console.log("I changed title of page,it will be reverted in 10 scs.")
  77. },500)
  78. setTimeout(() => {
  79. document.title = titl[0] || "Refresh page to see original title"
  80. console.log("I've reverted the page title.")
  81. },10000)
  82. //console.log("Someone clicked to download button")
  83. }, false);
  84.  
  85.  
  86. }
  87. function setLikeCount() {
  88. var like_count = 0;
  89. try {
  90. var get_count = document.getElementById("favorites").getElementsByClassName("user").length
  91.  
  92. } catch(e) {
  93. like_count = 0
  94. }
  95. like_count = get_count || 0
  96. document.querySelector("p:nth-of-type(2)").style.color = "#FFFFFF"
  97.  
  98. let tmp = []
  99. let boyutvs = document.querySelector("p:nth-of-type(2)").childNodes[0].textContent
  100.  
  101. tmp.push(boyutvs)
  102.  
  103. setTimeout(() => {
  104. document.querySelector("p:nth-of-type(2)").childNodes[0].textContent = tmp[0] + ` (${like_count} ${like_count > 1? "likes":"like"})`
  105. },500)
  106.  
  107.  
  108.  
  109. document.querySelector(".fav-button").addEventListener("click",function(e) {
  110. let exists = document.querySelector(".active.fav-button")
  111. if (!exists){
  112. document.querySelector("p:nth-of-type(2)").childNodes[0].textContent = tmp[0] + ` (${like_count+1} ${like_count+1>1?"likes" : "like"})`
  113. } else {
  114. document.querySelector("p:nth-of-type(2)").childNodes[0].textContent = tmp[0] + ` (${like_count - 1 == "-1" ? 0 : like_count} ${like_count -1 > 1? "likes" :"like"})`
  115. }
  116. })
  117. }
  118. setLikeCount();
  119. }
  120.