Company Stock update

Updates company stock.

目前為 2018-05-02 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
            }
        }
    });
});