gpt4 book ai didi

thunderbird - 如何插入带有 Thunderbird 扩展的电子邮件标题?

转载 作者:行者123 更新时间:2023-12-04 12:38:41 26 4
gpt4 key购买 nike

我正在构建一个 Thunderbird 扩展,并希望将我自己的标题添加到所有外发电子邮件(例如 )。知道如何做到这一点吗?我知道这是可能的,因为这是在 OpenPGP Enigmail 扩展中完成的。谢谢!

最佳答案

这是我正在开发的一个扩展中的代码:

function SendObserver() {
this.register();
}

SendObserver.prototype = {
observe: function(subject, topic, data) {

/* thunderbird sends a notification even when it's only saving the message as a draft.
* We examine the caller chain to check for valid send notifications
*/
var f = this.observe;
while (f) {
if(/Save/.test(f.name)) {
print("Ignoring send notification because we're probably autosaving or saving as a draft/template");
return;
}
f = f.caller;
}

// add your headers here, separated by \r\n
subject.gMsgCompose.compFields.otherRandomHeaders += "x-test: test\r\n";
}

},
register: function() {
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver(this, "mail:composeOnSend", false);
},
unregister: function() {
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.removeObserver(this, "mail:composeOnSend");
}
};


/*
* Register observer for send events. Check for event target to ensure that the
* compose window is loaded/unloaded (and not the content of the editor).
*
* Unregister to prevent memory leaks (as per MDC documentation).
*/
var sendObserver;
window.addEventListener('load', function (e) {if (e.target == document) sendObserver = new SendObserver(); }, true);
window.addEventListener('unload', function (e) { if (e.target == document) sendObserver.unregister();}, true);

将其放在由撰写窗口加载的 .js 文件中(例如通过覆盖 chrome://messenger/content/messengercompose/messengercompose.xul)

在我的情况下,检查 SendObserver.observe 是必要的,因为我想做一个用户交互,但你可能会忽略它。

关于thunderbird - 如何插入带有 Thunderbird 扩展的电子邮件标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/162057/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com