Skip to content

Instantly share code, notes, and snippets.

@simonwep
Last active January 15, 2020 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonwep/8d35f1a313bb10ebbfa5ed1f74b4c259 to your computer and use it in GitHub Desktop.
Save simonwep/8d35f1a313bb10ebbfa5ed1f74b4c259 to your computer and use it in GitHub Desktop.
Automatically inserts the repo-name in the security tab
// ==UserScript==
// @name GitHub auto confirm
// @version 1.0
// @namespace http://tampermonkey.net/
// @description Automatically inserts your repo name in dialogs
// @match https://*.github.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
!async function () {
const details = [...document.querySelectorAll('details')];
for (const detail of details) {
detail.addEventListener('toggle', function ret() {
if (detail.open) {
const button = detail.querySelector('summary');
const verifyInput = detail.querySelector('[name=verify]');
const form = detail.querySelector('form');
const match = location.href.match(/([^\/]+?\/[^\/]+?)\/settings$/i);
if (!verifyInput || !form || !match) {
detail.removeEventListener('toggle', ret);
return;
}
let offset = 0;
const [, str] = match;
const interval = setInterval(() => {
verifyInput.value = str.slice(0, offset);
offset++;
if (offset > str.length) {
form.dispatchEvent(new Event('change'));
clearInterval(interval);
if (button) {
console.log(`[GHAC] Auto-filled form for "${button.innerText.trim()}"`);
}
}
}, Math.random() * 25 + 10);
}
});
}
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment