Company Stock update

Updates company stock.

当前为 2018-05-02 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
            }
        }
    });
});