Del Confirm

del confirm

// ==UserScript==
// @name         Del Confirm
// @version      1.0
// @license      MIT
// @description  del confirm
// @author       Morning Start
// @match        https://gitee.com/*
// @match        https://github.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gitee.com
// @namespace https://greasyfork.org/users/803002
// ==/UserScript==

(function () {
  ("use strict");
  const currentURL = window.location.href;

  if (currentURL.includes("gitee.com")) {
    giteeConfirm();
  } else if (currentURL.includes("github.com")) {
    githubConfirm();
  }
})();

function githubConfirm() {
  let button1 = document.querySelector("#dialog-show-repo-delete-menu-dialog");
  button1.addEventListener("click", function () {
    // console.log("button1");
    let button2 = document.querySelector("#repo-delete-proceed-button");
    button2.addEventListener("click", function () {
      // console.log("button2");
      setTimeout(function () {
        let button3 = document.querySelector("#repo-delete-proceed-button");
        button3.addEventListener("click", function () {
          // console.log("button3");
          setTimeout(function () {
            let button = document.querySelector("#repo-delete-proceed-button");
            if ("disabled" in button.attributes) {
              button.attributes.removeNamedItem("disabled");
            }
            let wrap = document.querySelectorAll(
              ".Overlay-footer--alignEnd"
            )[4];
            let text = wrap.querySelector(".FormControl-label");
            let input = wrap.querySelector(".FormControl-input");

            input.value = text.textContent
              .match(/"(.*?)"/g)[0]
              .replace(/"/g, "");
          }, 10);
        });
      }, 10);
    });
  });
}

function giteeConfirm() {
  let button = document.querySelector(".del-pro-btn");
  button.addEventListener("click", function () {
    let wrap = document.querySelector(".del-or-clear-target-wrap");
    wrap.querySelector(".ok").className = "ui button orange ok";
    let text = wrap.querySelector(".highlight-black");
    let input = wrap.querySelector("#path_with_namespace");
    input.value = text.textContent;
  });
}