-
Notifications
You must be signed in to change notification settings - Fork 6
37 lines (29 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// ==UserScript==
// @name Vagrant Box Download Helper
// @namespace http://userscript.everyx.in
// @version 2.0
// @description Add a download button in app.vagrantup.com.
// @author everyx
// @match https://app.vagrantup.com/*/boxes/*
// @grant none
// @downloadURL https://github.com/everyx/vagrant-box-download-helper-everyx.user.js/raw/master/[email protected]
// @updateURL https://github.com/everyx/vagrant-box-download-helper-everyx.user.js/raw/master/[email protected]
// @run-at document-end
// ==/UserScript==
(function () {
var versionList = document.querySelectorAll(".page-header h3 a");
var panelList = document.querySelectorAll(".panel");
for (var i = 0; i < versionList.length; i++) {
var providerElements = panelList[i].querySelectorAll('.list-group-item');
for (var j = 0; j < providerElements.length; j++) {
var element = providerElements[j]
var downloadButton = document.createElement('a');
downloadButton.className = 'pull-right glyphicon glyphicon-download';
downloadButton.title = 'download';
var ignoreText = element.querySelector('small').innerText;
var provider = element.innerText.replace(ignoreText, '').trim();
downloadButton.href = versionList[i].href + '/providers/' + provider + '.box';
element.querySelector('h4').appendChild(downloadButton);
}
}
})();