github repo delete auto confirm

auto complete the confirm input when deleting a repo on github

  1. // ==UserScript==
  2. // @name github repo delete auto confirm
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.0.3
  5. // @description auto complete the confirm input when deleting a repo on github
  6. // @author remisiki
  7. // @match https://github.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Your code here...
  16. // https://stackoverflow.com/a/56760883
  17. const rs = history.replaceState;
  18. history.replaceState = () => {
  19. rs.apply(history, arguments); // preserve normal functionality
  20. window.dispatchEvent(new Event("locationchange")); // do something extra here; raise an event
  21. };
  22.  
  23. window.addEventListener("locationchange", () => {
  24. if (window.location.href.match(/https:\/\/github\.com\/.*?\/settings/g)) {
  25. const handler = () => {
  26. document.querySelector("#repo-delete-proceed-button").click();
  27. setTimeout(() => {
  28. document.querySelector("#repo-delete-proceed-button").click();
  29. setTimeout(() => {
  30. const confirmBox = document.querySelector("#verification_field");
  31. confirmBox.value = confirmBox.getAttribute("data-repo-nwo");
  32. confirmBox.dispatchEvent(new Event("focus"));
  33. confirmBox.dispatchEvent(new Event("input"));
  34. }, 100);
  35. }, 0);
  36. };
  37. document.querySelector("#dialog-show-repo-delete-menu-dialog").addEventListener("click", handler);
  38. }
  39. });
  40. })();