Skip to main content
added 17 characters in body
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64

Good idea. There's a few minor niggles, though:

  1. Don't use unsafeWindow, this will break in Chrome and will not even work in Firefox+Greasemonkey if the effective @grant changes.

  2. Avoid leading * wildcards in @includes, if you can help it. This is a big performance hit. @match limits the wildcard scope and performs much better and reports the sites/security correctly on Chrome. This gets all current SE sites:

     // @match       *://*.askubuntu.com/questions/*
     // @match       *://*.onstartups.com/questions/*
     // @match       *://*.serverfault.com/questions/*
     // @match       *://*.stackapps.com/questions/*
     // @match       *://*.stackexchange.com/questions/*
     // @match       *://*.stackoverflow.com/questions/*
     // @match       *://*.superuser.com/questions/*
    
  3. The regex match needs to be more robust, to account for all legal characters in the URL, and for anchors.

  4. Use injection so that the script will work on most userscript-capable browsers (Chrome, Firefox, Opera, Safari, etc.).


Here's a variant of the script I've been using. It also adds a "revisions" link since a post's history is sometimes hidden. It works on Chrome and Firefox, and should work on most other userscript-capable browsers:

###View the source at GitHub Gist.

####Install button:Install from GitHub Gist


Change log:

Versn  Date        Change
-----  ----------  --------------------------------------------------------------------------
1.5    2019-08-28  Updated Metadata and Lint config for Tampermonkey changes and performance.
1.4    2019-08-28  SE renamed `short-link` to `js-share-link`.
1.3    2016-08-19  SE changed Timelines. Answers were separated out from the question timeline.
1.2    2015-07-22  Updated match list.
1.1    2014-02-07  Added revisions link. (On private copy, didn't update Gist until 2015.)
1.0    2013-06-11  Initial release to the public.

Good idea. There's a few minor niggles, though:

  1. Don't use unsafeWindow, this will break in Chrome and will not even work in Firefox+Greasemonkey if the effective @grant changes.

  2. Avoid leading * wildcards in @includes, if you can help it. This is a big performance hit. @match limits the wildcard scope and performs much better and reports the sites/security correctly on Chrome. This gets all current SE sites:

     // @match       *://*.askubuntu.com/questions/*
     // @match       *://*.onstartups.com/questions/*
     // @match       *://*.serverfault.com/questions/*
     // @match       *://*.stackapps.com/questions/*
     // @match       *://*.stackexchange.com/questions/*
     // @match       *://*.stackoverflow.com/questions/*
     // @match       *://*.superuser.com/questions/*
    
  3. The regex match needs to be more robust, to account for all legal characters in the URL, and for anchors.

  4. Use injection so that the script will work on most userscript-capable browsers (Chrome, Firefox, Opera, Safari, etc.).


Here's a variant of the script I've been using. It also adds a "revisions" link since a post's history is sometimes hidden. It works on Chrome and Firefox, and should work on most other userscript-capable browsers:

###View the source at GitHub Gist.

#Install from GitHub Gist


Change log:

Versn  Date        Change
-----  ----------  --------------------------------------------------------------------------
1.5    2019-08-28  Updated Metadata and Lint config for Tampermonkey changes and performance.
1.4    2019-08-28  SE renamed `short-link` to `js-share-link`.
1.3    2016-08-19  SE changed Timelines. Answers were separated out from the question timeline.
1.2    2015-07-22  Updated match list.
1.1    2014-02-07  Added revisions link. (On private copy, didn't update Gist until 2015.)
1.0    2013-06-11  Initial release to the public.

Good idea. There's a few minor niggles, though:

  1. Don't use unsafeWindow, this will break in Chrome and will not even work in Firefox+Greasemonkey if the effective @grant changes.

  2. Avoid leading * wildcards in @includes, if you can help it. This is a big performance hit. @match limits the wildcard scope and performs much better and reports the sites/security correctly on Chrome. This gets all current SE sites:

     // @match       *://*.askubuntu.com/questions/*
     // @match       *://*.onstartups.com/questions/*
     // @match       *://*.serverfault.com/questions/*
     // @match       *://*.stackapps.com/questions/*
     // @match       *://*.stackexchange.com/questions/*
     // @match       *://*.stackoverflow.com/questions/*
     // @match       *://*.superuser.com/questions/*
    
  3. The regex match needs to be more robust, to account for all legal characters in the URL, and for anchors.

  4. Use injection so that the script will work on most userscript-capable browsers (Chrome, Firefox, Opera, Safari, etc.).


Here's a variant of the script I've been using. It also adds a "revisions" link since a post's history is sometimes hidden. It works on Chrome and Firefox, and should work on most other userscript-capable browsers:

###View the source at GitHub Gist.

###Install button:Install from GitHub Gist


Change log:

Versn  Date        Change
-----  ----------  --------------------------------------------------------------------------
1.5    2019-08-28  Updated Metadata and Lint config for Tampermonkey changes and performance.
1.4    2019-08-28  SE renamed `short-link` to `js-share-link`.
1.3    2016-08-19  SE changed Timelines. Answers were separated out from the question timeline.
1.2    2015-07-22  Updated match list.
1.1    2014-02-07  Added revisions link. (On private copy, didn't update Gist until 2015.)
1.0    2013-06-11  Initial release to the public.
deleted 1189 characters in body
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64

View###View the source at GitHub Gist.

Install from GitHub Gist

# Install from GitHub Gist

Change log:

// ==UserScript==
// @name        Stack Exchange: Add Timeline and Revisions links to posts
// @description Adds links to posts to always show history and links to questions to show the Timeline".
// @namespace   StackExchange
// @match       *://*.askubuntu.com/questions/*
// @match       *://*.mathoverflow.net/questions/*
// @match       *://*.serverfault.com/questions/*
// @match       *://*.stackapps.com/questions/*
// @match       *://*.stackexchange.com/questions/*
// @match       *://*.stackoverflow.com/questions/*
// @match       *://*.superuser.com/questions/*
// @version     1.3
// @history     1.3 SE changed Timelines. Answers were separated out from the question timeline.
// @history     1.2 Updated match list
// @history     1.1 Added revisions link
// @grant       none
// ==/UserScript==

$(".post-menu").each ( function (J) {
    var jThis   = $(this);
    var href    = jThis.find ('a[class="short-link"]').attr ("href");
    var idMtch  = href.split (/[qa]\/(\d+)/);
    if (idMtch.length > 2) {
        var id  = idMtch[1];
        jThis.append (
            '<span class="lsep">|</span><a href="/posts/' + id + '/revisions">revisions</a>'
        );
        jThis.append (
            '<span class="lsep">|</span><a href="/posts/' + id + '/timeline">timeline</a>'
        );
    }
} );
$(".revcell3.vm>div").each (function () {
    //-- Looks like a timebomb...
    guid = $(this).find ("a").attr ("href").match (/\w{8} (?:-\w{4} ){3}-\w{12}/)[0];
    $(this).prepend ('<a href="#rev' + guid + '">link</a><span class="lsep">|</span>');
} );

Versn  Date        Change
-----  ----------  --------------------------------------------------------------------------
1.5    2019-08-28  Updated Metadata and Lint config for Tampermonkey changes and performance.
1.4    2019-08-28  SE renamed `short-link` to `js-share-link`.
1.3    2016-08-19  SE changed Timelines. Answers were separated out from the question timeline.
1.2    2015-07-22  Updated match list.
1.1    2014-02-07  Added revisions link. (On private copy, didn't update Gist until 2015.)
1.0    2013-06-11  Initial release to the public.

View the source at GitHub Gist.

Install from GitHub Gist

// ==UserScript==
// @name        Stack Exchange: Add Timeline and Revisions links to posts
// @description Adds links to posts to always show history and links to questions to show the Timeline".
// @namespace   StackExchange
// @match       *://*.askubuntu.com/questions/*
// @match       *://*.mathoverflow.net/questions/*
// @match       *://*.serverfault.com/questions/*
// @match       *://*.stackapps.com/questions/*
// @match       *://*.stackexchange.com/questions/*
// @match       *://*.stackoverflow.com/questions/*
// @match       *://*.superuser.com/questions/*
// @version     1.3
// @history     1.3 SE changed Timelines. Answers were separated out from the question timeline.
// @history     1.2 Updated match list
// @history     1.1 Added revisions link
// @grant       none
// ==/UserScript==

$(".post-menu").each ( function (J) {
    var jThis   = $(this);
    var href    = jThis.find ('a[class="short-link"]').attr ("href");
    var idMtch  = href.split (/[qa]\/(\d+)/);
    if (idMtch.length > 2) {
        var id  = idMtch[1];
        jThis.append (
            '<span class="lsep">|</span><a href="/posts/' + id + '/revisions">revisions</a>'
        );
        jThis.append (
            '<span class="lsep">|</span><a href="/posts/' + id + '/timeline">timeline</a>'
        );
    }
} );
$(".revcell3.vm>div").each (function () {
    //-- Looks like a timebomb...
    guid = $(this).find ("a").attr ("href").match (/\w{8} (?:-\w{4} ){3}-\w{12}/)[0];
    $(this).prepend ('<a href="#rev' + guid + '">link</a><span class="lsep">|</span>');
} );

###View the source at GitHub Gist.

# Install from GitHub Gist

Change log:


Versn  Date        Change
-----  ----------  --------------------------------------------------------------------------
1.5    2019-08-28  Updated Metadata and Lint config for Tampermonkey changes and performance.
1.4    2019-08-28  SE renamed `short-link` to `js-share-link`.
1.3    2016-08-19  SE changed Timelines. Answers were separated out from the question timeline.
1.2    2015-07-22  Updated match list.
1.1    2014-02-07  Added revisions link. (On private copy, didn't update Gist until 2015.)
1.0    2013-06-11  Initial release to the public.
Mod Moved Comments To Chat
deleted 671 characters in body
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64
// ==UserScript==
// @name        Stack Exchange: Add Timeline and Revisions links to posts
// @description Adds links to posts to always show history and links to questions to show the Timeline".
// @namespace   StackExchange
// @match       *://*.askubuntu.com/questions/*
// @match       *://*.mathoverflow.net/questions/*
// @match       *://*.serverfault.com/questions/*
// @match       *://*.stackapps.com/questions/*
// @match       *://*.stackexchange.com/questions/*
// @match       *://*.stackoverflow.com/questions/*
// @match       *://*.superuser.com/questions/*
// @version     1.23
// @history     1.3 SE changed Timelines. Answers were separated out from the question timeline.
// @history     1.2 Updated match list
// @history     1.1 Added revisions link
// ==/UserScript==

function@grant addUtilityLinks ($) {

    none
// ==/UserScript==

$(".post-menu").each ( function (J) {
        var jThis   = $(this);
        var href    = jThis.find ('a[class="short-link"]').attr ("href");
        var idMtch  = href.split (/[qa]\/(\d+)/);
        if (idMtch.length > 2) {
            var id  = idMtch[1];
            jThis.append (
                '<span class="lsep">|</span><a href="/posts/' + id + '/revisions">revisions</a>'
            );

            if (J === 0) {  //-- Question only
                jThis.append (
                    '<span class="lsep">|</span><a href="/posts/' + id + '/timeline">timeline</a>'
                );
            }
        }
    } );
    $(".revcell3.vm>div").each (function () {
        //-- Looks like a timebomb...
        guid = $(this).find ("a").attr ("href").match (/\w{8} (?:-\w{4} ){3}-\w{12}/)[0];
        $(this).prepend ('<a href="#rev' + guid + '">link</a><span class="lsep">|</span>');
    } );
}

withPages_jQuery (addUtilityLinks);

function withPages_jQuery (NAMED_FunctionToRun) {
    //--- Use named functions for clarity and debugging...
    var funcText        = NAMED_FunctionToRun.toString ();
    var funcName        = funcText.replace (/^function\s+(\w+)\s*\((.|\n|\r)+$/, "$1");
    var script          = document.createElement ("script");
    script.textContent  = funcText + "\n\n";
    script.textContent += 'jQuery(document).ready( function () {' + funcName + '(jQuery);} );';
    document.body.appendChild (script);
};
// ==UserScript==
// @name        Stack Exchange: Add Timeline and Revisions links to posts
// @description Adds links to posts to always show history and links to questions to show the Timeline".
// @namespace   StackExchange
// @match       *://*.askubuntu.com/questions/*
// @match       *://*.mathoverflow.net/questions/*
// @match       *://*.serverfault.com/questions/*
// @match       *://*.stackapps.com/questions/*
// @match       *://*.stackexchange.com/questions/*
// @match       *://*.stackoverflow.com/questions/*
// @match       *://*.superuser.com/questions/*
// @version     1.2
// @history     1.2 Updated match list
// @history     1.1 Added revisions link
// ==/UserScript==

function addUtilityLinks ($) {

    $(".post-menu").each ( function (J) {
        var jThis   = $(this);
        var href    = jThis.find ('a[class="short-link"]').attr ("href");
        var idMtch  = href.split (/[qa]\/(\d+)/);
        if (idMtch.length > 2) {
            var id  = idMtch[1];
            jThis.append (
                '<span class="lsep">|</span><a href="/posts/' + id + '/revisions">revisions</a>'
            );

            if (J === 0) {  //-- Question only
                jThis.append (
                    '<span class="lsep">|</span><a href="/posts/' + id + '/timeline">timeline</a>'
                );
            }
        }
    } );
    $(".revcell3.vm>div").each (function () {
        //-- Looks like a timebomb...
        guid = $(this).find ("a").attr ("href").match (/\w{8} (?:-\w{4} ){3}-\w{12}/)[0];
        $(this).prepend ('<a href="#rev' + guid + '">link</a><span class="lsep">|</span>');
    } );
}

withPages_jQuery (addUtilityLinks);

function withPages_jQuery (NAMED_FunctionToRun) {
    //--- Use named functions for clarity and debugging...
    var funcText        = NAMED_FunctionToRun.toString ();
    var funcName        = funcText.replace (/^function\s+(\w+)\s*\((.|\n|\r)+$/, "$1");
    var script          = document.createElement ("script");
    script.textContent  = funcText + "\n\n";
    script.textContent += 'jQuery(document).ready( function () {' + funcName + '(jQuery);} );';
    document.body.appendChild (script);
};
// ==UserScript==
// @name        Stack Exchange: Add Timeline and Revisions links to posts
// @description Adds links to posts to always show history and links to questions to show the Timeline".
// @namespace   StackExchange
// @match       *://*.askubuntu.com/questions/*
// @match       *://*.mathoverflow.net/questions/*
// @match       *://*.serverfault.com/questions/*
// @match       *://*.stackapps.com/questions/*
// @match       *://*.stackexchange.com/questions/*
// @match       *://*.stackoverflow.com/questions/*
// @match       *://*.superuser.com/questions/*
// @version     1.3
// @history     1.3 SE changed Timelines. Answers were separated out from the question timeline.
// @history     1.2 Updated match list
// @history     1.1 Added revisions link
// @grant       none
// ==/UserScript==

$(".post-menu").each ( function (J) {
    var jThis   = $(this);
    var href    = jThis.find ('a[class="short-link"]').attr ("href");
    var idMtch  = href.split (/[qa]\/(\d+)/);
    if (idMtch.length > 2) {
        var id  = idMtch[1];
        jThis.append (
            '<span class="lsep">|</span><a href="/posts/' + id + '/revisions">revisions</a>'
        );
        jThis.append (
            '<span class="lsep">|</span><a href="/posts/' + id + '/timeline">timeline</a>'
        );
    }
} );
$(".revcell3.vm>div").each (function () {
    //-- Looks like a timebomb...
    guid = $(this).find ("a").attr ("href").match (/\w{8} (?:-\w{4} ){3}-\w{12}/)[0];
    $(this).prepend ('<a href="#rev' + guid + '">link</a><span class="lsep">|</span>');
} );
added 129 characters in body
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64
Loading
SE sites now frequently use https.
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64
Loading
added 1 characters in body
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64
Loading
Correctly handle deleted posts
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64
Loading
added 49 characters in body
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64
Loading
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64
Loading