Skip to content

Instantly share code, notes, and snippets.

@romanbarczynski
Created July 1, 2013 08:54
Show Gist options
  • Save romanbarczynski/5899374 to your computer and use it in GitHub Desktop.
Save romanbarczynski/5899374 to your computer and use it in GitHub Desktop.
Greasemonkey script for hg commands on pull requests page...
// ==UserScript==
// @name Bitbucket show merge commandline
// @namespace http://www.romke.net/static/grease/bb-pull-merge
// @description show merge commandline
// @include https://bitbucket.org/*/pull-request/*
// @grant none
// @version 1
// ==/UserScript==
if (! document.getElementsByClassName("conflicts-detected")[0].classList.contains("conflicts") &&
document.getElementsByClassName("merge-commands").length > 0) {
var edit = document.getElementById("edit-pullrequest");
var nbut = document.createElement("a");
nbut.setAttribute("id", "hg-commands");
nbut.setAttribute("class", "aui-button aui-style");
nbut.setAttribute("href", "#");
nbut.innerHTML = "<span>hg</span>"
document.getElementsByClassName("compare-widget-container")[0].style.width = 'auto';
edit.parentNode.insertBefore(nbut, edit);
document.getElementById('hg-commands').onclick = function() {
var merge_commands = document.getElementsByClassName("merge-commands")[0];
if (merge_commands.parentNode.tagName == 'HEADER') {
merge_commands.style.margin = 'auto';
document.getElementsByClassName("conflicts-detected")[0].appendChild(merge_commands);
} else {
merge_commands.style.margin = '20px';
document.getElementById("pull-request-header").appendChild(merge_commands);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment