feat(extension): add Firefox browser extension and native integration

- Implement Firefox extension to intercept downloads and scrape selected links via context menus
- Create LocalExtensionServer over TCP (localhost:6412) to receive links from the extension
- Automatically package extension to firelink.xpi in create_app_bundle.sh
- Add Integrations tab in SettingsView with one-click installer for Firefox variants
- Modify ContentView and TrayMenuView to automatically open the Add Downloads window on extension trigger
This commit is contained in:
nimbold
2026-06-03 22:15:12 +03:30
parent 93e6e11939
commit 0ddea52db8
14 changed files with 840 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
// content.js
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === "extractSelectionLinks") {
const selection = window.getSelection();
if (!selection || selection.rangeCount === 0) {
sendResponse({ links: [] });
return;
}
const links = new Set();
// Extract a tags from the selected range
for (let i = 0; i < selection.rangeCount; i++) {
const range = selection.getRangeAt(i);
const container = document.createElement("div");
container.appendChild(range.cloneContents());
const anchors = container.querySelectorAll("a");
anchors.forEach(a => {
if (a.href) {
// ensure the link is a full URL by using the current document's base URI if it's relative
try {
const url = new URL(a.getAttribute('href'), document.baseURI).href;
links.add(url);
} catch (e) {
// Invalid URL, fallback to just checking if it looks like a valid protocol
if (a.href.startsWith("http")) {
links.add(a.href);
}
}
}
});
}
sendResponse({ links: Array.from(links) });
}
});