Giter VIP home page Giter VIP logo

sample-extensions's Introduction

Sample Extensions

This is a collection of MailExtensions (Thunderbird add-ons based on WebExtension technology) to showcase how the available WebExtension APIs can be used in Thunderbird. Each example exists for Manifest V2 and V3. The Manifest V3 compatible versions include comments to highlight the required changes.

Manifest V3 is officially supported since Thunderbird 128. Running Manifest V3 add-ons in older versions of Thunderbird is not recommended.

Sample Extension Description
addressBooks Use the addressbooks, contacts, and mailingLists APIs and its dependencies.
apiList List all available APIs in different windows: tabs, options, message compose and message display window. It uses the tabs API to inject scripts and css into the message compose and message display windows.
awaitPopup Open a blocking popup and await user feedback.
composeBody Use the compose API to access and manipulate the content of the message compose window.
composeScript Use the composeScript API to access and manipulate the content of the message compose window.
dropbox Use the cloudFile (a.k.a. FileLink) API to upload attachments to dropbox.
experiment Show how to write an Experiment API including a function and an event and how to listen to the custom event.
experiment.openSearchDialog Use an Experiment to open the message search dialog. The Experiment has been created with the Experiment Generator.
experiment.prefMigration Use an Experiment to migrate preferences from the legacy pref system to the WebExtension local storage.
experiment.restart Use an Experiment to add a Restart entry to Thunderbird's file menu and to perform a Thunderbird restart.
mailTabs Use the mailTabs APIs to manipulate the appearance of the main Thunderbird window.
managedStorage Use storage.managed to access data defined by enterprise policies.
messageDisplay Use the messageDisplay and messageDisplayAction APIs to show how to add a button to the message header, and how to react when a message is displayed.
messageDisplayScript Use the messageDisplayScript API to display a banner with information from the currently selected message along with a button to trigger an action in the background script via runtime.sendMessage.
messageDisplayScript.pdfPreview Use the listAttachments() and getAttachmentFile() functions of the messages API to extract attached PDFs and images, and uses the messageDisplayScript API to display an inline preview directly in the message window.
optIn Ask the user for extended consent before using the add-on.
quickFilter Use the mailTabs, menus and messages APIs to add a Filter context menu to the message list which can set certain quickfilter settings.
sobriety Shows how the compose.onBeforeSend event can be used: Opening a composeAction popup in the composition window when an email is about to be send, to request confirmation.
theme_experiment A theme using the theme_experiment API to change the color of the chat icon.

To run any of the listed extensions, clone or download this repository and either:

  • zip the directory of your choice (manifest.json should be at the top level of the zip file) and install it like any other Add-On in Thunderbird.
  • select "Debug Add-Ons" from the Add-On Manager menu, click "Load Temporary Add-On" and select manifest.json from your source (or any other file part of your Add-On). Temporary loaded Add-Ons do not need to be zipped.

sample-extensions's People

Contributors

arndissler avatar darktrojan avatar jobisoft avatar joendres avatar rholeczy avatar standard8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sample-extensions's Issues

Drop down menu in address book

I want to add a new drop down field as gender and want to show in address book in thuderbird. Can you please guide me

Most of these sample extensions dont work

Name Thunderbird
Version 91.7.0
Build ID 20220305171341
Distribution ID ubuntu-snap-build

So I've gone through pretty much every extension, and tried. I'm not able to load any temporary addon - files are not found leading to errors about encoding...

e.g. Just testing the layout example

First tried as a temp addon -

"The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. layout.html"

So naturally thinking that I had to check the UTF-8 in the HTML as meta tag. No - seems fine. Locales are not found when loading the temp add on. Tried as XPI / ZIP - same again, and seems that TB isnt loading the file at all.

Not sure if its a breaking change, or unique to this build...

for testing, doesn'need to be zipped

the instruction tells to zip and temporarily install.

