1

I'm working on some chrome/firefox extension and what I want to accomplish is as similar UX as possible between these two. I've already understood that while in chrome you can (through manifest.json) register to override chrome://newtab, in firefox it's not such an easy job. What I want to accomplish in firefox is that once user click on browser action button - it opens new tab with my local HTML page. This codes do just that:

var buttons = require('sdk/ui/button/action');
var tabs = require('sdk/tabs');
var wuntils = require('sdk/window/utils');

var handleClick = function (state) {
    tabs.open({
        "url": "./pages/index.html",
        "isPinned": false
    });
};

var button = buttons.ActionButton({
    id: "mozilla-link",
    label: "Visit Mozilla",
    icon: {
        "16": "./assets/logo.png",
        "32": "./assets/logo.png",
        "64": "./assets/logo.png"
    },
    onClick: handleClick
});

Problem with this approach is that once new tab is opened theres resource://.... URL in the address bar. I've noticed that some other extensions managed to remove it and keep address bar empty but if I try to change tab.url property it starts redirection loop...

Any ideas how to make it look like a new tab but keep address bar empty?

Thanks!

NemanjaSRB
  • 398
  • 1
  • 16
  • If the address bar is empty they probably override the newtab page, which gets an empty address bar. Everything else has an URI. – humanoid May 24 '16 at 09:53
  • They did not because if you put text cursor in the address bar and press ESC it isn't empty anymore - you get same "resource://....." path. And if you open a new tab you get firefox new tab, not a plugin's one. – NemanjaSRB May 24 '16 at 12:02
  • Then I would suggest looking at the source code of such an extension - if they have resource:// paths they're likely also using the SDK. – humanoid May 24 '16 at 12:53
  • Thanks! I've thought that I can't access their extension source code 'cause their javascript was minified but it looks like that javascript that works with SDK was plain open! I'll test their solution later and post it here as an answer if it's working as expected. – NemanjaSRB May 24 '16 at 16:53

0 Answers0