Sleazy Fork is available in English.

JavDB图片下载

Download all images from a JavDB gallery page

  1. // ==UserScript==
  2. // @name JavDB图片下载
  3. // @namespace http://tampermonkey.net/
  4. // @version 1
  5. // @description Download all images from a JavDB gallery page
  6. // @author Anonymous
  7. // @match https://javdb.com/v/*
  8. // @grant GM_download
  9. // @grant GM_notification
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Function to download an image
  17. function downloadImage(url, filename) {
  18. GM_download({
  19. url: url,
  20. name: filename,
  21. saveAs: false
  22. });
  23. }
  24.  
  25. // Function to download all images
  26. function downloadAllImages() {
  27. // 获取页面的 ID
  28. const pageId = window.location.pathname.split('/v/')[1];
  29.  
  30. // 检查页面 ID 是否有效
  31. if (!pageId) {
  32. GM_notification({
  33. text: '无法获取页面 ID。',
  34. title: '下载失败',
  35. timeout: 4000
  36. });
  37. return;
  38. }
  39.  
  40. // 从页面 ID 提取前两位的小写字母作为文件夹前缀
  41. const prefix = pageId.slice(0, 2).toLowerCase(); // 获取页面 ID 的前两位小写字母
  42. const baseUrl = `https://c0.jdbstatic.com/samples/${prefix}/${pageId}_l_`;
  43.  
  44. // 通过页面中的图片数量动态设置总图像数
  45. const totalImages = 50; // 假设有 50 张图片,你可以动态调整这个值
  46.  
  47. let images = [];
  48.  
  49. // 生成图片的 URL
  50. for (let i = 0; i < totalImages; i++) { // 从 0 开始
  51. let imgUrl = `${baseUrl}${i}.jpg`;
  52. images.push(imgUrl);
  53. }
  54.  
  55. // 下载每一张图片
  56. images.forEach((imgUrl, index) => {
  57. let filename = `image_${index}.jpg`;
  58. downloadImage(imgUrl, filename);
  59. });
  60.  
  61. // 提醒用户下载完成
  62. GM_notification({
  63. text: '所有图片已开始下载。',
  64. title: '下载完成',
  65. timeout: 4000
  66. });
  67. }
  68.  
  69. // 创建一个按钮来触发下载所有图片
  70. const downloadButton = document.createElement('button');
  71. downloadButton.textContent = 'Download All Images';
  72. downloadButton.style.position = 'fixed';
  73. downloadButton.style.top = '50%'; // 垂直居中
  74. downloadButton.style.right = '10px'; // 右侧
  75. downloadButton.style.transform = 'translateY(-50%)'; // 使其精确居中
  76. downloadButton.style.padding = '10px';
  77. downloadButton.style.backgroundColor = '#007bff';
  78. downloadButton.style.color = 'white';
  79. downloadButton.style.border = 'none';
  80. downloadButton.style.borderRadius = '5px';
  81. downloadButton.style.cursor = 'pointer';
  82. downloadButton.style.zIndex = '9999'; // 确保它在其他元素上方
  83. downloadButton.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)'; // 增加阴影效果
  84.  
  85. // 添加点击事件来触发下载过程
  86. downloadButton.addEventListener('click', downloadAllImages);
  87.  
  88. // 将按钮添加到页面中
  89. document.body.appendChild(downloadButton);
  90. })();