Last active
April 17, 2022 01:11
-
-
Save aaronsteers/8e160ebb8462412fd5f2116bf27abe29 to your computer and use it in GitHub Desktop.
Choco install script for TamperMonkey/GreaseMonkey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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