Last active
January 15, 2020 15:58
-
-
Save simonwep/8d35f1a313bb10ebbfa5ed1f74b4c259 to your computer and use it in GitHub Desktop.
Automatically inserts the repo-name in the security tab
This file contains hidden or 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 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