Update Sidebar Content

How can I change sidebar content with this logic below:

Add-on script: Event occurred => page worker creates port.emit

Content script: port.on detected event => change sidebar content

Many thanks.

Try sending another emit from the add-on script to the sidebar script with the requested change.

Example from my extension

sidebar script

addon.port.emit(“loaded”);
addon.port.on(“update”, function(array) {
//Make changes using array data
});

index.js

worker.port.on(“loaded”, function() {
var theDate = new Date();
var endDate = theDate.toJSON();
var array = new Array(theDate, endDate);
worker.port.emit(“update”, array);
});

Hi Paul,

It works perfectly. Thank you.

Regards,

Ken