1

Screenshot

enter image description here

About

Adds three links next to the search box. Allows to open the regular Stackoverflow search in a new tab, or search using Google, or Symbolhound. Proved useful to find duplicates.

License

Public Domain

Version

0.5

Download

Install | View (userscripts.org)

Source

// Add search links (SO, Google, Symbolhound), allowing to open them in a new tab
//
// ==UserScript==
// @name           Stackoverflow Search in Tab
// @version        0.5
// @description    Adds tab-openable links besides the search box
// @namespace      data:,000000000000000000000000000000003fbf49fdcc8f9ddb8de0d10f6a5c32ca
// @include        http*://*stackexchange.com/*
// @include        http*://*stackoverflow.com/*
// @include        http*://*superuser.com/*
// @include        http*://*serverfault.com/*
// @include        http*://*doctype.com/*
// @include        http*://*askubuntu.com/*
// ==/UserScript==

(function(){

    // functionality
    var main = (function(){

        // append empty links next to search box
        $("#search").append(
            '<span style="position:absolute">'+
            '<a id="q_search1" href="/search?q=..." target=_blank title="Stacksearch, new tab">⬀</a>'+
            '&nbsp;'+
            '<a id="q_search2" href="//google.com/search?q=..." title=Google>G</a>' +
            '&nbsp;'+
            '<a id="q_search3" href="//symbolhound.com/?q=..." title=Symbolhound>$</a>'+
            '</span>'
        );

        // register update handler to populate ⬀ G $ links
        $("input[name=q]").bind("change input propertychange", function(){
            $("#q_search1").attr("href", "/search?q="+encodeURI(this.value));
            $("#q_search2").attr("href", "http://www.google.com/search?q=site:"+location.host+"+"+encodeURI(this.value));
            $("#q_search3").attr("href", "http://symbolhound.com/?q="+encodeURI(this.value)+"&l=&e=&n=&u="+location.host);
        });

        // temporary fix for missing space after [tag]
        var q = document.forms.search.q;
        if (q.value && q.value != "search") {
            q.value += " ";
        }


    });

    // inject function as last page script, so jQuery is available
    var script = document.createElement('script');
    script.type = "text/javascript";
    script.textContent = '(' + main.toString() + ')();';
    document.body.appendChild(script);

})();

Platform

Works with Opera.
Tested in Chrome, but shows the links below the search box there.

Caveats

Runs as injected script, not in Greasemonkey context. But does not load external resources.
Does not update links with pre-existing search box content on page load.
Supposed to respond to key presses and pasted text, at least works in Opera.

Alternatives

Two similar scripts exist for Google or Symbolhound respectively. Alternative searches can be invoked with sh: or gq: prefixes there:

0

You must log in to answer this question.

Browse other questions tagged .