feat: 评论间隔随机化 v1.7.6
- 每条评论之间在设定范围内随机等待(默认1~2分钟,可自定义,支持小数) - 进度条实时倒计时显示剩余秒数,可随时停止 - 填0则不等待
This commit is contained in:
1 parent
8193e6c0c5
commit
2e97e62210
7 files changed
+179
-8
No files matched your search
@@ -12,6 +12,7 @@ class AutoCommentManager {
|
||||
|
||||
async init() {
|
||||
await this.loadClickMode(); // 加载点击模式设置
|
||||
await this.loadDelayConfig(); // 加载评论间隔设置
|
||||
await this.loadRegion(); // 加载按地区搜索设置
|
||||
await this.loadApiKey(); // 加载API密钥
|
||||
await this.loadModelConfig(); // 加载自定义模型配置
|
||||
@@ -79,6 +80,16 @@ class AutoCommentManager {
|
||||
this.saveClickMode(e.target.checked);
|
||||
});
|
||||
|
||||
// 评论间隔:输入即保存
|
||||
['delay-min', 'delay-max'].forEach((id) => {
|
||||
const input = document.getElementById(id);
|
||||
if (input) {
|
||||
input.addEventListener('input', () => {
|
||||
this.saveDelayConfig();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 评论方式选择(固定评论池 / 自定义文字 / 图片 / AI 按笔记生成)
|
||||
document.querySelectorAll('input[name="comment-mode"]').forEach((radio) => {
|
||||
radio.addEventListener('change', (e) => {
|
||||
@@ -466,6 +477,44 @@ class AutoCommentManager {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载评论间隔(分钟,默认 1~2 分钟随机)
|
||||
async loadDelayConfig() {
|
||||
try {
|
||||
const result = await chrome.storage.local.get(['commentDelayMin', 'commentDelayMax']);
|
||||
const min = Number(result.commentDelayMin);
|
||||
const max = Number(result.commentDelayMax);
|
||||
const minInput = document.getElementById('delay-min');
|
||||
const maxInput = document.getElementById('delay-max');
|
||||
if (minInput) minInput.value = Number.isFinite(min) && min >= 0 ? min : 1;
|
||||
if (maxInput) maxInput.value = Number.isFinite(max) && max >= 0 ? max : 2;
|
||||
console.log('加载评论间隔:', minInput?.value, '~', maxInput?.value, '分钟');
|
||||
} catch (error) {
|
||||
console.error('加载评论间隔失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 保存评论间隔
|
||||
async saveDelayConfig() {
|
||||
try {
|
||||
const minInput = document.getElementById('delay-min');
|
||||
const maxInput = document.getElementById('delay-max');
|
||||
let min = Number(minInput?.value);
|
||||
let max = Number(maxInput?.value);
|
||||
if (!Number.isFinite(min) || min < 0) min = 1;
|
||||
if (!Number.isFinite(max) || max < 0) max = 2;
|
||||
if (max < min) {
|
||||
// 自动纠正顺序
|
||||
[min, max] = [max, min];
|
||||
if (minInput) minInput.value = min;
|
||||
if (maxInput) maxInput.value = max;
|
||||
}
|
||||
await chrome.storage.local.set({ commentDelayMin: min, commentDelayMax: max });
|
||||
console.log('保存评论间隔:', min, '~', max, '分钟');
|
||||
} catch (error) {
|
||||
console.error('保存评论间隔失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 保存API密钥
|
||||
async saveApiKey(apiKey) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user