我想为 Thunderbird 编写一个扩展来修改消息显示(例如插入/替换文本/标记/图像)。
不幸的是,缺少文档(由于最近的更改?)。
https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Thunderbird_extensions https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Thunderbird_extensions
已经过时了
https://developer.thunderbird.net/ https://developer.thunderbird.net/
还没有有用的例子
https://thunderbird-webextensions.readthedocs.io/ https://thunderbird-webextensions.readthedocs.io/
也没有例子
一些示例可以在以下位置找到:
- https://github.com/thundernest/sample-extensions https://github.com/thundernest/sample-extensions
建立在https://github.com/thundernest/sample-extensions/tree/master/messageDisplay https://github.com/thundernest/sample-extensions/tree/master/messageDisplay
我已经修改了背景.js https://github.com/thundernest/sample-extensions/blob/master/messageDisplay/background.js
browser.messageDisplay.onMessageDisplayed.addListener((tabId, message) => {
console.log(`Message displayed in tab ${tabId}: ${message.subject}`);
console.log(message.id);
browser.messages.getFull(message.id).then((messagepart) => {
console.log(messagepart);
body = messagepart['parts'][0]['parts'][0]['body'];
console.log(body);
body += "modified!";
console.log(body);
});
browser.windows.getCurrent().then((window)=>{
console.log(window.type);
});
browser.tabs.getCurrent().then((tab)=>{
console.log("tab",tab);
});
});
这为我提供了消息正文(使用魔法索引),但正如预期的那样,更改不会反映在消息显示中。
返回的窗口类型是normal
, not messageDisplay
.
The tab
is undefined
尽管添加了权限
"permissions": [
"messagesRead",
"activeTab",
"tabs",
"tabHide"
],
但我认为这是因为脚本运行时background
.
因此,我需要一个在内容/访问选项卡上运行的脚本,然后提供一些有关如何修改显示的消息内容的提示(我不想修改消息)。
我在哪里可以找到等效的文档
- https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts
特定于雷鸟?
指定content_scripts
在manifest.json中导致“错误:重新加载插件时出错[电子邮件受保护] /cdn-cgi/l/email-protection: 不明确的”。
executeScript()
from background
即使指定了 tabId,似乎也不起作用。