6

Sometimes I need to move an url from an app to a browser. I select the url, say in gvim, and make Firefox window active. Then I see that I should clear address bar before pasting the new url, which requires selecting existing url, which wipes the new url from PRIMARY clipboard out.

What is the best way to put the new url from PRIMARY clipboard to address bar? Is there a shortcut to clear address bar and then to move focus there?

ps I know I can use Ctrl-C to put the new url to CLIPBOARD clipboard, but I prefer to use PRIMARY clipboard.

4
  • just drag drop the url to the firefox icon in unity it opens it in new tab, i have done this for vlc!! – sarvesh.lad Oct 17 '12 at 21:33
  • Thank you! That works with gedit, but gvim doesn't allow to drag a selection. I need a solution that works with all applications. – zuba Oct 18 '12 at 8:17
  • The workaround I use is to open a new tab (left click on the "new tab" button and middle click in the address bar). – August Karlstrom Jul 3 '15 at 16:37
  • That is not the answer, as I asked how to clear the address bar of existing tab with a page loaded – zuba Jul 3 '15 at 17:09
2

Just use Xclear add-on.

Clear url and search field easily https://addons.mozilla.org/en-US/firefox/addon/xclear/

1
  • 1
    Unfortunately, it does not work anymore with last firefox versions – Jérôme Pouiller Aug 6 '18 at 12:47
6

Ctrl + L selects the Location Bar, giving it focus and highlights whatever is in the field. Simply use that keyboard shortcut just after giving the Firefox window focus but before you paste your intended target URL.

3
  • As soon as I press Ctrl + L, the primary clipboard contains the URL which is currently in the location bar, because this combination highlights it. I wonder why it worked for you, @zuba …? – unor Oct 20 '12 at 2:51
  • I bet it worked when I checked it out, but, yes, I'm mistaken the way I couldn't explain. Yes you're right - it doesn't work. So I clear the answer mark. – zuba Oct 20 '12 at 16:48
  • That certainly works for Chrome, despite it selects a location bar content as Firefox does. I guess I checked the solution for Chrome not for Firefox. – zuba Oct 20 '12 at 16:53
1

As per my tests Alt+A is not working as intented but Ctrl+A definitely works, since "Xclear" or "Clear fields" extensions are not working anymore with Firefox 60 or later.

The diference between Ctrl+A and Alt+A is that the later puts the selection into PRIMARY buffer (overwriting your selection) while Ctrl+A does not, so you can select a text in any application, Ctrl+A to highlight any text field (not only the address bar), press Del to delete it and then paste your previous selection with middle mouse button.

0

Activate the address field if necessary with a click, Select the url with Alt-A, clear the url with Del, and paste the new url with middle mouse button click.

1
  • That doesn't work to me – zuba Oct 18 '12 at 8:12
0

It is Ctrl + K to select the additional address bar search box (and highlight without over-riding the Primary clipboard).

1
  • I see a lot of website / tools prehending Ctrl+K. Good to know, under Linux, Ctrl+J goes the search bar as well. – lolesque Apr 11 '19 at 12:41
0

I have made a userChromeJS script which will add clear buttons to the urlbar and findbar.

// ==UserScript==
// @name        xClearFieldButton.uc.js
// @namespace       xClearFieldButton@iwo.uc.js
// @description     xClearbutton test
// @include     main
// @compatibility   Firefox 67-72
// @author      Tobias Rupf
// @version     0.5
// @note        build button to clear address bar and search bar fields for use in conjunction with middle mouse paste (about:config "middlemouse.paste"=true)
// ==/UserScript==

