-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathvault_more_options.user.js
More file actions
56 lines (47 loc) · 1.79 KB
/
vault_more_options.user.js
File metadata and controls
56 lines (47 loc) · 1.79 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// ==UserScript==
// @name Torn: Vault: More options
// @namespace lugburz.vault.more_options
// @version 0.1.4
// @description Add 'Upkeep' button that automatically inputs the amount needed to pay upkeep.
// @author Lugburz
// @match https://www.torn.com/properties.php*
// @require https://github.com/f2404/torn-userscripts/raw/31f4faa6da771b7a16cf732c1a78970506effeeb/lib/lugburz_lib.js
// @updateURL https://github.com/f2404/torn-userscripts/raw/master/vault_more_options.user.js
// @grant none
// ==/UserScript==
function addRentButton() {
const btnId = 'upkeepButton';
const jqBtnId = '#' + btnId;
const found = $('ul.options-list > li.upkeep-prop').text().match(/\(\$(\d+.+?)\)/);
let upkeep = -1;
if (typeof found !== 'undefined' && found !== null) {
upkeep = found[1];
}
if (document.getElementById(btnId) == null) {
$('div.vault-wrap > form.vault-cont.left > div.cont').append('<span id="' + btnId + '" class="btn-wrap silver"><span class="btn"><button class="torn-btn" title="Upkeep">$</button></span></span>');
}
if (upkeep < 1) {
$(jqBtnId).addClass('disable');
} else {
$(jqBtnId).removeClass('disable');
$(jqBtnId).on('click', function() {
const input = $('div.vault-wrap > form.vault-cont.left > div.cont > div.input-money-group > input:text');
if (input.val() == '') {
input.val(upkeep);
input.blur();
}
});
}
}
(function() {
'use strict';
// Your code here...
if (!$(location).attr('href').includes('p=options&tab=vault')) {
return;
}
ajax((page) => {
if (page == "properties") {
$('#properties-page-wrap').ready(addRentButton);
}
});
})();