Created
November 20, 2023 14:10
-
-
Save hexxone/f3636a5ce9f9e636f4718cf03ca8f92a to your computer and use it in GitHub Desktop.
Gitlab Pipeline Auto-Toggle "Show Dependencies"
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-Toggle GitLab Pipeline Dependencies | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Automatically toggle the "Show dependencies" button on Gitlab Pipeline pages | |
// @author hexx.one | |
// @match https://gitlab.yourserver.com/*/pipelines/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Function to wait for an element to exist | |
function waitForElement(selector, callback) { | |
const element = document.querySelector(selector); | |
if (element) { | |
callback(element); | |
} else { | |
setTimeout(() => waitForElement(selector, callback), 500); | |
} | |
} | |
// Function to toggle the "Show dependencies" button | |
function toggleDependenciesButton(button) { | |
// Check if the aria-checked attribute is 'false' and click the button if so | |
if (button.getAttribute('aria-checked') === 'false') { | |
button.click(); | |
} | |
} | |
// Wait for the "Show dependencies" button to exist in the DOM | |
waitForElement('[data-testid="show-links-toggle"] button[role="switch"]', toggleDependenciesButton); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment