-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
509 lines (442 loc) · 17.8 KB
/
index.html
File metadata and controls
509 lines (442 loc) · 17.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
<!-- 禁止倒卖、商用,版权归HXDD233@qq.com所有,如有侵权会进行合法追究 -->
<!DOCTYPE html>
<!-- saved from url=(0041)file:///C:/Users/Mashiro/Downloads/2.html -->
<html>
<title>提取链接和书引号中的文本-wan0ge</title>
<link rel="icon" type="image/svg+xml" href="default-icon.svg" id="favicon">
<!-- <link rel="preload" href='image/woff2/MiSans-Regular.woff2' as="font" crossorigin="anonymous"> -->
<!-- <link rel="preload" href='image/woff2/MiSans-Semibold.woff2' as="font" crossorigin="anonymous"> -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<!-- <meta http-equiv="Cache-Control" content="max-age=20"> -->
<style>
/*@font-face {
font-family: 'MiSans-Regular';
src: url('image/woff2/MiSans-Regular.woff2') format('woff2');
font-weight:400;
font-display:swap;
crossorigin: anonymous; /* 添加 crossorigin 属性 */
}
/*@font-face {
font-family: 'MiSans-Semibold';
src: url('image/woff2/MiSans-Semibold.woff2') format('woff2');
font-weight:700;
font-display:swap;
crossorigin: anonymous; /* 添加 crossorigin 属性 */
}
@font-face {
font-family: Emoji;
src: local("Apple Color Emojiji"), local("Segoe UI Emoji"), local("Segoe UI Symbol"), local("Noto Color Emoji");
unicode-range: U+1F000-1F644, U+203C-3299;
}
body {
font-family: /*'MiSans-Regular',*/system-ui, —apple-system, Segoe UI, Rototo, Emoji, Helvetica, Arial, sans-serif;
}
body {
/* font-family: 'Roboto', sans-serif;*/
/* 这里使用了字体 */
background-color: #f9f9f9;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-image: url('image/别当欧尼酱@onimai_anime.jpg');
)
;
}
.container {
width: 20%;
height: 60%;
border-radius: 18px;
background-color: #fff3ecbe;
box-shadow: 0 0px 0px rgba(0, 0, 0, 0.1);
padding: 32px;
display: flex;
backdrop-filter: blur(50px);
flex-direction: column;
align-items: center;
transition: 0.4s;
transition-delay: 120s;
}
.container:hover {
width: 40%;
height: 70%;
background-color: #fff3ec;
border-radius: 18px;
box-shadow: 0 4px 36px rgba(0, 0, 0, 0.1);
padding: 32px;
display: flex;
flex-direction: column;
align-items: center;
transition: 0.4s;
transition-delay: 0s;
}
h2 {
color: #333;
text-align: center;
margin-bottom: 6px;
}
textarea {
width: 100%;
padding: 12px;
box-sizing: border-box;
border: 0px solid #ccc;
border-radius: 5px;
background-color: #ffffff;
resize: none;
transition: 0.3s;
overflow-y: hidden;
transition-delay: 10s;
font-family: /*'MiSans-Regular',*/system-ui, —apple-system, Segoe UI, Rototo, Emoji, Helvetica, Arial, sans-serif;
}
textarea:focus{
outline: none;
border: 3px solid #f5b7ba;
animation-duration: 1s;
transition: 0.3s;
transition-delay: 0s;
}
button {
background-color: #ffffff;
color: #2b2b2b;
padding: 12px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 10px;
transition: background-color 0.3s;
width: 30%;
/*font-family: 'MiSans-Regular'
/* 这里使用了字体 */
}
button:hover {
background-color: #f5b7ba;
color: #ffffff;
}
.output {
width: 100%;
margin-top: 10px; /* 增加上下间距 */
}
.output p .outputLinks {
color: #333;
margin: 10px 10px; /* 增加上下间距 */
background-color: #ffffff;
border-radius: 5px;
}
.button-container {
display: flex;
justify-content: space-between;
width: 100%;
}
#autoCopyContainer {
display: flex;
justify-content: flex-end;
width: 100%;
height: 50px;
background-color: #ffffff;
text-align: center;
margin: 10px 10px; /* 增加上下间距 */
align-items: center;
justify-content: center;
/* font-family: 'Noto Sans SC','STHeiti Light','Source Han Sans CN','SimHei', "Times New Roman",Georgia,Serif,SimHei;*/
/* 这里使用了字体 */
border-radius: 5px;
}
#copyStatusContainer {
width: 100%;
text-align: center;
margin-top: 20px; /* 增加上下间距 */
}
#footer {
position: absolute;
bottom: 20px;
right: 20px;
color: #777;
}
/* 在 CSS 样式中添加新的样式 */
.preview-container {
position: absolute;
top: 50px;
right: 20px;
width: 400px;
height: 50px;
background-color: #f9f9f9;
border: 1px solid #ccc;
padding: 10px;
display: none; /* 默认隐藏 */
overflow: auto;
}
</style>
</head>
<body>
<div class="container">
<h2>提取链接和书引号中的文本</h2>
<p>在下方粘贴文本:</p>
<textarea id="inputText" rows="6" oninput="extractContent()" onmouseenter="forceActivateInput()" onfocus="forceActivateInput()"></textarea>
<button onclick="togglePreview()" id="previewButton">显示预览</button>
<div class="preview-container" id="previewContainer" style="display: none;"></div>
<div class="button-container">
<button onclick="copyLinks()">复制链接</button>
<button onclick="copyText()">复制文本</button>
<button onclick="clearText()">清空文本</button>
</div>
<div class="output">
<p><strong>提取的链接:</strong></p>
<p id="outputLinks" style="background-color: #ffffff;width: 100%;height: 70px;padding-top: 0px;transition: 0.5s;border-radius: 5px;text-align: center;justify-content: center;line-height: 70px;"></p>
<p><strong>提取的文本:</strong></p>
<p id="outputText" style="
background-color: #ffffff;
width: 100%;
height: 50px;
padding-top: 0px;
transition: 0.5s;
border-radius: 5px;
text-align: center;
justify-content: center;
margin-bottom: 100px;
margin: 0 auto;
line-height: 50px;
"></p>
</div>
<div id="autoCopyContainer">
<label for="autoCopyCheckbox">自动复制链接</label>
<input type="checkbox" id="autoCopyCheckbox" onchange="toggleAutoCopy()">
</div>
<div id="autoClearContainer">
<label for="autoClearCheckbox">复制链接后清空文本</label>
<input type="checkbox" id="autoClearCheckbox" onchange="toggleAutoClear()">
</div>
<div id="copyStatusContainer">
<p id="copyStatus"></p>
</div>
</div>
<div id="footer">
by:
鸽(与Ai对话)/
MashiroHut(UI设计)/
ChatGPT(代码提供)
</div>
<script>
// 随机显示网页图标
// Array of icon filenames (SVG format)
var icons = [
"https://github.com/wan0ge/extract-pure-links/raw/master/image/主网页图标-@一个人的鱼鱼鱼.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/主网页图标-@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/冰棍@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/冰棍@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/啤酒2@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/啤酒@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/奶酪@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/寿司@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/披萨@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/柠檬@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/水杯@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/汉堡包@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/汽水@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/牛奶@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/瓶装果汁@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/甜筒冰淇淋@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/生日蛋糕@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/碗筷@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/萝卜@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/锥形高脚杯@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/面包2@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/面包@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/餐盘盖@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/高脚杯@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/鱼@爱嗦辣条的射鸡师.svg",
"https://github.com/wan0ge/extract-pure-links/raw/master/image/@爱嗦辣条的射鸡师/鸡腿@爱嗦辣条的射鸡师.svg",
// Add more icon filenames as needed
];
// Function to randomly select an icon from the array
function getRandomIcon() {
var randomIndex = Math.floor(Math.random() * icons.length);
return icons[randomIndex];
}
// Update the favicon link with a random icon on page load
document.addEventListener("DOMContentLoaded", function() {
var randomIcon = getRandomIcon();
document.getElementById("favicon").href = randomIcon;
});
// 从本地存储中获取开关状态
let autoCopyEnabled = localStorage.getItem("autoCopyEnabled") === "true";
let autoClearEnabled = localStorage.getItem("autoClearEnabled") === "true";
let previousText = "";
// 设置开关状态
function setSwitchesState() {
document.getElementById("autoCopyCheckbox").checked = autoCopyEnabled;
document.getElementById("autoClearCheckbox").checked = autoClearEnabled;
}
// 保存开关状态到本地存储
function saveSwitchesState() {
localStorage.setItem("autoCopyEnabled", autoCopyEnabled);
localStorage.setItem("autoClearEnabled", autoClearEnabled);
}
// 在页面加载完成后设置开关状态
document.addEventListener("DOMContentLoaded", function () {
setSwitchesState();
});
function extractContent() {
var inputText = document.getElementById("inputText").value;
var linkRegex = /((https?|ftp):\/\/[^\s/$.?#].[^\s]*)/g;
var matchedLinks = inputText.match(linkRegex);
if (matchedLinks) {
document.getElementById("outputLinks").innerHTML = matchedLinks.join("<br>");
if (autoCopyEnabled && inputText !== previousText) {
copyLinks();
previousText = inputText;
}
} else {
document.getElementById("outputLinks").innerHTML = "未发现链接";
}
var textRegex = /《([^》]*)》/g;
var matchedText = inputText.match(textRegex);
if (matchedText) {
var extractedText = matchedText.map(function(item) {
return item.replace(/《|》/g, '');
});
document.getElementById("outputText").innerHTML = extractedText.join("<br>");
} else {
document.getElementById("outputText").innerHTML = "未发现匹配文本";
}
}
function copyLinks() {
var outputLinks = document.getElementById("outputLinks").innerText;
if (document.hasFocus()) {
navigator.clipboard.writeText(outputLinks)
.then(() => {
document.getElementById("copyStatus").innerHTML = "已复制链接: " + outputLinks;
})
.catch((error) => {
console.error('Failed to copy: ', error);
});
} else {
console.error('Document is not focused');
}
}
function autoCopy() {
if (autoCopyEnabled) {
copyLinks();
extractContent();
}
}
function copyText() {
var outputText = document.getElementById("outputText").innerText;
navigator.clipboard.writeText(outputText);
document.getElementById("copyStatus").innerHTML = "已复制文本: " + outputText;
}
function clearText() {
document.getElementById("inputText").value = "";
document.getElementById("outputLinks").innerHTML = "";
document.getElementById("outputText").innerHTML = "";
}
<!-- 在toggleAutoCopy和toggleAutoClear函数中调用saveSwitchesState -->
function toggleAutoCopy() {
autoCopyEnabled = !autoCopyEnabled;
saveSwitchesState();
}
function toggleAutoClear() {
autoClearEnabled = !autoClearEnabled;
saveSwitchesState();
}
// 在复制链接后执行清除文本框内容的操作
function copyLinks() {
var outputLinks = document.getElementById("outputLinks").innerText;
if (document.hasFocus()) {
navigator.clipboard.writeText(outputLinks)
.then(() => {
document.getElementById("copyStatus").innerHTML = "已复制链接: " + outputLinks;
var autoClearCheckbox = document.getElementById("autoClearCheckbox");
var autoClearEnabled = autoClearCheckbox.checked;
if (autoClearEnabled) {
setTimeout(() => {
document.getElementById("inputText").value = ""; // 2秒后清空文本框
}, 2000); // 延迟2秒执行
}
})
.catch((error) => {
console.error('Failed to copy: ', error);
});
} else {
console.error('Document is not focused');
}
}
// 在页面加载完成后为复选框添加事件监听器
document.addEventListener('DOMContentLoaded', function() {
setSwitchesState();
var autoClearCheckbox = document.getElementById("autoClearCheckbox");
// 监听复选框的改变
autoClearCheckbox.addEventListener('change', function() {
autoClearEnabled = autoClearCheckbox.checked;
saveSwitchesState();
});
// 复选框初始化时手动触发一次change事件,确保初始状态被记录
autoClearCheckbox.dispatchEvent(new Event('change'));
});
function copyLinks() {
var outputLinks = document.getElementById("outputLinks").innerText;
if (document.hasFocus()) {
navigator.clipboard.writeText(outputLinks)
.then(() => {
document.getElementById("copyStatus").innerHTML = "已复制链接: " + outputLinks;
var autoClearCheckbox = document.getElementById("autoClearCheckbox");
var autoClearEnabled = autoClearCheckbox.checked;
if (autoClearEnabled) {
setTimeout(() => {
document.getElementById("inputText").value = ""; // 2秒后清空文本框
}, 1000); // 延迟2秒执行
}
})
.catch((error) => {
console.error('Failed to copy: ', error);
});
} else {
console.error('Document is not focused');
}
}
let lastPastedValue = ""; // 存储最后一次粘贴的内容
// 监听粘贴事件
document.addEventListener('paste', function(event) {
// 获取粘贴的内容
var pastedText = (event.clipboardData || window.clipboardData).getData('text');
if (pastedText && pastedText !== lastPastedValue) {
lastPastedValue = pastedText;
// 显示预览内容
var previewContainer = document.getElementById("previewContainer");
<!-- previewContainer.style.display = "block"; -->
previewContainer.textContent = lastPastedValue;
}
});
function togglePreview() {
var previewContainer = document.getElementById("previewContainer");
// 切换预览区域的显示状态
if (previewContainer.style.display === "block") {
previewContainer.style.display = "none";
} else {
var inputText = document.getElementById("inputText").value;
previewContainer.style.display = "block";
}
updatePreviewButtonText(); // 更新按钮上的文本内容
}
function updatePreviewButtonText() {
var previewContainer = document.getElementById("previewContainer");
var previewButton = document.getElementById("previewButton");
// 更新按钮上的文本内容
if (previewContainer.style.display === "block") {
previewButton.textContent = "关闭预览";
} else {
previewButton.textContent = "显示预览";
}
}
var inputTextArea = document.getElementById("inputText");
function forceActivateInput() {
inputTextArea.focus(); // 在输入框获取焦点时再次强制激活
}
</script>
<!-- 禁止倒卖、商用,版权归HXDD233@qq.com所有,如有侵权会进行合法追究 -->
</body></html>