If temporarily installed, it is sufficient to 'load' an addonfile in the dialog, e.g. point to the manifest file.
zipping before is not needed (75b)

Adding a sidebar (or bottombar) to the message compose window

Hi!
I saw the example of "Compose Body" that adds a button to the top menu. However, is there an example showing how to add a sidebar (or bottom bar) to the text area (like in Word, Outlook or Google Docs)?
I am talking about a sidebar that one can build using html+js that can use the thunderbird api to manipulate the text area (email body) content.

Trying out message compose

I have found these examples and I want to modify the parameters of a thunderbird sending email window. I want to add cc, bcc and so forth.

I have tried the composeBody example for my extension but it keeps telling me that:

"browser.compose.setComposeDetails is not a function"

What is the problem?

restart extension doesn't work with TB 78.2.2

[Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIXPCComponents_Utils.readUTF8URI]"  nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)"  location: "JS frame :: resource://gre/modules/L10nRegistry.jsm :: L10nRegistry.loadSync :: line 658"  data: no] L10nRegistry.jsm:658:19
    loadSync resource://gre/modules/L10nRegistry.jsm:658
    fetchFile resource://gre/modules/L10nRegistry.jsm:573
    generateResourceSetSync resource://gre/modules/L10nRegistry.jsm:478
    map self-hosted:240
    generateResourceSetSync resource://gre/modules/L10nRegistry.jsm:473
    generateResourceSetsForLocaleSync resource://gre/modules/L10nRegistry.jsm:415
    InterpretGeneratorResume self-hosted:1151
    next self-hosted:1099
    generateBundlesSync resource://gre/modules/L10nRegistry.jsm:177
    InterpretGeneratorResume self-hosted:1151
    next self-hosted:1099
    touchNext resource://gre/modules/Localization.jsm:167
    regenerateBundles resource://gre/modules/Localization.jsm:552
    activate resource://gre/modules/Localization.jsm:243
    <anonymous> chrome://messenger/content/mailWidgets.js:37
    <anonymous> chrome://messenger/content/customElements.js:34
    <anonymous> chrome://messenger/content/customElements.js:37
    observe resource://gre/modules/MailGlue.jsm:198```

Address Book WebExtensions API custom properties

Hello and thank you for this repo, it really helps to understand the things better. I have a question here related to how new contacts are created. I am in the middle of creating an address book synchronization add-on for TB and thus the question.

The TB WebExtensions API states that the complete list of properties that TB uses should be taken from the nsIAbCard.idl i.e.

https://thunderbird-webextensions.readthedocs.io/en/latest/contacts.html#contactproperties

the nsIAbCard.idl interface provided the opportunity to create a custom property using the methods

void setProperty(in AUTF8String name, in nsIVariant value);
nsIVariant getProperty(in AUTF8String name, in nsIVariant defaultValue);

Is it possible to create those properties using the new address book API for the AddressBook node?

The reason i am asking this question is because i found myself in the need to tag each Node (Address Book, Contact, MailingList) with at least the first two of the 3 properties mentioned below:

  1. Integer Counter - which increases every time the contact is changed.
  2. Epoch time stamp integer - that is set to the current time stamp every time the contact has been changed.
  3. UUID - that will be set from external source in order to identify this contact . Here i do not mean the ID that is created by the

contact WebExtensions API i.e. i mean UUID string that is received from another program.

I could create a contact like that :

function createContact() {
  	let randomId = Math.random(); 
	let currentTimeStamp = new Date().getTime().toString(); 
	let counter = Math.random().toString();
	let uuid = "b0fe4bd6-eb2b-41a7-b49e-4fe37fd22813";
	
	let properties = { PreferMailFormat: "0", DisplayName: "TestContact33" + randomId , MyCustomerCounteProperty:counter, LastModifiedDate:currentTimeStamp, MyCustomeUUIDProperty:uuid  };
	let addressBookId="9c0e538f-a29f-4060-b5d8-21a3e788e5c6";
	let promise = browser.contacts.create(parentId = addressBookId, properties).then(() => {  });
}

