Skip to content

Instantly share code, notes, and snippets.

@hexxone
Created November 20, 2023 14:10
Show Gist options
  • Save hexxone/f3636a5ce9f9e636f4718cf03ca8f92a to your computer and use it in GitHub Desktop.
Save hexxone/f3636a5ce9f9e636f4718cf03ca8f92a to your computer and use it in GitHub Desktop.
Gitlab Pipeline Auto-Toggle "Show Dependencies"
// ==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