Skip to content

Instantly share code, notes, and snippets.

@aaronsteers
Last active April 17, 2022 01:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronsteers/8e160ebb8462412fd5f2116bf27abe29 to your computer and use it in GitHub Desktop.
Save aaronsteers/8e160ebb8462412fd5f2116bf27abe29 to your computer and use it in GitHub Desktop.
Choco install script for TamperMonkey/GreaseMonkey
// ==UserScript==
// @name Choco-One-Click
// @namespace http://tampermonkey.net/
// @version 0.1.1
// @description Install software from chocolatey.org with one-click. This requires choco:// protocol support (choco install choco-protocol-support).
// @author AJ Steers
// @include http://*chocolatey.org/*
// @include https://*chocolatey.org/*
// @grant none
// ==/UserScript==
console.log("hello, world!");
(function() {
'use strict';
console.log("hello, function!");
var code_elems = document.getElementsByTagName('input');
var cinst_regex = /choco\sinstall\s([\w\d\-\.]*)/;
for (var i = 0; i < code_elems.length; i++) {
console.log("hello, loop!");
var ce = code_elems[i];
var cmd = ce.value;
var cinst_match = cmd.match(cinst_regex);
if (cinst_match) {
console.log("hello, " + cinst_match[1] + "!");
console.log(ce);
console.log(cmd);
var new_install_cmd = "choco://" + cinst_match[1];
var a = document.createElement('a');
// Create the text node for anchor element.
var link = document.createTextNode(new_install_cmd);
a.appendChild(link);
a.title = new_install_cmd;
a.href = new_install_cmd;
parent = ce.parentElement.parentElement.parentElement
parent.appendChild(document.createElement('p'));
parent.appendChild(document.createTextNode("Or click to install: "));
parent.appendChild(a);
}
}
// Your code here...
})();
insert_add_to_box();
function insert_add_to_box() {
}
console.log("goodbye, world!");
@umarabdullahmansoori
Copy link

Brother if you:

1.Try to Launch it officially on chocolatey
2. Make a little install button GUI like this extension do https://github.com/BananaAcid/chocolatey-appstore (this extension
has multi-install issue, see on GitHub)
chrome link: https://chrome.google.com/webstore/detail/chocolatey-appstore/gkehnkphfligaeniienfamgdfocegffl?hl=en
3. Only if you can, make a chrome extension for it

, it will be great for all who use chocolatey, and will become more popular

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment