|
// ==UserScript== |
|
// @name Make Gitlab navigation great again |
|
// @namespace http://tampermonkey.net/ |
|
// @version 0.2 |
|
// @description Trying to make the new Gitlab navigation feel less crappy |
|
// @author Gabriel Ferreira |
|
// @match https://gitlab.com/* |
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=gitlab.com |
|
// @grant none |
|
// ==/UserScript== |
|
|
|
(function() { |
|
'use strict'; |
|
var top_bar_container = document.getElementsByClassName("top-bar-container"); |
|
// Create subdivision to hold buttons on the far-right of the screen, |
|
// where they were before Gitlab had a brain fart |
|
var right_buttons_div = document.createElement('div'); |
|
right_buttons_div.id = "good_old_menu"; |
|
|
|
right_buttons_div.class = "gl-display-flex gl-p-3 gl-gap-1 gl-flex-direction-column"; |
|
// Copy search bar |
|
right_buttons_div.appendChild(document.getElementById('super-sidebar-search')); |
|
// Copy issues button |
|
right_buttons_div.appendChild(document.querySelectorAll('[data-testid="issues-shortcut-button"]')[0]); |
|
// Copy merge requests button |
|
right_buttons_div.appendChild(document.querySelectorAll('[data-testid="merge-requests-shortcut-button"]')[0]); |
|
// Copy todo button |
|
right_buttons_div.appendChild(document.querySelectorAll('[data-testid="todos-shortcut-button"]')[0]); |
|
// Copy + button |
|
right_buttons_div.appendChild(document.getElementById('create-menu-toggle')); |
|
// Copy user button |
|
right_buttons_div.appendChild(document.querySelectorAll('[data-testid="user-dropdown"]')[0]); |
|
|
|
// Adjust display to inline-block to get them in a row |
|
for (var i = 0; i < right_buttons_div.children.length; i++) { |
|
// Prevent merge requests button from being retarded |
|
right_buttons_div.children[i].classList.remove("gl-w-full"); |
|
right_buttons_div.children[i].style.display = "inline-block"; |
|
// Add some spacing |
|
right_buttons_div.children[i].style.padding = "8px"; |
|
} |
|
// Put the top bar back to where it belong |
|
top_bar_container[0].appendChild(right_buttons_div); |
|
|
|
// Reduce size of stupid side bar |
|
document.getElementById('super-sidebar').style.width = "210px"; |
|
// Increase size of actually useful search bar |
|
document.getElementById('super-sidebar-search').style.width = "400px"; |
|
|
|
|
|
var top_level_entries_section = document.querySelectorAll('[data-testid="static-items-section"]')[0]; |
|
if (top_level_entries_section) |
|
{ |
|
top_level_entries_section = top_level_entries_section.parentElement; |
|
|
|
// Move useful sections to the outer list |
|
var pinned_entries = ["activity", |
|
"files", |
|
"project_issue_list", |
|
"project_merge_request_list", |
|
"pipelines" |
|
] |
|
for (i = 0; i < pinned_entries.length; i++) |
|
{ |
|
var entry_to_move = document.querySelectorAll('[data-track-label="'+pinned_entries[i]+'"]')[0]; |
|
if (entry_to_move) |
|
{ |
|
top_level_entries_section.appendChild(entry_to_move); |
|
} |
|
} |
|
} |
|
// Remove dumb sections |
|
var elements_to_remove = ["menu-section-button-pinned", |
|
"menu-section-button-plan", |
|
"menu-section-button-manage", |
|
"menu-section-button-code", |
|
"menu-section-button-build", |
|
"menu-section-button-deploy", |
|
"menu-section-button-operate", |
|
"menu-section-button-monitor", |
|
"menu-section-button-analyze" |
|
] |
|
for (i = 0; i < elements_to_remove.length; i++) |
|
{ |
|
var left_menu_section_to_remove = document.getElementById(elements_to_remove[i]); |
|
if (left_menu_section_to_remove) |
|
{ |
|
left_menu_section_to_remove.parentElement.innerHTML = ""; |
|
} |
|
} |
|
|
|
})(); |