Merlin-R / AutoVault

// ==UserScript==
// @name         AutoVault
// @namespace    https://reichwald.me/
// @version      1.0
// @description  Automatically store any money over $1M in your vault
// @author       Merlin Reichwald
// @match        https://www.torn.com/properties.php*
// @copyright 2018, Merlin-R (https://openuserjs.org//users/Merlin-R)
// @license MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function sendMoneyToVault( balance ) {
        let rfc = $.cookie('rfc_id');
        let id = $('input[type=hidden][name=ID]').val();
        $.get(`inputMoneyAction.php?step=propertyDepositAction&ID=${id}&rfcv=${rfc}`).then(function(){
            $.post(`properties.php?rfc=${rfc}`,{
                step: 'vaultProperty',
                deposit: balance,
                ID: id
            });
        });
    }

    function sendExtraMoneyToVault( threshold ) {
        if ( $('.vault-cont').length <= 0 ) return false;
        let balance = +$('#user-money').text().replace(/[^0-9]/g,'');
        if ( balance > threshold ) {
            sendMoneyToVault( balance - threshold );
            return true;
        }
        return false;
    }

    window.vaultInterval = setInterval(function(){
        sendExtraMoneyToVault( 1000000 )
    },1000);
})();