Private_Tab icon indicating copy to clipboard operation
Private_Tab copied to clipboard

Add button for open url typed in url bar in private tab

Open MurzNN opened this issue 10 years ago • 2 comments

I use feature "Open new tab from URL bar" and type urls without opening new tab. Will be good to get the button right of URL bar for open typed text in url bar in new private tab, can you add it? Thanks.

MurzNN avatar Mar 25 '15 06:03 MurzNN

You can use Custom Buttons extension with following code:

if(gURLBar.value) {
    privateTab.readyToOpenTabs(true);
    setTimeout(function() {
        privateTab.stopToOpenTabs(); // Turn off even if tab wasn't opened
    }, 10);
    var goBtn = document.getElementById("urlbar-go-button");
    goBtn.dispatchEvent(new MouseEvent("click", {
        bubbles: true,
        cancelable: true,
        view: window,
        button: 1
    }));
}

This is middle-click emulation on built-in Go button (+ code to make new tab private).

Or more simple (but probably more robust) way:

var typed = gURLBar.value;
if(typed) {
    gBrowser.selectedBrowser.userTypedValue = null;
    privateTab.readyToOpenTab(true);
    gBrowser.selectedTab = gBrowser.addTab(typed);
}

To just open URI (e.g. "search string with spaces" and keywords like "g search" to search using Google will not work).

Infocatcher avatar Mar 26 '15 17:03 Infocatcher

@MurzNN You can also simply create a bookmark shorcut like this: https://i.imgur.com/3DVgEhH.png

If you type "p example.com", http://example.com is going to open in a new private tab.

anewuser avatar Apr 21 '15 13:04 anewuser