Upload Tag Extractor with Auto Scroll-1.1.user.js
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144// ==UserScript==// @name Tag Extractor with Auto Scroll// @namespace http://tampermonkey.net/// @version 1.1// @description Extract tags from Gelbooru, Danbooru, and Rule34, copy to clipboard, and add auto-scroll functionality// @author Your Name// @match https://gelbooru.com/*// @match https://danbooru.donmai.us/*// @match https://rule34.xxx/*// @grant GM_setClipboard// ==/UserScript==
(function() { 'use strict';
// 創建按鈕的函數 function createButton(id, text, color, topOffset) { let button = document.createElement('button'); button.id = id; button.innerText = text; button.style.position = 'fixed'; button.style.top = `${topOffset}px`; button.style.right = '10px'; button.style.zIndex = 1000; button.style.padding = '10px'; button.style.backgroundColor = color; button.style.color = '#fff'; button.style.border = 'none'; button.style.borderRadius = '5px'; button.style.cursor = 'pointer'; return button; }
// 自動滾動的邏輯 let isScrolling = false; let scrollInterval;
function startAutoScroll() { if (!isScrolling) { isScrolling = true; scrollInterval = setInterval(() => { window.scrollBy(0, 150); // 每次滾動 50 像素 }, 50); // 每 100 毫秒滾動一次 } }
function stopAutoScroll() { if (isScrolling) { isScrolling = false; clearInterval(scrollInterval); } }
// 創建自動滾動按鈕 const autoScrollButton = createButton('auto-scroll-button', 'Auto Scroll', '#4CAF50', 60); document.body.appendChild(autoScrollButton);
// 自動滾動按鈕的事件監聽器 autoScrollButton.addEventListener('click', () => { if (isScrolling) { stopAutoScroll(); autoScrollButton.innerText = 'Auto Scroll'; autoScrollButton.style.backgroundColor = '#4CAF50'; } else { startAutoScroll(); autoScrollButton.innerText = 'Stop Scroll'; autoScrollButton.style.backgroundColor = '#f44336'; } });
// 原有的標籤提取邏輯 if (window.location.href.includes('gelbooru.com')) { let button = createButton('gelbooru-button', 'Extract Tags', '#ff5722', 10); document.body.appendChild(button);
button.addEventListener('click', () => { let images = document.querySelectorAll('img[title]'); let tags = Array.from(images).map(img => img.getAttribute('title')); let tagsString = tags.join('\n').replace(/ /g, ', '); GM_setClipboard(tagsString); alert('Tags have been copied to the clipboard!'); }); } else if (window.location.href.includes('danbooru.donmai.us')) { let button = createButton('danbooru-button', 'Copy Tag Data', '#007bff', 10); document.body.appendChild(button);
button.addEventListener('click', function() { var articles = document.querySelectorAll('article.post-preview'); var data = [];
articles.forEach(function(article) { var tags = article.getAttribute('data-tags'); var rating = article.getAttribute('data-rating');
switch (rating) { case 'e': rating = 'explicit'; break; case 'q': rating = 'questionable'; break; case 'g': rating = 'general'; break; case 's': rating = 'safe'; break; default: rating = 'unknown'; }
tags = tags.replace(/ /g, ', '); data.push(`${tags}; ${rating}`); });
var dataStr = data.join('\n'); GM_setClipboard(dataStr); alert('Tag data copied to clipboard!'); }); } else if (window.location.href.includes('rule34.xxx')) { let button = createButton('rule34-button', 'Copy Tags', '#ff4500', 10); document.body.appendChild(button);
button.addEventListener('click', function() { var thumbs = document.querySelectorAll('span.thumb'); var data = [];
thumbs.forEach(function(thumb) { var img = thumb.querySelector('img'); if (img) { var tags = img.getAttribute('title'); if (tags) { tags = tags.trim().replace(/ {2,}/g, ' ').replace(/ /g, ', '); data.push(tags); } } });
var dataStr = data.join('\n'); GM_setClipboard(dataStr); alert('Tag data copied to clipboard!'); }); }})();Tag Extractor with Auto Scroll-1.1.user.jsAdded+144