知乎下载助手

一键下载知乎原图,每张图片左下角有一个下载原图按钮

  1. // ==UserScript==
  2. // @name 知乎下载助手
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description 一键下载知乎原图,每张图片左下角有一个下载原图按钮
  6. // @author Robert-Stackflow
  7. // @match *://*.zhihu.com/*
  8. // @require https://code.jquery.com/jquery-3.6.0.min.js
  9. // @grant GM_info
  10. // @grant GM_download
  11. // @grant GM_openInTab
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_xmlhttpRequest
  15. // @license MIT
  16. // ==/UserScript==
  17. var $ = $ || window.$; //获得jquery的$标识符
  18. const window_url = window.location.href;
  19. const window_host = window.location.host;
  20. (function () {
  21. "use strict";
  22. window.getFileName = (url) => {
  23. var list = url.split("/");
  24. return list[list.length - 1];
  25. };
  26. window.downloadImage = (url) => {
  27. const x = new XMLHttpRequest();
  28. x.open("GET", url, true);
  29. x.responseType = "blob";
  30. x.onload = function (e) {
  31. const url = window.URL.createObjectURL(x.response);
  32. const a = document.createElement("a");
  33. a.href = url;
  34. a.target = "_blank";
  35. a.download = getFileName(url);
  36. a.click();
  37. a.remove();
  38. };
  39. x.send();
  40. };
  41. if (window_url.indexOf("zhihu.com") != -1) {
  42. $("body").append(
  43. "<style>.pic-div{position: relative;}.V5NKm5Fdiqhmnxlq6ndg0g=={display:none !important;}.download-button{backdrop-filter: saturate(180%) blur(20px);background:rgba(222, 222, 222, 0.3);border-radius: 50px;padding:7px;display: inline-block;position: absolute;bottom:12px;font-size: 12px;color:#fff;left:12px;}</style>"
  44. );
  45. setInterval(function () {
  46. $(".RichContent-inner img").each(function () {
  47. var token = $(this).attr("data-original-token");
  48. $(this).attr("src", "https://pic1.zhimg.com/" + token + ".png");
  49. });
  50. $(".RichContent-inner img").each(function () {
  51. var parentDom = $(this).parent();
  52. parentDom.css("position", "relative");
  53. var downloadButtonDom = parentDom.find(".download-button");
  54. if (downloadButtonDom.length == 0) {
  55. var originUrl = parentDom.find("img").attr("src");
  56. var dom = $(
  57. `<a class="download-button" href="javascript:void(0)">下载原图</span>`
  58. );
  59. dom.click(function () {
  60. downloadImage(originUrl);
  61. });
  62. parentDom.append(dom);
  63. }
  64. });
  65. }, 100);
  66. }
  67. })();

QingJ © 2025

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