Originally published at: http://www.sitepoint.com/build-trello-chrome-extension-exporting-lists/
How to Build a Trello Chrome Extension
- How To Build a Trello Chrome Extension – API Authentication
- How To Build a Trello Chrome Extension – Exporting Lists
In the previous part, we built the basics of our extension, implementing authentication through a custom Foundation-powered settings screen and using Trello’s JavaScript client library. In this part, we’ll finish our extension by adding the exporting logic and UI.
Messaging
When we authenticate with Trello on the settings screen, the Trello token is saved in local storage. However, the settings page is its own page and, effectively, its own environment – ergo, neither the extension’s background page nor the extension’s content scripts have access to it. This is where we need to use message passing.
The chrome.extension.sendMessage
API is used to send messages to and from background pages. In our case, we’ll be using it to send the token from the settings page to our background page. Since our settings adventure is done as soon as this is completed, we might as well automatically close the tab, to improve user friendliness.