3

I'm making a Thunderbird Extension through the WebExtension Api (with popup) and i've some difficulties running a Content script to get some elements (attachments list of the current mail for example) directly from Thunderbird interface.

I've made a popup.html , a popup.js and a contentScript.js that runs when the popup is opened. Apparently contentScript.js doesn't run in the main Thunderbird tab, but runs smoothly when i open a new tab (with url) through code.


$(document).ready(function(){

 console.log('Try to execute contentScript'); 

 //  -- create new tab -- 
 //    browser.tabs.create({
 //     url: 'https://example.org'
 //   });

 // -- execute script in current tab --
    browser.tabs.executeScript({

      file: 'scripts/contentScript.js'
    });

});

// from contentScript.js

console.log('contentScript.js - Injected');

In console i expected "contentScript.js - Injected" but this only appens when i am not in the main Thunderbird tab. When i am in the main tab it shows only "Try to execute contentScript" then nothing appens, no errors.

Thunderbird extension are evolving right now from the old legacy method (overlay of xul files) to the actual WebExtension Api used by most of the browsers, but there are some differences: in Firefox the extension works without any problem, so i supposed that the main tab of Thunderbird is somehow protected from content injection.

My objective here is to get the attachments list and other elements directly from the interface, but apparently i can't.

Davidebug
  • 53
  • 7
  • You might be able to get to the attachments using an event listener in `background` - see https://stackoverflow.com/questions/59547118/how-to-modify-thunderbird-message-display-with-extension for links to docs and examples. – handle Jan 01 '20 at 09:13

0 Answers0