Updates company stock.
目前為
// ==UserScript==
// @name Company Stock update
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Updates company stock.
// @author LordBusiness
// @match https://www.torn.com/companies.php
// @grant none
// ==/UserScript==
// You need to add the prices you want in order.
var PriceArray = ["100", "300", "500", "500", "1000", "700", "456", "3000"];
// a minimal jQuery library for reacting to innerHTML changes
(function($) {
$.fn.change = function(cb, e) {
e = e || { subtree:true, childList:true, characterData:true };
$(this).each(function() {
function callback(changes) { cb.call(node, changes, this); }
var node = this;
(new MutationObserver(callback)).observe(node, e);
});
};
})(jQuery);
var flag = 0;
$("#ui-id-8").click(function() {
$('#stock').change(function(changes, observer) {
if(($(".stock-list-wrap").length > 0) && (flag === 0)) {
flag = 1;
console.log("p");
try {
var i = 0;
$(".quantity > input").each(function() {
$(this).focus();
$(this).val(PriceArray[i]);
$(this).keydown();
$(this).keypress();
$(this).keyup();
$(this).blur();
i++;
});
i = 0;
}
catch(err) {
console.log("Err:" + err);
}
}
});
});