Created
October 17, 2012 15:59
-
-
Save agnoster/3906361 to your computer and use it in GitHub Desktop.
Like editing files in an open pull request?
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
/** | |
* 1) Use http://defunkt.io/dotjs/ | |
* 2) Install this into ~/.js/github.com.js | |
* 3) Enjoy a button to edit any file on a pull request (some restrictions may apply, void where prohibited) | |
* | |
* Note: this will replace the "View file @ ...", which I find pretty useless (and it's contained in the edit mode, | |
* anyway). However, if you want to look at files where you don't have access to edit them, this will suck. | |
*/ | |
function getBranch() { | |
return $($('.pull-description .commit-ref')[1]).text().trim() | |
} | |
function updateButtons() { | |
var branch = getBranch() | |
if (!branch) return // couldn't get a branch? NOT A PULL REQUEST | |
$('.actions .minibutton').each(function(i, el) { | |
el = $(el) | |
el.attr('href', el.attr('href').replace(/blob\/[a-z0-9]+/, 'edit/' + branch)) | |
el.html('Edit file @ <code>' + branch + '</code>') | |
}) | |
} | |
$(function() { | |
updateButtons() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great stuff!