04/20 Update extension UI and functions: add item, form filler
This commit is contained in:
+26
-1
@@ -83,6 +83,16 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Content script requests navigating the popup to the generator view.
|
||||
if (msg.type === "OPEN_GENERATOR") {
|
||||
chrome.storage.session.set({ popup_nav: "generator" });
|
||||
chrome.action.openPopup().catch(() => {
|
||||
// openPopup() requires user gesture in some Chrome versions — fallback is a no-op.
|
||||
});
|
||||
sendResponse({ ok: true });
|
||||
return false;
|
||||
}
|
||||
|
||||
// No-op ping from popup — keeps the service worker alive while the browser
|
||||
// is open so chrome.storage.session is not wiped between popup openings.
|
||||
if (msg.type === "KEEPALIVE") {
|
||||
@@ -90,9 +100,24 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Popup signals vault cache was refreshed → re-check all tab badges.
|
||||
// Popup signals vault cache was refreshed → re-check badges AND forward
|
||||
// the decrypted items directly to all content scripts (avoids storage read).
|
||||
if (msg.type === "VAULT_UPDATED") {
|
||||
refreshAllBadges();
|
||||
const payload = {
|
||||
type: "VAULT_UPDATED",
|
||||
vault_items: msg.vault_items || [],
|
||||
};
|
||||
chrome.tabs.query({}, function (tabs) {
|
||||
tabs.forEach(function (tab) {
|
||||
if (
|
||||
tab.url &&
|
||||
(tab.url.startsWith("http://") || tab.url.startsWith("https://"))
|
||||
) {
|
||||
chrome.tabs.sendMessage(tab.id, payload).catch(function () {});
|
||||
}
|
||||
});
|
||||
});
|
||||
sendResponse({ ok: true });
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user