Last active
October 16, 2017 07:19
-
-
Save manuhabitela/4cc2e60e6946a9fc72eb8a30565f41d5 to your computer and use it in GitHub Desktop.
Assigned merge request shortcuts in Gitlab Menu UserScript
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 GitlabCreatedMRs | |
// @description Link to created merge requests in Gitlab menu | |
// @version 0.1 | |
// @author e.pelletier | |
// @license MIT | |
// @run-at document-end | |
// @match https://git.vtech.fr/* | |
// @match https://gitlab.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
/* add the link in the nav in the right */ | |
var assignedButton = document.querySelector('.badge.merge-requests-count').parentNode.parentNode; | |
var createdButton = assignedButton.cloneNode(true); | |
var createdButtonLink = createdButton.querySelector('a'); | |
var createdButtonIcon = createdButton.querySelector('svg'); | |
assignedButton.querySelector('a').setAttribute('title', 'Assigned merge requests'); | |
createdButtonLink.setAttribute('title', 'Created merge requests'); | |
createdButtonLink.setAttribute( | |
'href', | |
createdButtonLink.getAttribute('href').replace('assignee_id', 'author_id') | |
); | |
createdButtonLink.setAttribute( | |
'data-original-title', | |
'Created merge requests' | |
); | |
createdButtonLink.href.replace('assignee_id', 'author_id'); | |
createdButton.querySelector('.badge.merge-requests-count').innerHTML = '?'; | |
var currentStyle = createdButtonIcon.style.cssText; | |
var newStyle = (currentStyle.length ? currentStyle + '; ' : '') + 'transform: scaleX(-1)'; | |
createdButtonIcon.style.cssText = newStyle; | |
assignedButton.after(createdButton); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment