Fork me on GitHub

Github pull request "Edit File" button

A Bookmarklet that adds this "Edit File" button to github.com pull request diffs like this:

Bookmarklet:

Add "Edit File" -- drag this to your bookmarks bar, visit a pull-request page and click it.

Code:

/**
 * Add this as a bookmarklet to add a "Edit File" button to each file when
 * viewing a pull-request.
 */
         
var branch = $(".pull-description .current-branch .css-truncate-target").last().text();
$(".file .minibutton").each(function(indx, button) {
   button = $(button);
   if (button.text().indexOf("View file @") === -1) {
      return;
   }
   var edit = button.clone();
   edit.text("Edit File");
   var href = edit.attr("href");
   edit.attr("href", href.replace(/\/blob\/[^\/]+\//,"/edit/" + branch + "/"));
   button.before(edit);
});