From 856246a06abc922182ea1808d28e7a981a78cc21 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Sat, 25 May 2024 20:29:26 +0200 Subject: [PATCH 1/2] Create github-webhook-utils.user.js --- github-webhook-utils.user.js | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 github-webhook-utils.user.js diff --git a/github-webhook-utils.user.js b/github-webhook-utils.user.js new file mode 100644 index 0000000..7fb7d90 --- /dev/null +++ b/github-webhook-utils.user.js @@ -0,0 +1,40 @@ +// ==UserScript== +// @name GitHub Webhook Events Toggle Checkboxes +// @version 1.0.0 +// @description Adds additional buttons to the github webhook event settings page, to easily Check, Uncheck and Invert all checkboxes +// @license MIT +// @author Bluscream, Mottie +// @namespace https://github.com/Mottie +// @match https://github.com/*/*/settings/hooks/* +// @run-at document-idle +// @grant GM_addStyle +// @grant GM.addStyle +// @icon https://github.githubassets.com/pinned-octocat.svg +// @updateURL https://raw.githubusercontent.com/Mottie/GitHub-userscripts/master/github-webhook-utils.user.js +// @downloadURL https://raw.githubusercontent.com/Mottie/GitHub-userscripts/master/github-webhook-utils.user.js +// @supportURL https://github.com/Mottie/GitHub-userscripts/issues +// ==/UserScript== + +(function() { + 'use strict'; + + const actions = ['invert', 'check', 'uncheck']; + const buttons = actions.map(action => { + const btn = document.createElement('button'); + btn.textContent = `${action} All`; + btn.style.position = 'fixed'; + btn.style.bottom = `${30 * (actions.indexOf(action) + 1)}px`; // Adjust position based on index + btn.style.right = '20px'; + btn.style.marginBottom = '1px'; // Additional spacing below the button + btn.style.zIndex = '1000'; + btn.onclick = () => { + const selectors = document.querySelectorAll('div.hook-event-selector input[type="checkbox"]'); + selectors.forEach(checkbox => { + checkbox.checked = action === 'invert'?!checkbox.checked : action === 'check'; + }); + }; + return btn; + }); + + buttons.forEach(btn => document.body.appendChild(btn)); +})(); From d891469b16d42408ec348ac6066dbb535118f920 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Sat, 25 May 2024 20:33:00 +0200 Subject: [PATCH 2/2] Update github-webhook-utils.user.js uppercase A looked ugly --- github-webhook-utils.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-webhook-utils.user.js b/github-webhook-utils.user.js index 7fb7d90..c4d4a2e 100644 --- a/github-webhook-utils.user.js +++ b/github-webhook-utils.user.js @@ -21,7 +21,7 @@ const actions = ['invert', 'check', 'uncheck']; const buttons = actions.map(action => { const btn = document.createElement('button'); - btn.textContent = `${action} All`; + btn.textContent = `${action} all`; btn.style.position = 'fixed'; btn.style.bottom = `${30 * (actions.indexOf(action) + 1)}px`; // Adjust position based on index btn.style.right = '20px';