Avoid popup blocker

I’m trying to port my Chrome extension for Firefox. It opens after clicking on the addon button in the addon bar a new tab with an address http://example.com#url=http://url-of-the-current-page.com.

The code for this is void(window.open('http://example.com#url='+window.location.href,'_blank'));.

This code is triggered by background script looking like chrome.browserAction.onClicked.addListener(function(tab) { chrome.tabs.executeScript(tab.id, {file: "code.js"}) });.

In Chrome this works like a charm. In Firefox it triggers the popup blocker with an alert Firefox prevented this site from opening a popup window.

How could i avoid popup blocker triggering and just immediately open new tab with my url?

Just use the proper APIs for this:

chrome.browserAction.onClicked.addListener(tab => {
    chrome.tabs.create({ url: tab.url, });
});

thank you for quick reply! maybe i use it wrong, but your code just opens a current url in the new tab… But i need that it executes the code from the file code.js…

Could you please explain how i properly use your code? This is my first approach to FF addons:)

Oh, yeah, right. You’d want to prepend the 'http://example.com#url=' to tab.url. And you should probably call encodeURIComponent on it as well:

chrome.tabs.create({ url: 'http://example.com#url='+ encodeURIComponent(tab.url), });

YEah! this works like expected! Nice, thank you!