// ==UserScript== // @name Arca Live Image and Video Downloader // @name:zh-TW Arca Live 圖片與影片下載器 // @name:zh-CN Arca Live 图片和视频下载器 // @namespace http://tampermonkey.net/ // @version 1.7 // @description Supports downloading images, GIFs, MP4s, and WEBMs from Arca Live posts (using GM_download to bypass CORS), and automatically names the files in the format: Board_PostNumber_0001~n // @description:zh-TW 支援下載 Arca Live 貼文中的圖片、GIF、MP4、WEBM(使用 GM_download 繞過 CORS)並自動命名為「板塊_編號_0001~n」格式。 // @description:zh-CN 支援下载 Arca Live 贴文中的图片、GIF、MP4、WEBM(使用 GM_download 绕过 CORS)并自动命名为「板块_编号_0001~n」格式。 // @author ChatGPT // @match https://arca.live/* // @grant GM_download // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/541242/Arca%20Live%20Image%20and%20Video%20Downloader.user.js // @updateURL https://update.greasyfork.icu/scripts/541242/Arca%20Live%20Image%20and%20Video%20Downloader.meta.js // ==/UserScript== (function () { 'use strict'; // 延遲用的 sleep 函數(毫秒) const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); // 等待 Arca Live 收藏按鈕出現,作為我們插入自訂按鈕的參考點 const waitForScrapButton = async () => { for (let i = 0; i < 50; i++) { const scrapBtn = document.querySelector('form#scrapForm > button.scrap-btn'); if (scrapBtn) return scrapBtn; await sleep(200); // 每次等待 200 毫秒 } return null; }; // 收集所有圖片與影片的網址(支援 JPG、PNG、GIF、MP4、WEBM) const collectMediaUrls = () => { const urls = new Set(); // 收集 標籤(含 data-src) document.querySelectorAll('.article-body img').forEach(img => { const src = img.getAttribute('data-src') || img.src; if (src) urls.add(src); }); // 收集