// ==UserScript==
// @name Add Timeline Button
// @namespace none
// @description Adds a "View Timeline" Button to StackOverflow
// @include @match http://*stackoverflow.com/questions*
// @include http://*serverfault*.askubuntu.com/questions*questions/*
// @include@match http://*superuser*.onstartups.com/questions*questions/*
// @include@match http://*stackexchange*.serverfault.com/questions*questions/*
// @include@match http://*askubuntu*.stackapps.com/questions*questions/*
// @include@match http://*answers*.onstartupsstackexchange.com/questions*questions/*
// @include @match http://*mathoverflow.net/questions*
// @include http://discuss.area51*.stackexchangestackoverflow.com/questions/*
// @include@match http://stackapps*.superuser.com/questions*questions/*
// @author csharpler
// @version 0.12
// ==/UserScript==
/*
* Version History
* * 0.1 (2013-06-11): First release
* * 0.2 (2013-06-12): * changed includes
* * improved regex
* - removed unsafeWindow, replaced with function wrapper
*/
withPages_jQuery(run);
function withPages_jQuery (NAMED_FunctionToRun) {
//--- Use named functions for clarity and debugging...
if var funcText = NAMED_FunctionToRun.toString (typeof);
unsafeWindow ! var funcName = 'undefined'funcText.replace (/^function\s+(\w+){\s*\((.|\n|\r)+$/, "$1");
$var script = unsafeWindowdocument.$;createElement ("script");
} script.textContent = funcText + "\n\n";
script.textContent += 'jQuery(document).ready( function () {' + funcName + '(jQuery);} );';
run document.body.appendChild (script);
};
function run(){
var uri = unsafeWindow.location.href;
var matchpost = urilocation.pathname.match(/(https?:\/\/[^\/]*\questions\/)questions(\/\d+\/\d+)[a-zA-Z\-]+$\D/i);
var newuri = match[1]"";
if(post && post.length > 1){
newuri = location.protocol + "posts""//" + match[2]location.host + "timeline";"/posts/" + post[1] + "/timeline";
}
$(".favoritecount").after("<a href='" + newuri + "'>View Timeline</a>");
}