Mottie / GitHub-userscripts

Userscripts to add functionality to GitHub
https://greasyfork.org/en/users/24847
MIT License
1.81k stars 167 forks source link

Userscript to auto enter repo name #49

Open Bluscream opened 6 years ago

Bluscream commented 6 years ago

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

Mottie commented 6 years ago

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 commented 6 years ago

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

Mottie commented 6 years ago

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

Bluscream commented 6 years ago

Thanks, that one works just fine :3

Bluscream commented 2 years ago

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

Mottie commented 1 year ago

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();
})();
Bluscream commented 1 year ago

They updated it again :(