Chocolatey install -y

Add -y to install command

  1. // ==UserScript==
  2. // @name Chocolatey install -y
  3. // @namespace Violentmonkey Scripts
  4. // @match http*://chocolatey.org/packages*
  5. // @grant none
  6. // @version 1.2
  7. // @author SettingDust
  8. // @description Add -y to install command
  9. // ==/UserScript==
  10.  
  11. const map = {};
  12.  
  13. const observer = new MutationObserver(function (mutations, me) {
  14. const installElem = Array.from(
  15. document.querySelectorAll(".input-group .input-group-prepend+input")
  16. );
  17. if (installElem.length) {
  18. installElem
  19. .filter((elem) => !map[elem])
  20. .filter((elem) => !elem.value.endsWith("-y"))
  21. .forEach((elem) => {
  22. elem.value += " -y";
  23. map[elem] = true;
  24. });
  25. }
  26.  
  27. const copyElem = Array.from(
  28. document.querySelectorAll("[data-original-title='Copy to Clipboard']")
  29. );
  30. if (copyElem.length) {
  31. copyElem
  32. .filter((elem) => !map[elem])
  33. .forEach((elem) => {
  34. elem.setAttribute(
  35. "data-clipboard-text",
  36. elem.getAttribute("data-clipboard-text") + " -y"
  37. );
  38. map[elem] = true;
  39. });
  40. }
  41. });
  42.  
  43. // start observing
  44. observer.observe(document, {
  45. childList: true,
  46. subtree: true,
  47. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址