feat: url cleaner tool and extension update

This commit is contained in:
2026-02-27 06:11:12 +00:00
parent efe23a99ac
commit 7d989be27f
4 changed files with 37 additions and 2 deletions

View File

@@ -122,6 +122,17 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
return true;
}
if (request.action === 'writeClipboard') {
if (isSniffing) {
chrome.runtime.sendMessage({
target: 'offscreen',
type: 'write-clipboard',
data: request.content
}).catch(() => {});
}
return true;
}
if (request.type === 'clipboard-data' && request.target === 'background') {
// Received data from offscreen document
if (isSniffing && request.data && request.data !== lastClipboardContent) {

View File

@@ -46,6 +46,17 @@ window.addEventListener('message', (event) => {
// ignore
}
}
if (event.data.type === 'TOOLS_APP_CLIPBOARD_WRITE') {
try {
chrome.runtime.sendMessage({
action: 'writeClipboard',
content: event.data.content
});
} catch (e) {
console.warn('Tools App Extension: Write clipboard failed', e);
}
}
});
// Listen for messages from the Extension Background

View File

@@ -1,10 +1,11 @@
{
"manifest_version": 3,
"name": "Tools App Extension",
"version": "1.0",
"version": "1.1",
"description": "Browser extension for Tools App",
"permissions": [
"clipboardRead",
"clipboardWrite",
"offscreen",
"storage",
"alarms",

View File

@@ -42,12 +42,24 @@ setInterval(async () => {
}
}, 50);
// Listen for messages from background if we need to change behavior
// Listen for messages from background
chrome.runtime.onMessage.addListener((message) => {
if (message.target === 'offscreen') {
// Handle commands
if (message.type === 'play-sound') {
playNotificationSound();
} else if (message.type === 'write-clipboard') {
try {
const text = message.data;
if (text) {
textEl.value = text;
textEl.select();
document.execCommand('copy');
lastText = text; // Update internal state to avoid re-triggering update
}
} catch (e) {
console.error('Failed to write clipboard:', e);
}
}
}
});