Going back to what works.
Manifest v3 and its consequences have been a disaster for the human race.
This commit is contained in:
parent
f9a31415a0
commit
6a85dbb2eb
3 changed files with 144 additions and 153 deletions
|
@ -369,27 +369,6 @@ async function clearCacheForMessages(idsInput) {
|
|||
icons: { "16": "resources/img/brain.png" }
|
||||
});
|
||||
|
||||
//for the love of god work please
|
||||
browser.messageDisplayAction.onClicked.addListener(async (tab, info) => {
|
||||
try {
|
||||
let header = await browser.messageDisplay.getDisplayedMessages(tab.id);
|
||||
if (!header) {
|
||||
logger.aiLog("No header, no message loaded?", { debug: true });
|
||||
return;
|
||||
}
|
||||
|
||||
const url = browser.runtime.getURL(`details.html?mid=${header.id}`);
|
||||
await browser.messageDisplayAction.setPopup({ tabId: tab.id, popup: url });
|
||||
await browser.messageDisplayAction.openPopup({ tabId: tab.id });
|
||||
} catch (err) {
|
||||
logger.aiLog("Failed to open details popup", { debug: true });
|
||||
}
|
||||
});
|
||||
|
||||
browser.messageDisplay.onMessagesDisplayed.addListener(async (tab, displayedMessages) => {
|
||||
logger.aiLog("Messages displayed!", { debug: true }, displayedMessages);
|
||||
});
|
||||
|
||||
browser.menus.onClicked.addListener(async (info, tab) => {
|
||||
if (info.menuItemId === "apply-ai-rules-list" || info.menuItemId === "apply-ai-rules-display") {
|
||||
const ids = info.selectedMessages?.messages?.map(m => m.id) ||
|
||||
|
@ -505,7 +484,9 @@ async function clearCacheForMessages(idsInput) {
|
|||
try {
|
||||
const [tab] = await browser.tabs.query({ active: true, currentWindow: true });
|
||||
const messages = await browser.messageDisplay.getDisplayedMessages(tab?.id);
|
||||
return { messages };
|
||||
const ids = messages.map(hdr => hdr.id);
|
||||
|
||||
return { ids };
|
||||
} catch (e) {
|
||||
logger.aiLog("failed to get displayed messages", { level: 'error' }, e);
|
||||
return { messages: [] };
|
||||
|
|
|
@ -10,9 +10,18 @@ if (!isNaN(qMid)) {
|
|||
if (messages && messages[0]) {
|
||||
loadMessage(messages[0].id);
|
||||
} else {
|
||||
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
|
||||
const tabId = tabs[0]?.id;
|
||||
const msgs = tabId ? await browser.messageDisplay.getDisplayedMessages(tabId) : [];
|
||||
let id = msgs[0]?.id;
|
||||
if (id) {
|
||||
loadMessage(id);
|
||||
}
|
||||
else {
|
||||
aiLog("Details popup: no displayed message found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMessage(id) {
|
||||
const storage = (globalThis.messenger ?? browser).storage;
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
"message_display_action": {
|
||||
"default_icon": "resources/img/brain.png",
|
||||
"default_title": "Details",
|
||||
"default_label": "Details"
|
||||
"default_label": "Details",
|
||||
"default_popup": "details.html"
|
||||
},
|
||||
"background": { "scripts": [ "background.js" ] },
|
||||
"options_ui": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue