Oosayam commited on
Commit
2a1933c
·
verified ·
1 Parent(s): a7b8099

Upload Tag Extractor with Auto Scroll-1.1.user.js

Browse files
Tag Extractor with Auto Scroll-1.1.user.js ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // ==UserScript==
2
+ // @name Tag Extractor with Auto Scroll
3
+ // @namespace http://tampermonkey.net/
4
+ // @version 1.1
5
+ // @description Extract tags from Gelbooru, Danbooru, and Rule34, copy to clipboard, and add auto-scroll functionality
6
+ // @author Your Name
7
+ // @match https://gelbooru.com/*
8
+ // @match https://danbooru.donmai.us/*
9
+ // @match https://rule34.xxx/*
10
+ // @grant GM_setClipboard
11
+ // ==/UserScript==
12
+
13
+ (function() {
14
+ 'use strict';
15
+
16
+ // 創建按鈕的函數
17
+ function createButton(id, text, color, topOffset) {
18
+ let button = document.createElement('button');
19
+ button.id = id;
20
+ button.innerText = text;
21
+ button.style.position = 'fixed';
22
+ button.style.top = `${topOffset}px`;
23
+ button.style.right = '10px';
24
+ button.style.zIndex = 1000;
25
+ button.style.padding = '10px';
26
+ button.style.backgroundColor = color;
27
+ button.style.color = '#fff';
28
+ button.style.border = 'none';
29
+ button.style.borderRadius = '5px';
30
+ button.style.cursor = 'pointer';
31
+ return button;
32
+ }
33
+
34
+ // 自動滾動的邏輯
35
+ let isScrolling = false;
36
+ let scrollInterval;
37
+
38
+ function startAutoScroll() {
39
+ if (!isScrolling) {
40
+ isScrolling = true;
41
+ scrollInterval = setInterval(() => {
42
+ window.scrollBy(0, 150); // 每次滾動 50 像素
43
+ }, 50); // 每 100 毫秒滾動一次
44
+ }
45
+ }
46
+
47
+ function stopAutoScroll() {
48
+ if (isScrolling) {
49
+ isScrolling = false;
50
+ clearInterval(scrollInterval);
51
+ }
52
+ }
53
+
54
+ // 創建自動滾動按鈕
55
+ const autoScrollButton = createButton('auto-scroll-button', 'Auto Scroll', '#4CAF50', 60);
56
+ document.body.appendChild(autoScrollButton);
57
+
58
+ // 自動滾動按鈕的事件監聽器
59
+ autoScrollButton.addEventListener('click', () => {
60
+ if (isScrolling) {
61
+ stopAutoScroll();
62
+ autoScrollButton.innerText = 'Auto Scroll';
63
+ autoScrollButton.style.backgroundColor = '#4CAF50';
64
+ } else {
65
+ startAutoScroll();
66
+ autoScrollButton.innerText = 'Stop Scroll';
67
+ autoScrollButton.style.backgroundColor = '#f44336';
68
+ }
69
+ });
70
+
71
+ // 原有的標籤提取邏輯
72
+ if (window.location.href.includes('gelbooru.com')) {
73
+ let button = createButton('gelbooru-button', 'Extract Tags', '#ff5722', 10);
74
+ document.body.appendChild(button);
75
+
76
+ button.addEventListener('click', () => {
77
+ let images = document.querySelectorAll('img[title]');
78
+ let tags = Array.from(images).map(img => img.getAttribute('title'));
79
+ let tagsString = tags.join('\n').replace(/ /g, ', ');
80
+ GM_setClipboard(tagsString);
81
+ alert('Tags have been copied to the clipboard!');
82
+ });
83
+ } else if (window.location.href.includes('danbooru.donmai.us')) {
84
+ let button = createButton('danbooru-button', 'Copy Tag Data', '#007bff', 10);
85
+ document.body.appendChild(button);
86
+
87
+ button.addEventListener('click', function() {
88
+ var articles = document.querySelectorAll('article.post-preview');
89
+ var data = [];
90
+
91
+ articles.forEach(function(article) {
92
+ var tags = article.getAttribute('data-tags');
93
+ var rating = article.getAttribute('data-rating');
94
+
95
+ switch (rating) {
96
+ case 'e':
97
+ rating = 'explicit';
98
+ break;
99
+ case 'q':
100
+ rating = 'questionable';
101
+ break;
102
+ case 'g':
103
+ rating = 'general';
104
+ break;
105
+ case 's':
106
+ rating = 'safe';
107
+ break;
108
+ default:
109
+ rating = 'unknown';
110
+ }
111
+
112
+ tags = tags.replace(/ /g, ', ');
113
+ data.push(`${tags}; ${rating}`);
114
+ });
115
+
116
+ var dataStr = data.join('\n');
117
+ GM_setClipboard(dataStr);
118
+ alert('Tag data copied to clipboard!');
119
+ });
120
+ } else if (window.location.href.includes('rule34.xxx')) {
121
+ let button = createButton('rule34-button', 'Copy Tags', '#ff4500', 10);
122
+ document.body.appendChild(button);
123
+
124
+ button.addEventListener('click', function() {
125
+ var thumbs = document.querySelectorAll('span.thumb');
126
+ var data = [];
127
+
128
+ thumbs.forEach(function(thumb) {
129
+ var img = thumb.querySelector('img');
130
+ if (img) {
131
+ var tags = img.getAttribute('title');
132
+ if (tags) {
133
+ tags = tags.trim().replace(/ {2,}/g, ' ').replace(/ /g, ', ');
134
+ data.push(tags);
135
+ }
136
+ }
137
+ });
138
+
139
+ var dataStr = data.join('\n');
140
+ GM_setClipboard(dataStr);
141
+ alert('Tag data copied to clipboard!');
142
+ });
143
+ }
144
+ })();