Infocatcher / Private_Tab

Adds private tabs, restartless extension for Firefox (20.0+) and SeaMonkey (2.17+)
https://addons.mozilla.org/addon/private-tab/
Other
86 stars 20 forks source link

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

Open MurzNN opened 9 years ago

MurzNN commented 9 years ago

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.

Infocatcher commented 9 years ago

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).

anewuser commented 9 years ago

@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.