Skip to content

Instantly share code, notes, and snippets.

@Dessix
Last active November 17, 2016 18:12
Show Gist options
  • Save Dessix/d1d4c4090f4348cf030ec61977952898 to your computer and use it in GitHub Desktop.
Save Dessix/d1d4c4090f4348cf030ec61977952898 to your computer and use it in GitHub Desktop.
Github Script - Flip Comparison Direction - Install: https://git.io/vXQ4p
// ==UserScript==
// @name Github - Flip Comparison
// @namespace http://dessix.net/userscripts/github/flip
// @version 0.1
// @updateURL https://gist.github.com/Dessix/d1d4c4090f4348cf030ec61977952898/raw/GithubFlipComparison.user.js
// @description Flip github branches in comparison.
// @author Dessix
// @match *://github.com/*/*/compare/*...*
// @grant none
// @require https://code.jquery.com/jquery-3.1.1.slim.min.js
// ==/UserScript==
(function() {
(function ($, undefined) {
'use strict';
function swapComparison() {
const path = window.location.pathname;
const reg = /^(.*\/)([^\/]+)\.{3}(.*)$/;
const dest = path.replace(reg, "\$1\$3...\$2");
//alert(`swapping from ${reg} => ${dest}`);
window.location.pathname = dest;
}
$(function() {
$(".range-editor.js-range-editor")
.find(".range-editor-icon")
.addClass("btn")
.addClass("text-green")
.click(swapComparison)
.css("border", "solid 1px green")
.css("border-radius", "3px")
.css("padding", "2px")
.css("transform", "scale(1.7)")
.css("transform-origin", "center center")
;
});
})(window.jQuery.noConflict(true));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment