Skip to content

Instantly share code, notes, and snippets.

@cordoval
Forked from fabpot/pr-labels.js
Created December 20, 2013 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cordoval/8049679 to your computer and use it in GitHub Desktop.
Save cordoval/8049679 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Adds Labels on Github Pull Request
// @namespace http://fabien.potencier.org
// @include https://github.com/*/*/pulls*
// @version 2
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==
$(function() {
$(".pulls-list .list-group-item h4").each(function() {
var pull_request = this;
$(pull_request).addClass("issues-list");
var issue_href = $("a:first", pull_request).attr("href").replace('/pull/', '/issues/');
$.getJSON("https://api.github.com/repos" + issue_href + "?access_token=YOUR_API_TOKEN", function(issue) {
$.each(issue.labels, function(l_i, label) {
var label_html = $('<span class="labels"><span style="background-color: #' + label.color + ' !important; color: #333 !important" data-name="' + label.name + '" class="label">' + label.name + '</span></span>');
$(pull_request).append(label_html);
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment