feat: 初步开发一些特性

This commit is contained in:
meishibiezb
2026-05-01 21:13:16 +08:00
parent a25145638f
commit a6b86934af
6 changed files with 527 additions and 107 deletions

View File

@@ -1,6 +1,37 @@
import { showPageMarker } from "@/components/page-marker";
import { PinCollector } from "#imports";
export default defineContentScript({
matches: ['*://*.google.com/*'],
matches: ['*://*.huaban.com/*'],
runAt: 'document_idle',
main() {
console.log('Hello content.');
sayHello();
const collector = new PinCollector();
// 首次加载自动收集并存储
const pins = collector.collect();
if (pins.length > 0) {
collector.saveToStorage();
}
// 允许 popup 主动触发重新收集
browser.runtime.onMessage.addListener((msg, sender, sendResponse) => {
if (msg.type === 'COLLECT_PINS') {
const updatedPins = collector.collect();
sendResponse({ success: true, count: updatedPins.length });
return true; // 异步响应
}
});
},
});
function sayHello() {
console.log('检测到花瓣网!', window.location.href);
console.log('这个插件是一个用于自动收集图片的插件。');
showPageMarker({
text: '检测到花瓣网!插件已启动',
position: 'top-right',
backgroundColor: 'rgba(34, 139, 34, 0.9)',
closable: true, // 用户可点击 × 关闭
autoRemoveSeconds: 10,
});
}