Del Confirm

删除仓库自动填写库名,支持 github、gitee

  1. // ==UserScript==
  2. // @name Del Confirm
  3. // @version 2.0
  4. // @license MIT
  5. // @description 删除仓库自动填写库名,支持 github、gitee
  6. // @author Morning Start
  7. // @match https://gitee.com/*
  8. // @match https://github.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=gitee.com
  10. // @namespace https://greasyfork.org/users/803002
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. ("use strict");
  15. const currentURL = window.location.href;
  16.  
  17. if (currentURL.includes("gitee.com")) {
  18. giteeConfirm();
  19. } else if (currentURL.includes("github.com")) {
  20. githubConfirm();
  21. }
  22. })();
  23.  
  24. function githubConfirm() {
  25. let del_btn = document.querySelector("#dialog-show-repo-delete-menu-dialog");
  26.  
  27. del_btn.addEventListener("click", function () {
  28. const intervalId = setInterval(() => {
  29. const targetButton = document.getElementById('repo-delete-proceed-button');
  30. if (targetButton) {
  31. // 若元素存在,点击该按钮
  32. targetButton.click();
  33. const button3 = document.getElementById('repo-delete-proceed-button');
  34. const intervalCheck = setInterval(() => {
  35. if (button3.querySelector('.Button-label').textContent ==="Delete this repository") {
  36. // 清除定时器,停止检查
  37. clearInterval(intervalId);
  38. clearInterval(intervalCheck);
  39. // 若按钮已禁用,解除禁用
  40. button3.disabled = false;
  41. // 填写库名
  42. let warp= document.querySelector('#repo-delete-proceed-button-container')
  43. let text=warp.querySelector('.FormControl-label')
  44. let input = warp.querySelector('#verification_field')
  45. const regex = /"([^"]*)"/;
  46. const match = text.textContent.match(regex);
  47. input.value=match[1]
  48. }
  49. }, 200);
  50. }
  51. }, 500);
  52. // console.log("button1");
  53.  
  54.  
  55. });
  56. }
  57.  
  58. function giteeConfirm() {
  59. let del_btn = document.querySelector(".del-pro-btn");
  60. del_btn.addEventListener("click", function () {
  61. let wrap = document.querySelector(".del-or-clear-target-wrap");
  62. wrap.querySelector(".ok").className = "ui button orange ok";
  63. let text = wrap.querySelector(".highlight-black");
  64. let input = wrap.querySelector("#path_with_namespace");
  65. input.value = text.textContent;
  66. });
  67. }