4

A screenshot

Another short and simple script, it adds numerical keyboard shortcuts to the favourite tags. Only works on those pages which have the favourite tags on them. The default modifier is Alt but the boolean expression at line 43 can easily be changed to some other modifier key combination.

Sorry to not provide a file for download but i am sure you will manage somehow, adjust includes as needed:

// ==UserScript==
// @name           Favourite Tags Numerical Keyboard Shortcuts
// @namespace      stackoverflow
// @include        *stackoverflow.com*
// ==/UserScript==

(function ()
{
    var cancelWaiting = false;
    jq_wait();

    function jq_wait()
    {
        if (typeof unsafeWindow.jQuery == 'undefined')
        {
            window.setTimeout(jq_wait, 100);
        } else
        {
            $ = unsafeWindow.jQuery;
            window.setTimeout(function () { cancelWaiting = true; }, 5000);
            $(document).ready(favs_wait);
        }
    }

    function favs_wait()
    {
        var items = $("#interestingTags .post-tag");
        if (items.length == 0)
        {
            if (cancelWaiting) return;
            window.setTimeout(favs_wait, 10);
        }
        else
        {
            items.each(function (i, elem)
            {
                if (i <= 9)
                {
                    var x = 48;
                    if (i < 9) x = 49 + i;
                    $(document).keyup(function (e)
                    {
                        if (!e.ctrlKey && !e.shiftKey && e.altKey && e.keyCode == x)
                        {
                            window.location.href = $(elem).attr("href");
                        }
                    });
                }
            });
        }
    }
})();

Edits:

  • Dreadful obi-wan...

0

You must log in to answer this question.

Browse other questions tagged .