Here i am adding the custome properties "MyCustomerCounteProperty", and "MyCustomeUUIDProperty"
I am searching for more clean approach to do the same for the AddressBook Node type and Mailing List.

The documentation mentioned that for Contacts
"It is also possible to store custom properties. The custom property name however may only use a to z, A to Z, 1 to 9 and underscores."

however i am not able to execute some customer property for the AddressBook node, i can execute that for Contacts only! Can customer property be executed on AddressBook nodes and Mailing lists?

Alert when sending that checks contact metadata for flag

E.g. when SEND is pressed and a particular contact e.g. where they have a value "NO-EMAIL" in a custom contact field - the extension should not proceed sending, but pop up with an alert.

There's also a case where certain contacts should only be sent email using a particular "FROM" email address (i.e. corporate vs. personal)... similarly the extension should not proceed sending, but pop up with an alert.

How do I determine the attachment for messages with manifest v3?

I sent myself an email with an attachment, but I don't see any way to read the file attachment within the "message" and, for example, process it further

i use messenger.messages.onNewMailReceived.addListener(mail_checker); for calling and IMAPS Server, there is no "Attachments" or something else.

image

i can't see attachments if i use this to load the message object content while opening the email in thunderbird.

background.js

browser.messageDisplay.onMessageDisplayed.addListener((tab, message) => {
  console.log(`Message displayed in tab ${tab.id}: ${message.subject}`);
  console.log(message);
});

Thank you for helping me :-)

hello-world example does not display icon or popup in 102.10.1 (64-bit)

OS: KDE Neon 22.04 Guest running under KVM/QEMU on Ubuntu 22.04
Thunderbird: 102.10.1 (64-bit) Flatpak
hello-world commit used: b8855e6

hello-world button appears on main toolbar without icon:

image

Hovering over hello-world button causes title to display:

image

Clicking on the button causes a vertical line to be displayed briefly, and a small oblong "bubble" to appear:

image

Loading mainPopup/popup.html in Firefox seems to work fine:

image

I've checked file permissions of the files and directory to make sure they are accessible, have loaded the icons in a viewer to confirm that they are okay. I loaded the extension with Load Temporary Add-on...

image

Here's what the inspector shows (which makes no sense to me):

image

Add-on for send-unsent-messages-without-attachments

@darktrojan An add-on which will add an option to send unsent messages without attachments .
While travelling on a plane, I check my downloaded emails and may reply /send many emails . Some are brief , others have large attachments.
When I connect to a mobile network with low data range. Thunderbird tries to deliver the emails in Outbox in chronological order. If the first on happens to be a low-priority
email with large attachment,it may take a very long time or even timeout. Short high-priority emails later in the Outbox are blocked.

Error calling messenger.messageDisplay.getDisplayedMessage on .eml mail

Thunderbird version: 102.6.0 (64-bit)
OS: Linux

Hello :)

I encountered a strange behavior when working with .eml attachments. If I run the sample extension https://github.com/thundernest/sample-extensions/tree/master/messageDisplay on a "normal" mail it works just fine. But, if I have an .eml attachment, open it and click the extension's button, it gives me the following error (console output):

msgHdr.getProperty is not a function ext-mail.js:1753
    convertMessage chrome://messenger/content/parent/ext-mail.js:1753
    getDisplayedMessage chrome://messenger/content/parent/ext-messageDisplay.js:142
    getDisplayedMessage self-hosted:1121
    result resource://gre/modules/ExtensionParent.jsm:1035
    withCallContextData resource://gre/modules/ExtensionParent.jsm:524
    result resource://gre/modules/ExtensionParent.jsm:1034
    withPendingBrowser resource://gre/modules/ExtensionParent.jsm:534
    result resource://gre/modules/ExtensionParent.jsm:1033
    callAndLog resource://gre/modules/ExtensionParent.jsm:986
    recvAPICall resource://gre/modules/ExtensionParent.jsm:1032
    InterpretGeneratorResume self-hosted:1429
    AsyncFunctionNext self-hosted:632
