-
-
Save lsegal/1305443 to your computer and use it in GitHub Desktop.
add links to github from rubydoc.info docs in the 'github' area.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name RubyDoc.info Github Source Links | |
// @description Adds view source on github links to rubydoc.info | |
// @author Jonathan Rochkind | |
// @include http://*rubydoc.info/github/* | |
// @version 1.0 | |
// ==/UserScript== | |
if (match = window.location.pathname.match(/^\/github\/([^\/]+\/[^/]+)\/([^/]+)/)) { | |
var github_project = match[1]; | |
var github_commit = match[2]; | |
$(".source_code").each( function() { | |
if (match = $(this).find(".info.file").text().match(/^# File '([^']+)', line (\d+)/)) { | |
var file = match[1]; | |
var line = match[2]; | |
var url = "https://github.com/" + github_project + | |
"/blob/" + github_commit + "/" + | |
file + | |
"#L" + line; | |
$(this).before(' [<a target="_new" href="' + url + '">View on Github</a>]'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment