Skip to content

Commit 820c35b

Browse files
committed
feat(115-helper): 单文件夹查重使用随机颜色高亮
1 parent d2b422c commit 820c35b

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

legacy/packages/115-helper/115-helper.user.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ==UserScript==
33
// @name 115小助手
44
// @namespace https://github.com/maomao1996/tampermonkey-scripts
5-
// @version 1.8.3
5+
// @version 1.8.4
66
// @description 网盘顶部菜单栏添加链接任务和云下载、SHA1 快速查重(新页面打开)、SHA1 自动查重、删除空文件夹、一键搜(快捷搜索)、SHA1 查重列表支持选中第一个元素和悬浮菜单展示、搜索列表支持悬浮菜单展示、列表显示文件 SHA1 信息、关闭网盘侧边栏、悬浮菜单移除图标、悬浮菜单支持新标签页打开文件夹、加速转码
77
// @icon https://115.com/favicon.ico
88
// @author maomao1996
@@ -318,6 +318,21 @@
318318
return new Promise((resolve) => setTimeout(resolve, timeout))
319319
}
320320

321+
/**
322+
* 工具方法 - 生成随机 rgba 颜色
323+
* 生成类似 rgba(199, 237, 204, 0.7) 的随机颜色
324+
* 保持绿色为主色调,其他颜色适当随机
325+
*/
326+
const getRandomRgba = (): string => {
327+
// 保持绿色为主色调
328+
const g = random(220, 255)
329+
// 红色和蓝色适当随机
330+
const r = random(120, 240)
331+
const b = random(120, 240)
332+
333+
return `rgba(${r}, ${g}, ${b}, 0.39)`
334+
}
335+
321336
/**
322337
* 工具方法 - 获取样式
323338
*/
@@ -356,7 +371,7 @@
356371
* 小助手相关样式
357372
*/
358373
/*css*/ `.mm-quick-operation{margin-left: 12px;padding: 0 4px;white-space: nowrap;}`,
359-
/*css*/ `.list-contents .active::before, .list-thumb .active{background: rgba(199, 237, 204, 0.7)!important;}`,
374+
/*css*/ `.list-contents .active::before, .list-thumb .active{background: var(--repeat-color, rgba(199, 237, 204, 0.7))!important;}`,
360375
// 链接任务
361376
/*css*/ `.left-tvf .btn-upload{z-index: 1;}`,
362377
// 列表显示文件SHA1信息
@@ -764,10 +779,10 @@
764779
$li.each(function () {
765780
const sha1 = $(this).attr('sha1')
766781
if (!SHA1_MAP[sha1]) {
767-
SHA1_MAP[sha1] = 1
782+
SHA1_MAP[sha1] = getRandomRgba()
768783
} else {
769784
repeatCount++
770-
$(this).addClass('active')
785+
$(this).addClass('active')[0].style.setProperty('--repeat-color', SHA1_MAP[sha1])
771786
if (isSelected) {
772787
$(this).find('.checkbox').trigger('click')
773788
}

0 commit comments

Comments
 (0)