Last active
December 10, 2015 11:00
-
-
Save tijn/00a494a77645161549b6 to your computer and use it in GitHub Desktop.
Sort pull requests by number
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 Bitbucket: sort pull requests by number | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Sort pull requests by number | |
// @author Victor Yap, changes by Tijn Schuurmans | |
// @match https://bitbucket.org/*/*/pull-requests/* | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
$(document).ready(function(){ | |
document.bitbucket_augment = { | |
number: function(row){ | |
var nr = $(row).find(".title div a").attr('title').match(/\#(\d+)\:/)[1]; | |
return parseInt(nr); | |
}, | |
sort_pull_requests_by_number: function(){ | |
var $rows = $("table.pullrequest-list tbody tr"); | |
$rows.remove(); | |
var sorted = $rows.sort(function(left, right){ | |
var leftNr = document.bitbucket_augment.number(left); | |
var rightNr = document.bitbucket_augment.number(right); | |
return leftNr > rightNr; | |
}); | |
sorted.each(function(i, elem){ | |
$("table.pullrequest-list tbody").append(elem); | |
}); | |
} | |
}; | |
document.bitbucket_augment.sort_pull_requests_by_number(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment