GitHub-userscripts icon indicating copy to clipboard operation
GitHub-userscripts copied to clipboard

Userscript to auto enter repo name

Open Bluscream opened this issue 7 years ago • 7 comments

When having the "confirm with name of repo" dialog could you make it read and enter the name automatically?

I feel safe enough with that click on a big red button and copy pasting becomes annoying. Especially whith a huge amount of repos you want to edit

Bluscream avatar Jun 22 '18 05:06 Bluscream

Hi @Bluscream!

I don't know if I'd want to actually include this kind of userscript in this repo since it may cause some accidental deletions... but, I'll add it here for prosperity:

// ==UserScript==
// @name        GitHub Add Repo Name to Delete Dialog
// @version     0.1.2
// @description A userscript that adds your repo name to the delete dialog
// @license     MIT
// @author      Rob Garrison
// @namespace   https://github.com/Mottie
// @include     https://github.com/*
// @run-at      document-idle
// @require     https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=597950
// @icon        https://assets-cdn.github.com/pinned-octocat.svg
// ==/UserScript==
(() => {
	"use strict";

	function addName() {
		const name = document.getElementById("rename_field");
		if (name) {
			document.querySelector("form[action$='delete'] .input-block").value = name.value;
			const btn = document.querySelector("form[action$='delete'] .btn-danger");
			btn.removeAttribute("disabled");
			btn.removeAttribute("data-disable-invalid");
		}
	}

	document.addEventListener("ghmo:container", addName);
	addName();
})();

Mottie avatar Jun 22 '18 13:06 Mottie

Oops, I forgot to add the mutation observer... I've updated the code above.

Mottie avatar Jun 22 '18 13:06 Mottie

And... one more update to re-enable the delete button... done and actually tested this time! 😸

Mottie avatar Jun 22 '18 13:06 Mottie

Thanks, that one works just fine :3

Bluscream avatar Jun 30 '18 11:06 Bluscream

Can anyone please update this to work with the new format for transfer/change visibility?

Bluscream avatar Aug 25 '22 19:08 Bluscream

Sorry for the delay, here is the updated code:

// ==UserScript==
// @name        GitHub Add Repo Name to Delete Dialog
// @version     0.2.0
// @description A userscript that adds your repo name to the delete dialog
// @license     MIT
// @author      Rob Garrison
// @namespace   https://github.com/Mottie
// @match       https://github.com/*/*/settings
// @run-at      document-idle
// @require     https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=1108163
// @icon        https://assets-cdn.github.com/pinned-octocat.svg
// ==/UserScript==
(() => {
	"use strict";

	function addName() {
        const dialog = document.querySelector("details-dialog[aria-label='Delete repository']");
        if (dialog) {
            const name = document.getElementById("rename-field");
            if (name) {
                dialog.querySelector("form[action$='delete'] .input-block").value = name.value;
                const btn = dialog.querySelector("form[action$='delete'] .btn-danger");
                btn.removeAttribute("disabled");
                btn.removeAttribute("data-disable-invalid");
            }
        }
    }

	document.addEventListener("ghmo:container", addName);
	addName();
})();

Mottie avatar Oct 26 '22 00:10 Mottie

They updated it again :(

Bluscream avatar Jun 21 '23 22:06 Bluscream