(function clearFieldButton() {
    if (!location.toString().match('chrome://browser/content/browser\.(xul)|(xhtml)')) return;
    if (document.getElementById("urlbarClearButton")) return;

    function createBtn() {
        var xClearBtnBox = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'hbox');
        xClearBtnBox.setAttribute("class", "urlbar-icon-wrapper");
        xClearBtnBox.setAttribute("onclick", "if (event.button == 0) {\
            if (typeof(this.parentNode.parentNode.reset) == 'function') {\
                this.parentNode.parentNode.reset();\
                this.parentNode.parentNode.focus();\
            } else {\
                obj = this.parentNode.parentNode.children;\
                for (var i=0; i<obj.length; i++) {\
                    if (typeof(obj[i].reset) == 'function') {\
                        obj[i].reset();\
                        obj[i].focus();\
                    }\
                    else if (typeof(obj[i].className.indexOf('input-box'>0)) || typeof(obj[i].className.indexOf('textbox'>0))) {\
                        if (typeof(obj[i].value) == 'string') {\
                           obj[i].value = '';\
                           obj[i].focus();\
                        }\
                        for (var j=0; j<obj[i].children.length; j++) {\
                            if (typeof(obj[i].children[j].value) == 'string') {\
                                obj[i].children[j].value = '';\
                                obj[i].children[j].focus();\
                            }\
                        }\
                    }\
                }\
            }\
        }");
        var xClearBtn = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'image');
        xClearBtn.setAttribute("class", "urlbar-icon");
        xClearBtn.setAttribute("role", "button");

        /* KDE button style */
        xClearBtn.style.listStyleImage = "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAAG7AAABuwE67OPiAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAATVQTFRF////AAAAOkI6AAAALDIsAAAAICAgAAAAFRUSAAAABQUFPT48AAAAPT47Y2NjAAAAAQEBMDEvAgICJCUkAgICGBgXBAQEDQ0NAQEBAgICBAQEBQUFBgYGBwcHCAgIDAwMDQ0NEBAQFBQTFBQUGRkZICAgISIhIiIiJycmLzAuMTExMjMxNzc3Ojo6PT47Pz8/QUFBQUI/REVDRUVFR0dHSkpKSktIS0tLTU5LTk5OTk9NUFBQU1NTVFRUVlZVVldUWFlWWVlZW1tbZGRjZGZiZmhkaGhoampqamtncXFxdXV1eXl5enp6hISEhoaGioqKkJCQn5+frKysrq6usrKxt7i3wcHBxMXExsbGz9DP1NTU3t7e4eHh5+fn6enp6urq7e3t8PDw8/Pz9PT0+vr6+/v7/Pz8dUr3qgAAABh0Uk5TAB8fLi4/P1RUZWW4ysrU5eXl8PD4+P39CqmsmgAAAJ1JREFUGBmdwQMWAgEABcCfbdu2bdt2W3v/I4Q9QO81A/yJLgpTBPhiyurjQb837LR9+GArijNiUh8R86Ibb1xVqrZ/3BcEecnZAfA10UyydHg8yVshYgQg8UdCweCUJJ9Tj1MLgKe2WG2Jw/V0PeZ0OrxxlAb99rwpr887lx4fLLkjvszHKqtGwIAvhtSbrja7rWrWBApNaKaI8dsLXHIcGL0rDy8AAAAASUVORK5CYII=)";

        /* CLEAR button style */
        /*xClearBtn.style.listStyleImage = "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAA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Fst2mtuTFGZC+zj1CJscansFLqyIkh63xRQM4MThO4Kg1FStttZ2vtAHZr4TYO5qOJMO99AxDDuiKCdiDpbhWApzHNAUM7iH3LFXyCi+K+Av0IzrnPIywf4to1Lj+kLU95y2f6Yxe9Ghv54yQyLAAAAABJRU5ErkJggg==)";*/

        /* Firefox standard button style */
        //xClearBtn.style.listStyleImage = url("chrome://global/skin/icons/searchfield-cancel.svg");
        //xClearBtnBox.setAttribute("class", xClearBtnBox.className + " textbox-search-clear");
        const localeString = "de_DE";
        const tooltipText = localeString.indexOf("zh") == -1?"Feldinhalt löschen":"\u6E05\u7A7A\u5404\u8F93\u5165\u680F";
        xClearBtn.setAttribute("tooltiptext", tooltipText);
        xClearBtnBox.appendChild(xClearBtn);
        return xClearBtnBox
    }

    var pageActionButtonbar = document.getElementById("page-action-buttons");
    var urlbarClearBtn = new createBtn();
    urlbarClearBtn.id = "urlbarClearButton"
    pageActionButtonbar.insertBefore(urlbarClearBtn, pageActionButtonbar.firstChild);

    function addSearchbarClearButton() { 
        var searchbarTextBox = document.getElementsByClassName("search-go-container")[0];
        var searchbarClearBtn = new createBtn();
        searchbarClearBtn.id = "searchClearButton"
        searchbarTextBox.insertBefore(searchbarClearBtn, searchbarTextBox.firstChild);
    }
    addSearchbarClearButton();

    var searchbar = document.getElementById('searchbar');
    var observers=new window.MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if(mutation.addedNodes!==null) {
                for (var i=0; i<mutation.addedNodes.length; i++) {
                    if (mutation.addedNodes[i].className=='searchbar-textbox') {
                        addSearchbarClearButton();
                        break;
                    }
                }
            }
        });
    });
    observers.observe(searchbar, {childList: true});

    function addFindbarClearButton() { 
        var findbarTextBox = document.getElementsByClassName("findbar-container")[0];
        var findhbarClearBtn = new createBtn();
        findbarClearBtn.id = "findClearButton"
        findbarTextBox.insertBefore(findbarClearBtn, findbarTextBox.firstChild);
    }

    var findbar = document.getElementById('panel-1-1');
    var observerf=new window.MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if(mutation.addedNodes!==null) {
                for (var i=0; i<mutation.addedNodes.length; i++) {
                    if (mutation.addedNodes[i].className=='findbar-textbox') {
                        addFindbarClearButton();
                        break;
                    }
                }
            }
        });
    });
    observerf.observe(findbar, {childList: true});

    createBtn();
})();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.