Greasy Fork is available in English.

RGiskard's Stock Lib

Library functions for stock scripts

لقد تم حذف هذا البرنامج النصي. "Automated delete due to script containing JavaScript syntax errors"

<!DOCTYPE html>
<html lang="en">
<head>
<script>window.NREUM||(NREUM={});NREUM.info={"beacon":"bam.nr-data.net","errorBeacon":"bam.nr-data.net","licenseKey":"2a000a1c4d","applicationID":"3221391","transactionName":"ewpeFRRWXVQDFxcSBUoMQBUVFkJQCRJnAglcAA==","queueTime":0,"applicationTime":27,"agent":""}</script>
<script>window.NREUM||(NREUM={}),__nr_require=function(e,n,t){function r(t){if(!n[t]){var o=n[t]={exports:{}};e[t][0].call(o.exports,function(n){var o=e[t][1][n];return r(o||n)},o,o.exports)}return n[t].exports}if("function"==typeof __nr_require)return __nr_require;for(var o=0;o<t.length;o++)r(t[o]);return r}({1:[function(e,n,t){function r(){}function o(e,n,t){return function(){return i(e,[c.now()].concat(u(arguments)),n?null:this,t),n?void 0:this}}var i=e("handle"),a=e(3),u=e(4),f=e("ee").get("tracer"),c=e("loader"),s=NREUM;"undefined"==typeof window.newrelic&&(newrelic=s);var p=["setPageViewName","setCustomAttribute","setErrorHandler","finished","addToTrace","inlineHit","addRelease"],d="api-",l=d+"ixn-";a(p,function(e,n){s[n]=o(d+n,!0,"api")}),s.addPageAction=o(d+"addPageAction",!0),s.setCurrentRouteName=o(d+"routeName",!0),n.exports=newrelic,s.interaction=function(){return(new r).get()};var m=r.prototype={createTracer:function(e,n){var t={},r=this,o="function"==typeof n;return i(l+"tracer",[c.now(),e,t],r),function(){if(f.emit((o?"":"no-")+"fn-start",[c.now(),r,o],t),o)try{return n.apply(this,arguments)}catch(e){throw f.emit("fn-err",[arguments,this,e],t),e}finally{f.emit("fn-end",[c.now()],t)}}}};a("actionText,setName,setAttribute,save,ignore,onEnd,getContext,end,get".split(","),function(e,n){m[n]=o(l+n)}),newrelic.noticeError=function(e,n){"string"==typeof e&&(e=new Error(e)),i("err",[e,c.now(),!1,n])}},{}],2:[function(e,n,t){function r(e,n){if(!o)return!1;if(e!==o)return!1;if(!n)return!0;if(!i)return!1;for(var t=i.split("."),r=n.split("."),a=0;a<r.length;a++)if(r[a]!==t[a])return!1;return!0}var o=null,i=null,a=/Version\/(\S+)\s+Safari/;if(navigator.userAgent){var u=navigator.userAgent,f=u.match(a);f&&u.indexOf("Chrome")===-1&&u.indexOf("Chromium")===-1&&(o="Safari",i=f[1])}n.exports={agent:o,version:i,match:r}},{}],3:[function(e,n,t){function r(e,n){var t=[],r="",i=0;for(r in e)o.call(e,r)&&(t[i]=n(r,e[r]),i+=1);return t}var o=Object.prototype.hasOwnProperty;n.exports=r},{}],4:[function(e,n,t){function r(e,n,t){n||(n=0),"undefined"==typeof t&&(t=e?e.length:0);for(var r=-1,o=t-n||0,i=Array(o<0?0:o);++r<o;)i[r]=e[n+r];return i}n.exports=r},{}],5:[function(e,n,t){n.exports={exists:"undefined"!=typeof window.performance&&window.performance.timing&&"undefined"!=typeof window.performance.timing.navigationStart}},{}],ee:[function(e,n,t){function r(){}function o(e){function n(e){return e&&e instanceof r?e:e?f(e,u,i):i()}function t(t,r,o,i){if(!d.aborted||i){e&&e(t,r,o);for(var a=n(o),u=v(t),f=u.length,c=0;c<f;c++)u[c].apply(a,r);var p=s[y[t]];return p&&p.push([b,t,r,a]),a}}function l(e,n){h[e]=v(e).concat(n)}function m(e,n){var t=h[e];if(t)for(var r=0;r<t.length;r++)t[r]===n&&t.splice(r,1)}function v(e){return h[e]||[]}function g(e){return p[e]=p[e]||o(t)}function w(e,n){c(e,function(e,t){n=n||"feature",y[t]=n,n in s||(s[n]=[])})}var h={},y={},b={on:l,addEventListener:l,removeEventListener:m,emit:t,get:g,listeners:v,context:n,buffer:w,abort:a,aborted:!1};return b}function i(){return new r}function a(){(s.api||s.feature)&&(d.aborted=!0,s=d.backlog={})}var u="nr@context",f=e("gos"),c=e(3),s={},p={},d=n.exports=o();d.backlog=s},{}],gos:[function(e,n,t){function r(e,n,t){if(o.call(e,n))return e[n];var r=t();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(e,n,{value:r,writable:!0,enumerable:!1}),r}catch(i){}return e[n]=r,r}var o=Object.prototype.hasOwnProperty;n.exports=r},{}],handle:[function(e,n,t){function r(e,n,t,r){o.buffer([e],r),o.emit(e,n,t)}var o=e("ee").get("handle");n.exports=r,r.ee=o},{}],id:[function(e,n,t){function r(e){var n=typeof e;return!e||"object"!==n&&"function"!==n?-1:e===window?0:a(e,i,function(){return o++})}var o=1,i="nr@id",a=e("gos");n.exports=r},{}],loader:[function(e,n,t){function r(){if(!E++){var e=x.info=NREUM.info,n=l.getElementsByTagName("script")[0];if(setTimeout(s.abort,3e4),!(e&&e.licenseKey&&e.applicationID&&n))return s.abort();c(y,function(n,t){e[n]||(e[n]=t)}),f("mark",["onload",a()+x.offset],null,"api");var t=l.createElement("script");t.src="https://"+e.agent,n.parentNode.insertBefore(t,n)}}function o(){"complete"===l.readyState&&i()}function i(){f("mark",["domContent",a()+x.offset],null,"api")}function a(){return O.exists&&performance.now?Math.round(performance.now()):(u=Math.max((new Date).getTime(),u))-x.offset}var u=(new Date).getTime(),f=e("handle"),c=e(3),s=e("ee"),p=e(2),d=window,l=d.document,m="addEventListener",v="attachEvent",g=d.XMLHttpRequest,w=g&&g.prototype;NREUM.o={ST:setTimeout,SI:d.setImmediate,CT:clearTimeout,XHR:g,REQ:d.Request,EV:d.Event,PR:d.Promise,MO:d.MutationObserver};var h=""+location,y={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net",agent:"js-agent.newrelic.com/nr-1123.min.js"},b=g&&w&&w[m]&&!/CriOS/.test(navigator.userAgent),x=n.exports={offset:u,now:a,origin:h,features:{},xhrWrappable:b,userAgent:p};e(1),l[m]?(l[m]("DOMContentLoaded",i,!1),d[m]("load",r,!1)):(l[v]("onreadystatechange",o),d[v]("onload",r)),f("mark",["firstbyte",u],null,"api");var E=0,O=e(5)},{}]},{},["loader"]);</script>
  <title>RGiskard&#39;s Stock Lib - Source code</title>
  <meta name="description" value="Source code for RGiskard&#39;s Stock Lib">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" media="all" href="/assets/application-aee7bc1c949c01c2492d7decb9901fcd00998f9104f0668dfd2bc299aa38ec51.css" />
  <script src="/assets/application-6f3fdf691e17817118bf2825a435cd046555a0562258cd6d2bdc234ffa41c8a5.js"></script>
  <meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="ObnzLPJtKjiu4h820+MnoCVDnYicGUUsfaPEnIzqU5QPt9/zyIgimbQECwkp1Mi5wIAeej8kBr22TO5IirM5uw==" />
  <link rel="canonical" href="https://greasyfork.org/en/scripts/21214-rgiskard-s-stock-lib/code">
  <link rel="icon" href="/assets/blacklogo16-bc64b9f7afdc9be4cbfa58bdd5fc2e5c098ad4bca3ad513a27b15602083fd5bc.png">
  <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
    <link rel="alternate" hreflang="x-default" href="/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="ar" href="/ar/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="bg" href="/bg/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="cs" href="/cs/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="da" href="/da/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="de" href="/de/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="el" href="/el/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="en" href="/en/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="es" href="/es/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="fi" href="/fi/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="fr" href="/fr/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="fr-CA" href="/fr-CA/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="he" href="/he/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="hu" href="/hu/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="id" href="/id/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="it" href="/it/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="ja" href="/ja/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="ko" href="/ko/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="nb" href="/nb/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="nl" href="/nl/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="pl" href="/pl/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="pt-BR" href="/pt-BR/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="ro" href="/ro/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="ru" href="/ru/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="sk" href="/sk/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="sv" href="/sv/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="th" href="/th/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="tr" href="/tr/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="uk" href="/uk/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="vi" href="/vi/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="zh-CN" href="/zh-CN/scripts/21214-rgiskard-s-stock-lib/code">
      <link rel="alternate" hreflang="zh-TW" href="/zh-TW/scripts/21214-rgiskard-s-stock-lib/code">


  <link rel="search" href="/en/opensearch.xml" type="application/opensearchdescription+xml" title="Greasy Fork search" hreflang="en">

  
</head>
<body>

  <header id="main-header">
    <div class="width-constraint">
      <div id="site-name">
        <a href="/en"><img src="/assets/blacklogo96-e0c2c76180916332b7516ad47e1e206b42d131d36ff4afe98da3b1ba61fd5d6c.png" alt=""></a>
        <div id="site-name-text">
          <h1><a href="/en">Greasy Fork</a></h1>
        </div>
      </div>
      <div id="site-nav">
        <div id="nav-user-info">
            <span class="sign-in-link"><a rel="nofollow" href="/en/users/sign_in?return_to=%2Fen%2Fscripts%2F21214-rgiskard-s-stock-lib%2Fcode">Sign in</a></span>

          <form id="language-selector" action="/scripts/21214-rgiskard-s-stock-lib/code">
            <select id="language-selector-locale" name="locale">
                  <option data-language-url="/ar/scripts/21214-rgiskard-s-stock-lib/code" value="ar">
                    العَرَبِيةُ (ar)
                  </option>
                  <option data-language-url="/bg/scripts/21214-rgiskard-s-stock-lib/code" value="bg">
                    Български (bg)
                  </option>
                  <option data-language-url="/cs/scripts/21214-rgiskard-s-stock-lib/code" value="cs">
                    Čeština (cs)
                  </option>
                  <option data-language-url="/da/scripts/21214-rgiskard-s-stock-lib/code" value="da">
                    Dansk (da)
                  </option>
                  <option data-language-url="/de/scripts/21214-rgiskard-s-stock-lib/code" value="de">
                    Deutsch (de)
                  </option>
                  <option data-language-url="/el/scripts/21214-rgiskard-s-stock-lib/code" value="el">
                    Ελληνικά (el)
                  </option>
                  <option data-language-url="/en/scripts/21214-rgiskard-s-stock-lib/code" value="en" selected>
                    English (en)
                  </option>
                  <option data-language-url="/es/scripts/21214-rgiskard-s-stock-lib/code" value="es">
                    Español (es)
                  </option>
                  <option data-language-url="/fi/scripts/21214-rgiskard-s-stock-lib/code" value="fi">
                    Suomi (fi)
                  </option>
                  <option data-language-url="/fr/scripts/21214-rgiskard-s-stock-lib/code" value="fr">
                    Français (fr)
                  </option>
                  <option data-language-url="/fr-CA/scripts/21214-rgiskard-s-stock-lib/code" value="fr-CA">
                    Français canadien (fr-CA)
                  </option>
                  <option data-language-url="/he/scripts/21214-rgiskard-s-stock-lib/code" value="he">
                    עברית (he)
                  </option>
                  <option data-language-url="/hu/scripts/21214-rgiskard-s-stock-lib/code" value="hu">
                    Magyar (hu)
                  </option>
                  <option data-language-url="/id/scripts/21214-rgiskard-s-stock-lib/code" value="id">
                    Bahasa Indonesia (id)
                  </option>
                  <option data-language-url="/it/scripts/21214-rgiskard-s-stock-lib/code" value="it">
                    Italiano (it)
                  </option>
                  <option data-language-url="/ja/scripts/21214-rgiskard-s-stock-lib/code" value="ja">
                    日本語 (ja)
                  </option>
                  <option data-language-url="/ko/scripts/21214-rgiskard-s-stock-lib/code" value="ko">
                    한국어 (ko)
                  </option>
                  <option data-language-url="/nb/scripts/21214-rgiskard-s-stock-lib/code" value="nb">
                    Bokmål (nb)
                  </option>
                  <option data-language-url="/nl/scripts/21214-rgiskard-s-stock-lib/code" value="nl">
                    Nederlands (nl)
                  </option>
                  <option data-language-url="/pl/scripts/21214-rgiskard-s-stock-lib/code" value="pl">
                    Polski (pl)
                  </option>
                  <option data-language-url="/pt-BR/scripts/21214-rgiskard-s-stock-lib/code" value="pt-BR">
                    Português do Brasil (pt-BR)
                  </option>
                  <option data-language-url="/ro/scripts/21214-rgiskard-s-stock-lib/code" value="ro">
                    Română (ro)
                  </option>
                  <option data-language-url="/ru/scripts/21214-rgiskard-s-stock-lib/code" value="ru">
                    Русский (ru)
                  </option>
                  <option data-language-url="/sk/scripts/21214-rgiskard-s-stock-lib/code" value="sk">
                    Slovenčina (sk)
                  </option>
                  <option data-language-url="/sv/scripts/21214-rgiskard-s-stock-lib/code" value="sv">
                    Svenska (sv)
                  </option>
                  <option data-language-url="/th/scripts/21214-rgiskard-s-stock-lib/code" value="th">
                    ภาษาไทย (th)
                  </option>
                  <option data-language-url="/tr/scripts/21214-rgiskard-s-stock-lib/code" value="tr">
                    Türkçe (tr)
                  </option>
                  <option data-language-url="/uk/scripts/21214-rgiskard-s-stock-lib/code" value="uk">
                    Українська (uk)
                  </option>
                  <option data-language-url="/vi/scripts/21214-rgiskard-s-stock-lib/code" value="vi">
                    Tiếng Việt (vi)
                  </option>
                  <option data-language-url="/zh-CN/scripts/21214-rgiskard-s-stock-lib/code" value="zh-CN">
                    简体中文 (zh-CN)
                  </option>
                  <option data-language-url="/zh-TW/scripts/21214-rgiskard-s-stock-lib/code" value="zh-TW">
                    繁體中文 (zh-TW)
                  </option>
              <option value="help">Help us translate!</option>
            </select><input id="language-selector-submit" type="submit" value="→">
            <script>
              /* submit is handled by js if enabled */
              document.getElementById("language-selector-submit").style.display = "none"
            </script>
          </form>
        </div>
        <nav>
          <li class="scripts-index-link"><a href="/en/scripts">Scripts</a></li>
            <li class="forum-link"><a href="/en/forum/">Forum</a></li>
          <li class="help-link"><a href="/en/help">Help</a></li>
          <li class="with-submenu">
            <a href="#" onclick="return false">More</a>
            <nav>
              <li><a href="/en/search">Advanced search</a></li>
              <li><a href="/en/users">User list</a></li>
              <li><a href="/en/scripts/libraries">Libraries</a></li>
              <li><a href="/en/moderator_actions">Moderator log</a></li>
            </nav>
          </li>
        </nav>
      </div>
    </div>
  </header>

  <div class="width-constraint">

    	<section id="script-info">
		<ul id="script-links" class="tabs">
			<li><a href="/en/scripts/21214-rgiskard-s-stock-lib"><span>Info</span></a></li>
			<li class="current"><span>Code</span></li>
			<li><a href="/en/scripts/21214-rgiskard-s-stock-lib/versions"><span>History</span></a></li>
			<li><a href="/en/scripts/21214-rgiskard-s-stock-lib/feedback"><span>Feedback (0)</span></a></li>
			<li><a href="/en/scripts/21214-rgiskard-s-stock-lib/stats"><span>Stats</span></a></li>
		</ul>
		<header>
			<h2>RGiskard&#39;s Stock Lib</h2>
			<p id="script-description">Library functions for stock scripts</p>
		</header>
		<div id="script-content">
			
  <p>
      This script has been deleted.
  </p>


<div id="script-feedback-suggestion">
    <a rel="nofollow" href="/en/forum/post/discussion?script=21214">Ask a question, post a review</a>, or <a rel="nofollow" href="/en/scripts/21214-rgiskard-s-stock-lib/report">report the script</a>.
</div>


<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>

<pre class="prettyprint lang-js">// ==UserScript==
// @name         RGiskard&#39;s Stock Lib
// @namespace    RGiskardScripts
// @version      1.1.2
// @description  Library functions for stock scripts
// @author       RGiskard [1953860]
// @grant        none
// @require      https://greasyfork.org/scripts/21221-rgiskard-s-script-libs/code/RGiskard&#39;s%20Script%20Lib.user.js
// ==/UserScript==



var stockLibDebugIdentifier = &#39;RG Stock Lib&#39;;


/**
 * Gets the name of a stock by its id.
 * @param {int} stockId the id for the given stock, 0 to numberOfStocks - 1, not including 24
 * @returns the human-readable string representing the identified stock in the format of the stock name
 * followed by its symbol in square brackets
 **/
function GetStockNameFromId(stockId) {
    if (stockId == 0) {
        return &#39;Torn City Stock Exchange [TCSE]&#39;;
    } else if (stockId == 1) {
        return &#39;Torn City and Shanghai Banking Corporation [TSBC]&#39;;
    } else if (stockId == 2) {
        return &#39;Torn City Investment Banking [TCB]&#39;;
    } else if (stockId == 3) {
        return &#39;Syscore MFG [SYS]&#39;;
    } else if (stockId == 4) {
        return &#39;Society and Legal Authorities Group [SLAG]&#39;;
    } else if (stockId == 5) {
        return &#39;Insured On Us [IOU]&#39;;
    } else if (stockId == 6) {
        return &#39;Grain [GRN]&#39;;
    } else if (stockId == 7) {
        return &#39;Torn City Health Service [TCHS]&#39;;
    } else if (stockId == 8) {
        return &#39;Yazoo [YAZ]&#39;;
    } else if (stockId == 9) {
        return &#39;The Torn City Times [TCT]&#39;;
    } else if (stockId == 10) {
        return &#39;Crude &amp; Co. [CNC]&#39;;
    } else if (stockId == 11) {
        return &#39;Messaging Inc [MSG]&#39;;
    } else if (stockId == 12) {
        return &#39;TC Music Industries [TMI]&#39;;
    } else if (stockId == 13) {
        return &#39;TC Media Productions [TCP]&#39;;
    } else if (stockId == 14) {
        return &#39;I Industries Ltd [IIL]&#39;;
    } else if (stockId == 15) {
        return &#39;Feathery Hotels Group [FHG]&#39;;
    } else if (stockId == 16) {
        return &#39;Symbiotic Ltd [SYM]&#39;;
    } else if (stockId == 17) {
        return &#39;Lucky Shots Casino [LSC]&#39;;
    } else if (stockId == 18) {
        return &#39;Performance Ribaldry Network [PRN]&#39;;
    } else if (stockId == 19) {
        return &#39;Eaglewood Mercenary [EWM]&#39;;
    } else if (stockId == 20) {
        return &#39;Torn City Motors [TCM]&#39;;
    } else if (stockId == 21) {
        return &#39;The Empty Lunchbox Building Traders [ELBT]&#39;;
    } else if (stockId == 22) {
        return &#39;Home Retail Group [HRG]&#39;;
    } else if (stockId == 23) {
        return &#39;Tell Group Plc [TGP]&#39;;
    } else if (stockId == 25) {
        return &#39;West Side South Bank University [WSSB]&#39;;
    } else if (stockId == 26) {
        return &#39;International School TC [ISTC]&#39;;
    } else if (stockId == 27) {
        return &#39;Big Al\&#39;s Gun Shop [BAG]&#39;;
    } else if (stockId == 28) {
        return &#39;Evil Ducks Candy Corp [EVL]&#39;;
    } else if (stockId == 29) {
        return &#39;Mc Smoogle Corp [MCS]&#39;;
    } else if (stockId == 30) {
        return &#39;Wind Lines Travel [WLT]&#39;;
    } else if (stockId == 31) {
        return &#39;Torn City Clothing [TCC]&#39;;
    }
    return null;
}


/**
 * Gets the symbol of a stock by its id.
 * @param {int} stockId the id for the given stock, 0 to numberOfStocks - 1, not including 24
 * @returns the string representing the identified stock symbol
 **/
function GetStockSymbolFromId(stockId) {
    if (stockId == 0) {
        return &#39;TCSE&#39;;
    } else if (stockId == 1) {
        return &#39;TSBC&#39;;
    } else if (stockId == 2) {
        return &#39;TCB&#39;;
    } else if (stockId == 3) {
        return &#39;SYS&#39;;
    } else if (stockId == 4) {
        return &#39;SLAG&#39;;
    } else if (stockId == 5) {
        return &#39;IOU&#39;;
    } else if (stockId == 6) {
        return &#39;GRN&#39;;
    } else if (stockId == 7) {
        return &#39;TCHS&#39;;
    } else if (stockId == 8) {
        return &#39;YAZ&#39;;
    } else if (stockId == 9) {
        return &#39;TCT&#39;;
    } else if (stockId == 10) {
        return &#39;CNC&#39;;
    } else if (stockId == 11) {
        return &#39;MSG&#39;;
    } else if (stockId == 12) {
        return &#39;TMI&#39;;
    } else if (stockId == 13) {
        return &#39;TCP&#39;;
    } else if (stockId == 14) {
        return &#39;IIL&#39;;
    } else if (stockId == 15) {
        return &#39;FHG&#39;;
    } else if (stockId == 16) {
        return &#39;SYM&#39;;
    } else if (stockId == 17) {
        return &#39;LSC&#39;;
    } else if (stockId == 18) {
        return &#39;PRN&#39;;
    } else if (stockId == 19) {
        return &#39;EWM&#39;;
    } else if (stockId == 20) {
        return &#39;TCM&#39;;
    } else if (stockId == 21) {
        return &#39;ELBT&#39;;
    } else if (stockId == 22) {
        return &#39;HRG&#39;;
    } else if (stockId == 23) {
        return &#39;TGP&#39;;
    } else if (stockId == 25) {
        return &#39;WSSB&#39;;
    } else if (stockId == 26) {
        return &#39;ISTC&#39;;
    } else if (stockId == 27) {
        return &#39;BAG&#39;;
    } else if (stockId == 28) {
        return &#39;EVL&#39;;
    } else if (stockId == 29) {
        return &#39;MCS&#39;;
    } else if (stockId == 30) {
        return &#39;WLT&#39;;
    } else if (stockId == 31) {
        return &#39;TCC&#39;;
    }
    return null;
}


/**
 * An item representing a set of stock data.
 * @param {int} id the id of the stock
 * @param {string} forecast the forecast of the stock
 * @param {float} price the price of the stock
 * @param {float} change the last change in the price of the stock
 * @param {int} sharesAvailable the number of shares of the stock that are available
 **/
function StockData(id, forecast, price, change, sharesAvailable) {
    this.id = id;
    this.forecast = forecast;
    this.price = price;
    this.change = change;
    this.sharesAvailable = sharesAvailable;
}


/**
 * Requests the status of a given stock id from Torn and executes a callback with
 * the data received.
 * @param {int} stockId the id of the stock to check
 * @param {function} callback a function to call at the successful completion of
 * the request; it should take a StockData object as its sole argument
 **/
function GetStockStatus(stockId, callback) {
    console.debug(stockLibDebugIdentifier + &#39;: Looking up status of &#39; + GetStockSymbolFromId(stockId) + &#39;...&#39;);

    var url = &#39;stockexchange.php?ajax=true&amp;step=profile&amp;ID=&#39; + stockId + &#39;&amp;rfcv=&#39; + GetCookie(&#39;rfc_v&#39;);
    $.ajax({
        url: url,
        type: &quot;POST&quot;,
        success: function(response) {
            try {
                var parsedHtml;
                // Different browsers seem to have different Ajax responses.
                if (response.responseText &amp;&amp; response.responseText != []) {
                    parsedHtml = $.parseHTML(response.responseText);
                } else {
                    parsedHtml = $.parseHTML(response);
                }
                console.debug($(parsedHtml));
                
                var $infoTab = $(parsedHtml[8]);
                var $changesTab = $(parsedHtml[14]);

                var stockSymbol = $infoTab.find(&#39;li.t-overflow&#39;)[0].textContent.split(&#39;:&#39;)[1].trim();
                var stockPrice = parseFloat($infoTab.find(&#39;li.t-overflow&#39;)[4].textContent.split(&#39;:&#39;)[1].trim().substr(1).replace(/,/g, &#39;&#39;));
                var stockForecast = $infoTab.find(&#39;li.t-overflow&#39;)[2].textContent.split(&#39;:&#39;)[1].trim();
                var stockRemaining = parseInt($infoTab.find(&#39;li.t-overflow&#39;)[7].textContent.split(&#39;:&#39;)[1].trim().replace(/,/g, &#39;&#39;));

                var $stockChangeList = $changesTab.find(&#39;div.stock-changes-scrollbar&#39;).find(&#39;div.change&#39;);
                var stockChangeElement = $stockChangeList[0];
                var stockChangeClassList = stockChangeElement.classList;
                var stockChangeClassLatest = &quot;&quot;;  // Default of blank is correct for no change.
                if (stockChangeClassList.length &gt; 1) {
                    stockChangeClassLatest = stockChangeClassList[1];
                }
                var stockChangeAmountLatest = stockChangeElement.children[0].textContent.trim();
                if (stockChangeClassLatest == &#39;down&#39;) {
                    stockChangeAmountLatest = stockChangeAmountLatest * -1;
                }

                /*
                // Old code, possible future fields
                stockData[&#39;stockChangeClassLatest&#39;] = stockChangeClassLatest;
                stockData[&#39;stockIsIncreasing&#39;] = stockIsIncreasing;
                */
                console.log(stockSymbol + &#39; has forecast of &#39; + stockForecast + &#39; and &#39; + stockRemaining.toLocaleString()
                            + &#39; shares available; its last change was &#39;
                            + stockChangeAmountLatest.toLocaleString(&quot;en-US&quot;, {style: &quot;currency&quot;, currency: &quot;USD&quot;, maximumFractionDigits: 4}) + &#39;.&#39;);

                var stockData = new StockData(stockId, stockForecast, stockPrice, stockChangeAmountLatest, stockRemaining);

                callback(stockData);
            } catch (error) {
                console.error(stockLibDebugIdentifier + &#39;: Error in GetStockStatus() ajax result function: &#39; + error);
            }
        }
    });
}


/**
 * Attempts to purchase a given amount of a particular stock at a known price.
 * @param {int} stockId the id of the stock to purchase
 * @param {int} sharesToBuy the number of shares of the stock to buy
 * @param {float} currentPrice the current price of the stock
 * @param {function} callback the optional callback function, taking the resulting
 *   parsed HTML in a jQuery object as a parameter
 **/
function BuyStock(stockId, sharesToBuy, currentPrice, callback) {
    var totalCost = Math.ceil(sharesToBuy * currentPrice);
    console.debug(&#39;Buying &#39; + sharesToBuy + &#39; shares of &#39; + GetStockSymbolFromId(stockId) + &#39; at $&#39;
                  + currentPrice.toLocaleString(&#39;EN&#39;, { maximumFractionDigits : 4 })
                  + &#39; (total: $&#39; + totalCost.toLocaleString() + &#39;)...&#39;);
    $.ajax({
        url: &#39;stockexchange.php?ajax=true&amp;step=buy2&amp;ID=&#39; + stockId
            + &#39;&amp;shares=&#39; + sharesToBuy + &#39;&amp;cost=&#39; + totalCost
            + &#39;&amp;rfcv=&#39; + GetCookie(&#39;rfc_v&#39;),
        type: &#39;POST&#39;,
        success: function(data, textStatus) {
            try {
                var htmlResult = $.parseHTML(data);
                console.debug(htmlResult);
                if (callback) {
                    callback($(htmlResult));
                }
            } catch (error) {
                console.error(&#39;Error purchasing stock: &#39; + error);
                console.debug(data);
            }
        },
        error: function(response) {
            console.error(&#39;Error purchasing stock: &#39; + response);
        }
    });
}</pre>

		</div>
	</section>

  </div>

    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

      ga('create', 'UA-48197018-1', 'greasyfork.org');
      ga('send', 'pageview');

    </script>

</body>
</html>