Skip to content

Instantly share code, notes, and snippets.

@fillet54
Created January 24, 2016 20:15
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 fillet54/2ec66bfd6ce8da9f0a7f to your computer and use it in GitHub Desktop.
Save fillet54/2ec66bfd6ce8da9f0a7f to your computer and use it in GitHub Desktop.
Userscript to add links to Bitbucket Cloud's app switcher menu to make it consistent with other Atlassian Products
// ==UserScript==
// @name Bitbucket Cloud Menu
// @namespace http://philgomez.com
// @include https://bitbucket.org/*
// @version 1.2
// ==/UserScript==
//
function runWithJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")(jQuery.noConflict(true));";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function addMenuLinks($) {
var links = [
{display: "JIRA", url:"http://fiftycuatro.atlassian.net/MyJiraHome.jspa"},
{display: "Confluence", url:"http://fiftycuatro.atlassian.net/wiki"},
{display: "Bitbucket", url:"http://bitbucket.org/fiftycuatro", checked: true}
];
var linkList = $('<ul/>')
.addClass('nav-links')
.attr('role', 'radiogroup');
$.each(links, function(index, link) {
var li = $('<li/>')
.addClass('nav-link')
.appendTo(linkList);
var aLink = $('<a/>')
.addClass('aui-dropdown2-radio')
.attr('title', link.url)
.attr('href', link.url)
.attr('role', 'radio')
.text(link.display)
if (link.checked) {
aLink.addClass('aui-dropdown2-checked')
.attr('aria-checked', true)
} else {
aLink.attr('aria-checked', false)
}
aLink.appendTo(li);
});
$('#app-switcher').empty().append(linkList);
}
runWithJQuery(addMenuLinks);
@fillet54
Copy link
Author

Customize the links array with the links you want to be displayed.

To install:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment