Commit fb7e70b4 authored by flatgreen's avatar flatgreen
Browse files

workaround bug window.close

parent 92c3fff1
trav/
addtomailinglist.zip
addtomailinglist.xpi
addtomailinglist.zip
addtomailinglist.xpi
git.sh
\ No newline at end of file
......@@ -9,6 +9,9 @@
"message": "Add to ..."
},
"extensionMessageDisplayActionChoice": {
"message" : "choose a list"
"message": "choose a list"
},
"extensionNotificationInMessage": {
"message": "is added to the mailing list: "
}
}
......@@ -10,5 +10,8 @@
},
"extensionMessageDisplayActionChoice": {
"message" : "Choisir une liste"
},
"extensionNotificationInMessage": {
"message": "est dans la liste : "
}
}
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!-- transform from thunderbird repo -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="context-fill" fill-opacity="context-fill-opacity" viewBox="0 0 16 16">
<path d="m16,16l-0.671,0l0.671,0zm-3.535,-8a4.502,4.502 0 0 0 -4.229,3.058a5.006,5.006 0 0 0 -3.82,2.942l3.84,0a4.51,4.51 0 0 0 1.415,2l-7.671,0a7.003,7.003 0 0 1 4.812,-6.651a4,4 0 1 1 5.653,-1.349zm-3.465,0a2,2 0 1 0 0,-4a2,2 0 0 0 0,4z" fill="black"/>
<path d="m4.049,6.7a4,4 0 0 1 5.651,-5.651a5,5 0 0 0 -5.651,5.651zm-2.797,7.3l-1.252,0a7,7 0 0 1 4.249,-6.439c0.178,0.543 0.447,1.045 0.788,1.488a8.016,8.016 0 0 0 -3.785,4.951z"/>
<path d="m12.5,16a3.5,3.5 0 1 1 0,-7a3.5,3.5 0 0 1 0,7zm0.5,-4l0,-1.5a0.5,0.5 0 1 0 -1,0l0,1.5l-1.5,0a0.5,0.5 0 1 0 0,1l1.5,0l0,1.5a0.5,0.5 0 1 0 1,0l0,-1.5l1.5,0a0.5,0.5 0 1 0 0,-1l-1.5,0z" fill="#007f00"/>
</svg>
\ No newline at end of file
{
"manifest_version": 2,
"default_locale": "en",
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"version": "1.0",
"author": "GTeam",
"developer": {
"name": "GTeam"
},
"applications": {
"gecko": {
"id": "tb-addtomailinglists@tb.dev",
"strict_min_version": "68.3"
}
},
"message_display_action": {
"browser_style": true,
"default_popup": "popup/popup.html",
"default_title": "__MSG_extensionMessageDisplayActionDefaultTitle__",
"default_icon": "icons/addlist2.svg"
},
"permissions": [
"addressBooks",
"tabs",
"messagesRead"
],
"icons": {
"48": "icons/addlist2.svg",
"96": "icons/addlist2.svg"
}
}
{
"manifest_version": 2,
"default_locale": "en",
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"version": "1.1",
"author": "GTeam",
"homepage_url": "https://framagit.org/GTeam/addtomailinglist",
"applications": {
"gecko": {
"id": "tb-addtomailinglists@tb.dev",
"strict_min_version": "71.0"
}
},
"message_display_action": {
"browser_style": true,
"default_popup": "popup/popup.html",
"default_title": "__MSG_extensionMessageDisplayActionDefaultTitle__",
"default_icon": "icons/addlist2.svg"
},
"permissions": [
"addressBooks",
"tabs",
"messagesRead",
"notifications"
],
"icons": {
"48": "icons/addlist2.svg",
"96": "icons/addlist2.svg"
}
}
.panel {
padding: 16px;
}
#choice {
font-weight: bold;
}
ul {
list-style: none;
padding: 0;
margin: 0 0 5px 0;
}
li {
padding: 0 5px 0 5px;
}
li:hover {
background-color: #0996f8;
color: #fff;
.panel {
padding: 16px;
}
#choice {
font-weight: bold;
}
ul {
list-style: none;
padding: 0;
margin: 0 0 5px 0;
}
li {
padding: 0 5px 0 5px;
}
li:hover {
background-color: #0996f8;
color: #fff;
}
\ No newline at end of file
......@@ -8,19 +8,28 @@ function authorToEmail(text){
}
}
function notify(email, listName) {
var message = browser.i18n.getMessage("extensionNotificationInMessage") + listName;
browser.notifications.create({
"type": "basic",
"iconUrl": browser.runtime.getURL("icons/addlist2.png"),
"title": email,
"message": message
});
}
// click event
function addToMailingList(listId, email) {
// chercher le contact
function addToMailingList(listId, listName, email) {
// search contact
// console.log(listId + ' fonction addToMailingList');
browser.contacts.quickSearch(email)
.then((arrayContacts) => {
var waitForId;
if (arrayContacts.length == 0){
// creation d'un ContactNode
// create ContactNode
waitForId = browser.mailingLists.get(listId)
.then((node) => {
// console.log('create');
console.log('create contact');
return browser.contacts.create(node.parentId, {"DisplayName" : email, "PrimaryEmail" : email})
}).then((id) => {
// console.log('new: ' + id);
......@@ -29,14 +38,16 @@ function addToMailingList(listId, email) {
} else {
// on prend le premier (on s'en fout...)
waitForId = Promise.resolve(arrayContacts[0].id);
// console.log('exist waitForId: ' + waitForId);
}
return waitForId;
})
// ajouter le contact
// add contact to mailingList
.then((contactId) => {
// console.log('ajout : ' + contactId + ' -- list : ' + listId);
// console.log('add: ' + contactId + ' -- listId: ' + listId + ' -- listName: ' + listName);
browser.mailingLists.addMember(listId, contactId);
window.close();
notify(email, listName);
// window.close(); // bug OK in 83 ?
})
}
......@@ -54,8 +65,10 @@ browser.tabs.query({
let tabId = tabs[0].id;
return browser.messageDisplay.getDisplayedMessage(tabId)
}).then((message) => {
// console.log('the email (message)');
// console.log(message);
email = authorToEmail(message.author);
// console.log(email);
}).then(() => {
return browser.addressBooks.list(true)
}).then((listBooks) => {
......@@ -63,7 +76,7 @@ browser.tabs.query({
for (let aList of aBook.mailingLists){
let li = document.createElement("li");
li.textContent = aList.name;
li.addEventListener("click", () => addToMailingList(aList.id, email));
li.addEventListener("click", () => addToMailingList(aList.id, aList.name, email));
document.getElementById("mailingLists").appendChild(li);
}
}
......
# Add To Mailing List
Add-on (web extension) for Thunderbird.
Add an email address to an existing mailing list.
## Option
"autostart" checked by default: pass directly from JD2 Linkgrabbler to download list.
## Code Source
[UrlToJD2](https://framagit.org/GTeam/addtomailinglist)
# License
This project is licensed under the Mozilla Public License, version 2.0
# Add To Mailing List
AddToMailinglist is a add-on (MailExtension) for Thunderbird.
It add the current email address to an existing mailing list.
This add-on adds a button to the window for composing/reading an email. You can choose a mailing list to add this email address to.
## Code Source
[UrlToJD2](https://framagit.org/GTeam/addtomailinglist)
## Installation
[officiel site](https://support.mozilla.org/en-US/kb/installing-addon-thunderbird)
## License
This project is licensed under the Mozilla Public License, version 2.0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment