Last active
December 18, 2020 12:56
-
-
Save josh-richardson/fde00680807e67b762ad1c15fa6d11df to your computer and use it in GitHub Desktop.
Auto-expand GitLab breadcrumb
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 Auto-expand GitLab breadcrumb | |
// @version 0.1 | |
// @description GitLab's breadcrumb always collapses even when it doesn't need to, this fixes that, but it may be fragile... | |
// @author You | |
// @match https://gitlab.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const breadcrumb = document.getElementsByClassName("list-unstyled breadcrumbs-list js-breadcrumbs-list")[0]; | |
if (breadcrumb) { | |
const collapsed = Array.from(breadcrumb?.getElementsByClassName("dropdown")[0]?.getElementsByClassName("group-path js-breadcrumb-item-text")).map(i => { | |
return [i.href, Array.from(i.childNodes).filter(i => i.nodeType == Node.TEXT_NODE)[0].wholeText]; | |
}).reverse() | |
breadcrumb.getElementsByClassName("dropdown")[0].remove() | |
for (const element of collapsed) { | |
let source = ` | |
<li> | |
<a class="group-path breadcrumb-item-text js-breadcrumb-item-text" style="text-transform: capitalize;" href="${element[0]}">${element[1]}</a> | |
<svg class="s8 breadcrumbs-list-angle" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" id="angle-right"><path fill-rule="evenodd" d="M5.293 3.707a1 1 0 0 1 1.414-1.414l5 5a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414-1.414L9.586 8 5.293 3.707z"></path></svg> | |
</li> | |
` | |
breadcrumb.children[0].insertAdjacentHTML('afterend', source); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment