1

I have created an addon which shoots a new tab on firefox load and a message is displayed on the DOM of the new tab. But everytime i click on the new tab button it shows the message. I want to hamper the event after the first new tab .. i mean the new tab which we click afterwards manually should not show any "hello world" message?. Is it possible.. Please help.. Tell me if you want more info.. Thanks in advance.. Below is the code which i used...

var tabs = require("sdk/tabs");
tabs.open("about:blank");

tabs.on('activate', function(tab) {
var worker = tab.attach({
contentScript: 'self.port.emit("html", document.body.innerHTML = "Hello World");' // contentScript sending message to add-on script
  });
 worker.port.on("html", function(message) {   //recieving message from  contentSCript
  console.log(message)
     })
 });
Aksh1693
  • 59
  • 7

1 Answers1

0

This is a cool question. Because if you use the DOM Inspector you can see what event listeners are on an object, and then you can remove them. Like in this screenshot - https://i.stack.imgur.com/d0Dhr.png

I'm sure they use these XPCOM components - dig around on dxr.mozilla.org (firefoxes nightly codebase) to verify:

Noitidart
  • 35,443
  • 37
  • 154
  • 323