Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

A screenshot

This script adds an edit link to the question summary, saving frequent editors the trouble of "entering" the question first.

Adjust includes as needed:

// ==UserScript==
// @name           Direct Question Edit Links
// @namespace      stackoverflow
// @include        *stackoverflow.com*
// ==/UserScript==

(function ()
{
    var cancelWaiting = false;
    window.setTimeout(function () { cancelWaiting = true; }, 5000);
    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(waitForQuestions);
        }
    }

    function waitForQuestions()
    {
        var jQuestions = $("div.question-summary");
        if (jQuestions.length == 0)
        {
            if (!cancelWaiting) window.setTimeout(waitForQuestions, 100);
        }
        else
        {
            addLinks(jQuestions);
        }
    }

    function addLinks(jQuestions)
    {
        jQuestions.each(function (i, e)
        {
            var jQuestion = $(e);
            var jHeader = $("div.summary h3", e);
            var id = $("a", jHeader)
                .attr("href")
                .match(/[0-9]+(?=\/)/)[0];
            var link = $("<a/>");
            link.attr("href", "/posts/" + id + "/edit");
            link.html("Edit");
            link.css("margin-left", "5px");
            link.css("color", "grey");
            link.css("font-size", "small");
            link.css("visibility", "hidden");

            jQuestion.mouseenter(function ()
            {
                link.css("visibility", "visible");
            });
            jQuestion.mouseleave(function ()
            {
                link.css("visibility", "hidden");
            });

            jHeader.append(link);
        });
    }
})();

Changes:

  • There were some issues with including jQuery directly, removed static reference.
share|improve this question

You must log in to answer this question.

Browse other questions tagged .