Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create github-webhook-utils.user.js #207

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions github-webhook-utils.user.js
Original file line number Diff line number Diff line change
@@ -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));
})();