Chocolatey install -y

Add -y to install command

目前為 2020-05-22 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Chocolatey install -y
// @namespace   Violentmonkey Scripts
// @match       http*://chocolatey.org/packages/*
// @grant       none
// @version     1.0
// @author      SettingDust
// @description Add -y to install command
// ==/UserScript==

let a = true,
  b = true;

const observer = new MutationObserver(function (mutations, me) {
  const installElem = document.querySelector(
    "[aria-label='Install Netch command']"
  );
  if (installElem && a) {
    installElem.value += " -y";
    a = false;
  }

  const copyElem = document.querySelector(
    "[aria-label='Copy netch to Clipboard']"
  );
  if (copyElem && b) {
    copyElem.setAttribute(
      "data-clipboard-text",
      copyElem.getAttribute("data-clipboard-text") + " -y"
    );
    b = false;
  }
});

// start observing
observer.observe(document, {
  childList: true,
  subtree: true,
});