Error: An unexpected error occurred undefined
Message displayed in tab 2: eml attachment test background.js:2:11
This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”. fetch>UID>.INBOX>14690

The problem seems to start here:

https://github.com/thundernest/sample-extensions/blob/master/messageDisplay/popup.js#L6

I work on an extension myself where the same error occurs and I don't know how to fix this problem...

Any help would be very appreciated :)

Best
Martin

zipped experiment extension does not load anymore

Tested on TB 91.9.0 and 101.0, while trying to migrate my extension.
I zipped the entire content of the experiment sample to test.xpi and loaded the file in the debug menu.
I got the following error:

[Exception... "File error: Not found"  nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)"  location: "JS frame :: jar:file:///home/leon/Downloads/test.xpi!/api/ExampleAPI/implementation.js :: <TOP_LEVEL> :: line 9"  data: no] 2 implementation.js:9:34
    <anonymous> jar:file:///home/leon/Downloads/test.xpi!/api/ExampleAPI/implementation.js:9
    <anonymous> jar:file:///home/leon/Downloads/test.xpi!/api/ExampleAPI/implementation.js:161
    asyncLoaded resource://gre/modules/ExtensionCommon.jsm:1677
    (Async: promise callback)
    asyncLoadModule resource://gre/modules/ExtensionCommon.jsm:1675
    asyncLoadModule resource://gre/modules/ExtensionCommon.jsm:1892
    asyncGetAPI resource://gre/modules/ExtensionCommon.jsm:1618
    asyncLoadAPI resource://gre/modules/ExtensionCommon.jsm:1238
    asyncFindAPIPath resource://gre/modules/ExtensionCommon.jsm:1319
    recvAddListener resource://gre/modules/ExtensionParent.jsm:1008
    recvAddListener self-hosted:1175
    _recv resource://gre/modules/ConduitsChild.jsm:78
    receiveMessage resource://gre/modules/ConduitsParent.jsm:385

When I load the exact same contents unzipped (via the manifest) this does work.

Testing examples

Hello, I'm curious how TB extensions are tested. I wasn't able to find any test cases in any of the example plugins provided in this repo; please direct me if I overlooked something!

Filter extension gives a permissions error when loaded from folder

In the newest beta release, loading the extension from the file renders the warning

"Reading manifest: Error processing permissions.0: Value "mailTabs" must either: must either [must either [be one of ["clipboardRead", "clipboardWrite", "geolocation", "idle", "notifications"], be one of..." etc etc.

Any idea why this is happening and what the fix is? I've seen this issue on a couple other extensions using the new API.

Can Gloda queries be used?

Hello,

I am trying to create an experiment API to execute a Gloda query and display the results. However I seem to already get an error "file not found" with:

var { Gloda }  = Components.utils.import("resource:///modules/gloda/public.js")

Am I doing something wrong?

Thanks in advance.

messageDiplay example do not work on MacOS version

Thunderbird version: 102.2.2 (64-bit), language: FI
Plugin: [email protected]

The plugin was loaded using the Load temporary plug-in functionality.

The button becomes visible, but when pressed, the popup window has no content.

Näyttökuva 2022-9-10 kello 15 20 06

I modified plugin.js a bit to get some debug information:

browser.tabs.query({
  active: true,
  currentWindow: true,
}).then(tabs => {
  let tabId = tabs[0].id;
  browser.messageDisplay.getDisplayedMessage(tabId).then((message) => {
    document.body.textContent = message.subject;
    console.log(document.body)
  });
});

Here's what I can see on console:

Näyttökuva 2022-9-10 kello 15 18 54

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.