您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
导出“想看”和“看过”,进入这两个页面的第一页点击右上角的“开始导出”即可,导出为格式为 JSON。
当前为
// ==UserScript== // @name JavDB 收藏导出 // @namespace https://gist.github.com/nini22P/021f2db060aab1785151d1a0c142714a // @version 1 // @description 导出“想看”和“看过”,进入这两个页面的第一页点击右上角的“开始导出”即可,导出为格式为 JSON。 // @match https://javdb.com/users/* // @grant GM_xmlhttpRequest // @grant GM_listValues // @license MIT // ==/UserScript== let allVideoTitles = JSON.parse(localStorage.getItem('videoTitles')) || []; let allowExport = JSON.parse(localStorage.getItem('allowExport')) || false; let exportButton = null; function extractVideoTitles() { const videoTitleElements = document.querySelectorAll('.video-title'); const videoTitles = Array.from(videoTitleElements).map((element) => { const title = element.textContent.trim(); // Remove leading and trailing whitespace const [id, ...titleWords] = title.split(' '); // Split the title into ID and title words const formattedTitle = titleWords.join(' '); // Join the title words back together return { id, title: formattedTitle }; }); return videoTitles; } function scrapeAllPages() { const videoTitles = extractVideoTitles(); allVideoTitles = allVideoTitles.concat(videoTitles); localStorage.setItem('videoTitles', JSON.stringify(allVideoTitles)); // Save the video titles to local storage const nextPageButton = document.querySelector('.pagination-next'); if (nextPageButton) { nextPageButton.click(); setTimeout(() => scrapeAllPages(), 2000); // Wait for 2 seconds before scraping again } else { exportVideoTitles(); } } function exportVideoTitles() { allowExport = false; localStorage.setItem('allowExport', JSON.stringify(allowExport)); // Disable export after exporting allVideoTitles.sort((a, b) => a.id.localeCompare(b.id)); // Sort the video titles by ID const json = JSON.stringify(allVideoTitles); const jsonBlob = new Blob([json], { type: 'application/json' }); const jsonUrl = URL.createObjectURL(jsonBlob); const downloadLink = document.createElement('a'); let fileName = ''; if (window.location.href.includes('/watched_videos')) { fileName = 'watched_videos' } else if (window.location.href.includes('/want_watch_videos')) { fileName = 'want_watch_videos' } downloadLink.href = jsonUrl; downloadLink.download = `${fileName}.json`; document.body.appendChild(downloadLink); downloadLink.click(); localStorage.removeItem('videoTitles'); // Remove the video titles from local storage after exporting exportButton.textContent = '导出完毕'; // Update the export button text } function startExport() { allowExport = true; localStorage.setItem('allowExport', JSON.stringify(allowExport)); // Enable export exportButton.textContent = '导出中...'; // Update the export button text scrapeAllPages(); } function createExportButton() { const navbarEnd = document.querySelector('.navbar-end'); exportButton = document.createElement('button'); exportButton.textContent = '开始导出'; exportButton.addEventListener('click', startExport); navbarEnd.appendChild(exportButton); } if (window.location.href.includes('/watched_videos') || window.location.href.includes('/want_watch_videos')) { createExportButton(); if (allowExport) { startExport(); } }