Skip to content

Instantly share code, notes, and snippets.

@simonwep
Last active January 15, 2020 15:58
Show Gist options
  • Select an option

  • Save simonwep/8d35f1a313bb10ebbfa5ed1f74b4c259 to your computer and use it in GitHub Desktop.

Select an option

Save simonwep/8d35f1a313bb10ebbfa5ed1f74b4c259 to your computer and use it in GitHub Desktop.

Revisions

  1. simonwep renamed this gist Jan 15, 2020. 1 changed file with 0 additions and 0 deletions.
  2. simonwep created this gist Dec 22, 2019.
    45 changes: 45 additions & 0 deletions github-auto-repo-confirm.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    // ==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);
    }
    });
    }
    }();