ACGN股票系統每股營利外掛

try to take over the world!

目前為 2017-10-05 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name ACGN股票系統每股營利外掛
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.500
  5. // @description try to take over the world!
  6. // @author papago & Ming
  7. // @match http://acgn-stock.com/*
  8. // @match https://acgn-stock.com/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. //版本號為'主要版本號 + "." + 次要版本號 + 錯誤修正版本號(兩位),ex 1.801
  13. //修復導致功能失效的錯誤或更新重大功能提升主要或次要版本號
  14. //優化UI,優化效能,優化小錯誤更新錯誤版本號
  15. //一旦主要版本號或次要版本號更動,就會跳UI提是使用者更新腳本
  16. //兩個錯誤修正版本號防止迫不得已進位到次要版本號
  17. //版本更新會每十分鐘確認一次
  18.  
  19. var wasCompany, wasStockSummary, wasaccountInfo, wasFoundationPlan, jsonObj = null, oldUrl;
  20.  
  21. // 程式進入點
  22. (function mainfunction(){
  23. //設定狀態
  24. wasCompany = (document.location.href.search(/company\/detail/) != -1);
  25. wasStockSummary = (document.location.href.search(/company\/[0-9]+/) != -1);
  26. wasAccountInfo = (document.location.href.search(/accountInfo/) != -1);
  27. wasFoundationPlan = document.location.href.search(/foundation/) != -1;
  28. oldUrl = document.location.href;
  29. //針對現在的頁面做反應
  30. if(wasCompany)
  31. setTimeout(addCompanyEvent, 1000);
  32. else if(wasStockSummary)
  33. setTimeout(addSSEvent, 1000); // StockSummary
  34. else if(wasAccountInfo)
  35. setTimeout(addAIEvent, 1000); // AccountInfo
  36. else if(wasFoundationPlan)
  37. setTimeout(addFPEvent, 1000); // FoundationPlan
  38.  
  39. //全域事件
  40. setTimeout(addNavItem, 500); // 新增上方按鈕
  41. setTimeout(checkScriptEvent, 500); // 版本確認
  42. setTimeout(addEvent, 5000); // 監聽main的變化並呼叫對應事件
  43. //setTimeout(blockAD, 500);;
  44. })();
  45. function addCompanyEvent(){
  46. addCompanyClickListener(); // 數據資訊
  47. // addSubscribeListener(); // 訂閱按鈕
  48. }
  49. function addAIEvent(){
  50. AddTaxListener(); // 稅率資料夾
  51. // addShowSubscribesListener(); // 訂閱資料夾
  52. detectHoldStockInfo(); // 持股資訊資料夾
  53. }
  54. function addSSEvent(){
  55. computeAssets(); // 持股總額計算
  56. addStockSummaryListener(); //
  57. }
  58. //Header新增按鈕並監聽
  59. function addNavItem(){
  60. /*
  61. // 我的訂閱按鈕
  62. $('<div class="note"><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="" data-toggle="dropdown" id="subMenu">' + Dict[lan].showMySubscribes + '</a><div class="dropdown-menu px-3" aria-labelledby="navbarDropdownMenuLink" style="display: none;" id="subMenuList"></div></li></div>').insertAfter($('.note')[2]);
  63. $('#subMenu')[0].addEventListener("click", ShowSubscribesNavItem);
  64. */
  65. // 選擇語言按鈕
  66. $('<div class="note"><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="" data-toggle="dropdown">' + Dict[lan].language + '</a><div class="dropdown-menu px-3" aria-labelledby="navbarDropdownMenuLink" style="display: none;" id="lanmenu"></div></li></div>').insertAfter($('.note')[2]);
  67. $('#lanmenu').append($('<li class="nav-item"><a class="nav-link" href="" id="lantw">台灣話</a></li><li class="nav-item"><a class="nav-link" href="" id="lanmarstw">ㄏㄒㄨ</a></li><li class="nav-item"><a class="nav-link" href="" id="lanen">English</a></li><li class="nav-item"><a class="nav-link" href="" id="lanjp">日本語</a></li>'));
  68. $('#lantw')[0].addEventListener("click", ()=>{ChangeLanguage("tw");});
  69. $('#lanmarstw')[0].addEventListener("click", ()=>{ChangeLanguage("marstw");});
  70. $('#lanen')[0].addEventListener("click", ()=>{ChangeLanguage("en");});
  71. $('#lanjp')[0].addEventListener("click", () =>{ChangeLanguage("jp");});
  72.  
  73. // 關閉廣告按鈕
  74. $('<li class="nav-item"><a class="nav-link" href="" id="adsBlock">' + Dict[lan].adBlock + '</a></li>').insertAfter($('.note')[2]);
  75. $('#adsBlock')[0].addEventListener("click", blockAD);
  76.  
  77. // 關於插件按鈕
  78. $('<li class="nav-item"><a class="nav-link" href="" id="aboutmebtn">' + Dict[lan].aboutScript + '</a></li>').insertAfter($('.note')[$('.note').length - 1]);
  79. $('#aboutmebtn')[0].addEventListener("click", GotoAboutMe);
  80. }
  81.  
  82. // 監測main的變化並判斷當前屬於哪個頁面加入正確的事件監聽
  83. function addEvent(){
  84. $('#main').bind("DOMNodeInserted DOMNodeRemoved", function(){
  85. // 因AJAX動態生成不斷執行,所以有時候main的變動並不代表換頁,此時無須重新加入事件
  86. if(oldUrl != document.location.href && document.location.href.search(/company\/detail/) != -1)
  87. setTimeout(addCompanyEvent, 1000);
  88. else if(oldUrl != document.location.href && document.location.href.search(/company\/[0-9]+/) != -1)
  89. setTimeout(addSSEvent, 1000);
  90. else if(oldUrl != document.location.href && document.location.href.search(/accountInfo/) != -1)
  91. setTimeout(addAIEvent, 1000);
  92. else if(oldUrl != document.location.href && document.location.href.search(/foundation/) != -1)
  93. setTimeout(addFPEvent, 1000);
  94. wasCompany = (document.location.href.search(/company\/detail/) != -1);
  95. wasStockSummary = (document.location.href.search(/company\/[0-9]+/) != -1);
  96. wasAccountInfo = (document.location.href.search(/accountInfo/) != -1);
  97. wasFoundationPlan = document.location.href.search(/foundation/) != -1;
  98. oldUrl = document.location.href;
  99. });
  100. }
  101.  
  102. function getJsonObj(){
  103. var request = new XMLHttpRequest();
  104. request.open("GET", "https://jsonbin.org/papago89/ACGNStock", false); // 同步連線 POST到該連線位址
  105. request.send();
  106. jsonObj = JSON.parse(request.responseText);
  107. }
  108. //---------------擋廣告---------------//
  109. function blockAD(){
  110. if($('.fixed-bottom').length === 1){
  111. // 自動對所有廣告點擊關閉
  112. var i;
  113. for(i = $('.media.bg-info.text.px-2.py-1.my-2.rounded .d-flex a').length - 1; i >= 0; --i)
  114. $('.media.bg-info.text.px-2.py-1.my-2.rounded .d-flex a')[i].click();
  115. // 隱藏顯示
  116. // $('.fixed-bottom').css("height", "0px");
  117. console.log("Triggered BlockAD");
  118. }
  119. else {
  120. setTimeout(blockAD, 500);
  121. }
  122. }
  123.  
  124. /*************************************/
  125. /************UpdateScript*************/
  126.  
  127. function checkScriptEvent(){
  128. var myVersion = GM_info.script.version;
  129. var oReq = new XMLHttpRequest();
  130. oReq.addEventListener("load", checkScriptVersion);
  131. oReq.open("GET", "https://gf.qytechs.cn/zh-TW/scripts/33359-acgn%E8%82%A1%E7%A5%A8%E7%B3%BB%E7%B5%B1%E6%AF%8F%E8%82%A1%E7%87%9F%E5%88%A9%E5%A4%96%E6%8E%9B.json");
  132. oReq.send();
  133. var oReq2 = new XMLHttpRequest();
  134. oReq2.addEventListener("load", checkMingsScriptVersion);
  135. oReq2.open("GET", "https://gf.qytechs.cn/zh-TW/scripts/33781-acgn%E8%82%A1%E7%A5%A8%E7%B3%BB%E7%B5%B1%E6%AF%8F%E8%82%A1%E7%87%9F%E5%88%A9%E5%A4%96%E6%8E%9B.json");
  136. oReq2.send();
  137. }
  138.  
  139. function checkScriptVersion(){
  140. var obj = JSON.parse(this.responseText);
  141. var myVersion = GM_info.script.version;
  142. //console.log(obj.version.substr(0, 3) + "," + myVersion.substr(0, 3) + "," + (obj.version.substr(0, 3) > myVersion.substr(0, 3)));
  143. if(obj.version.substr(0, 3) > myVersion.substr(0, 3))
  144. $('<li class="nav-item"><a class="nav-link btn btn-primary" href="https://gf.qytechs.cn/zh-TW/scripts/33359-acgn%E8%82%A1%E7%A5%A8%E7%B3%BB%E7%B5%B1%E6%AF%8F%E8%82%A1%E7%87%9F%E5%88%A9%E5%A4%96%E6%8E%9B" id="UpdateScript" target="Blank">' + Dict[lan].updateScript + '</a></li>').insertAfter($('.nav-item')[$('.nav-item').length - 1]);
  145. else
  146. setTimeout(checkScriptEvent, 600000);
  147. }
  148.  
  149. function checkMingsScriptVersion(){
  150. var obj = JSON.parse(this.responseText);
  151. var myVersion = GM_info.script.version;
  152. //console.log(obj.version.substr(0, 3) + "," + myVersion.substr(0, 3) + "," + (obj.version.substr(0, 3) > myVersion.substr(0, 3)));
  153. if(obj.version.substr(0, 3) > myVersion.substr(0, 3))
  154. $('<li class="nav-item"><a class="nav-link btn btn-primary" href="https://gf.qytechs.cn/zh-TW/scripts/33781-acgn%E8%82%A1%E7%A5%A8%E7%B3%BB%E7%B5%B1%E6%AF%8F%E8%82%A1%E7%87%9F%E5%88%A9%E5%A4%96%E6%8E%9B" id="UpdateScript" target="Blank">' + Dict[lan].updateScript + '</a></li>').insertAfter($('.nav-item')[$('.nav-item').length - 1]);
  155. else
  156. setTimeout(checkScriptEvent, 600000);
  157. }
  158.  
  159. /************UpdateScript*************/
  160. /*************************************/
  161. /************stockSummary*************/
  162.  
  163. function addStockSummaryListener(){
  164. setTimeout(computeAssets, 2000);
  165. $(".btn.btn-secondary.mr-1")[0].addEventListener("click", addComputeEvent);
  166. $(".btn.btn-secondary.mr-1")[1].addEventListener("click", addComputeEvent);
  167.  
  168. var pagesBtn = $(".page-item");
  169. for(var i = 0; i < pagesBtn.length; i++)
  170. pagesBtn[i].addEventListener("click", addComputeEvent);
  171. console.log("Triggered StockSummary");
  172. }
  173.  
  174. function addComputeEvent(){
  175. setTimeout(addStockSummaryListener, 2000);
  176. }
  177. function computeAssets(){
  178. var assets = 0, tag, price, hold, classAssets;
  179. //方格模式
  180. if($(".col-12.col-md-6.col-lg-4.col-xl-3").length > 0){
  181. for(var i = 0; i < $('.company-card').length; ++i){
  182. price = Number($('.company-card')[i].innerText.match(/\$ [0-9]+\(([0-9]+)\)/)[1]);
  183. hold = Number($('.company-card')[i].innerText.match(/([0-9]+).+%.+/)[1]);
  184. assets += price * hold;
  185. console.log("price = " + price + ",hold = " + hold);
  186. }
  187. console.log("本頁持股價值: " + assets);
  188. classAssets = $("#totalAssetsNumber");
  189. if(classAssets.length === 0){
  190. $('<div class="media company-summary-item border-grid-body" id = "totalAssets"><div class="col-6 text-right border-grid" id = "totalAssetsTitle"><h2>' + Dict[lan].totalAssetsInThisPage + '</h2></div></div>').insertAfter($('.card-title.mb-1')[0]);
  191. $('<div class="col-6 text-right border-grid" id = "totalAssetsNumber"><h2>$ ' + assets + '</h2></div>').insertAfter($('#totalAssetsTitle')[0]);
  192. }
  193. else{
  194. $("#totalAssetsNumber")[0].innerHTML = "<h2>$ " + assets + "</h2>";
  195. }
  196. }
  197. else{ //列表模式
  198. //console.log($(".col-8.col-lg-3.text-right.border-grid"));
  199. for(var j = 0; j < $('.media-body.row.border-grid-body').length; ++j){
  200. price = Number($('.media-body.row.border-grid-body')[j].innerText.match(/\$ [0-9]+\(([0-9]+)\)/)[1]);
  201. hold = Number($('.media-body.row.border-grid-body')[j].innerText.match(/您在該公司持有([0-9]+)數量的股份/)[1]); // 找出持股量
  202. console.log("價= " + price + ",持= " + hold + ",總= " + (price * hold));
  203. assets += price * hold;
  204. }
  205. console.log("本頁持股價值: " + assets);
  206. classAssets = $("#totalAssetsNumber");
  207. if(classAssets.length === 0){
  208. $('<div class="media company-summary-item border-grid-body" id = "totalAssets"><div class="col-6 text-right border-grid" id = "totalAssetsTitle"><h2>' + Dict[lan].totalAssetsInThisPage + '</h2></div></div>').insertAfter($('.card-title.mb-1')[0]);
  209. $('<div class="col-6 text-right border-grid" id = "totalAssetsNumber"><h2>$ ' + assets + '</h2></div>').insertAfter($('#totalAssetsTitle')[0]);
  210. }
  211. else{
  212. $("#totalAssetsNumber")[0].innerHTML = "<h2>$ " + assets + "</h2>";
  213. }
  214. }
  215. //setTimeout(computeAssets, 1000);
  216. }
  217.  
  218. /************stockSummary*************/
  219. /*************************************/
  220. /**************company****************/
  221. //---------------按鍵區---------------//
  222. function addCompanyClickListener(){
  223. if($('.d-block.h4').length === 6){
  224. // 初始化 先看使用者有沒有預設打開資料夾
  225. folderOpenString = "fa-folder-open";
  226. folderCloseString = "12345678";
  227. chartEvent();
  228. numbersEvent();
  229. orderEvent();
  230. productEvent();
  231. directorEvent();
  232. logEvent();
  233. folderOpenString = "fa-folder";
  234. folderCloseString = "fa-folder-open";
  235.  
  236. // 註冊事件
  237. $('.d-block.h4')[0].addEventListener("click", chartEvent); //股價趨勢
  238. $('.d-block.h4')[1].addEventListener("click", numbersEvent); //數據資訊
  239. $('.d-block.h4')[2].addEventListener("click", orderEvent); //交易訂單
  240. $('.d-block.h4')[3].addEventListener("click", productEvent); //產品中心
  241. $('.d-block.h4')[4].addEventListener("click", directorEvent); //董事會
  242. $('.d-block.h4')[5].addEventListener("click", logEvent); //所有紀錄
  243. console.log("OnclickListener Registered");
  244. }
  245. else{
  246. setTimeout(addCompanyClickListener, 500);
  247. }
  248. console.log("Triggered Company");
  249. }
  250.  
  251. var folderOpenString, folderCloseString;
  252. // 股價趨勢
  253. function chartEvent(){
  254. var folderstate = $(".d-block.h4 i")[0].classList[1];
  255. if(folderstate === folderOpenString){
  256. //console.log("Open");
  257. //Open Event
  258. }
  259. else if(folderstate === folderCloseString){
  260. //Close Event
  261. }
  262. }
  263. // 數據資訊
  264. function numbersEvent(){
  265. var folderstate = $(".d-block.h4 i")[1].classList[1];
  266. if(folderstate === folderOpenString){
  267. //Open Event
  268. console.log("Open numbersfolder");
  269. setTimeout(addSomeInfo, 1000);
  270.  
  271. }
  272. else if(folderstate === folderCloseString){
  273. //Close Event
  274. console.log("close numbersfolder");
  275. deleteSomeInfo();
  276. }
  277. }
  278. // 交易訂單
  279. function orderEvent(){
  280. var folderstate = $(".d-block.h4 i")[2].classList[1];
  281. if(folderstate === folderOpenString){
  282. //console.log("Open");
  283. //Open Event
  284. }
  285. else if(folderstate === folderCloseString){
  286. //Close Event
  287. }
  288. }
  289. // 產品中心
  290. function productEvent(){
  291. var folderstate = $(".d-block.h4 i")[3].classList[1];
  292. if(folderstate === folderOpenString){
  293. //console.log("Open");
  294. //Open Event
  295. }
  296. else if(folderstate === folderCloseString){
  297. //Close Event
  298. }
  299. }
  300. // 董事會
  301. function directorEvent(){
  302. var folderstate = $(".d-block.h4 i")[4].classList[1];
  303. if(folderstate === folderOpenString){
  304. //console.log("Open");
  305. //Open Event
  306. }
  307. else if(folderstate === folderCloseString){
  308. //Close Event
  309. }
  310. }
  311. // 所有紀錄
  312. function logEvent(){
  313. var folderstate = $(".d-block.h4 i")[5].classList[1];
  314. if(folderstate === folderOpenString){
  315. //console.log("Open");
  316. //Open Event
  317. }
  318. else if(folderstate === folderCloseString){
  319. //Close Event
  320. }
  321. }
  322. // 計算每股盈餘、本益比、益本比並顯示
  323. function addSomeInfo(){
  324. var revenue, totalStock, earnPerShare, stockPrice;
  325.  
  326. stockPrice = $('.col-8.col-md-4.col-lg-2.text-right.border-grid')[0].innerHTML.match(/[0-9]+/);
  327. revenue = $('.col-8.col-md-4.col-lg-2.text-right.border-grid')[3].innerHTML.match(/[0-9]+/);
  328. totalStock = $('.col-8.col-md-4.col-lg-2.text-right.border-grid')[4].innerHTML.match(/[0-9]+/);
  329. earnPerShare = 0.8075 * revenue / totalStock;
  330. if($('#someInfo1').length !== 1){ // 防止雞巴人的雞巴操作:快速連續開關資料夾導致出現多組每股盈餘
  331. $('<div class="col-8 col-md-4 col-lg-2 text-right border-grid" id = "someInfo5">' + (earnPerShare / stockPrice).toFixed(2) + '</div>').insertAfter($('.row.border-grid-body')[0].children[14 + $('canvas').length]);
  332. $('<div class="col-4 col-md-2 col-lg-2 text-right border-grid" id = "someInfo6">' + Dict[lan].benefitRatio + '</div>').insertAfter($('.row.border-grid-body')[0].children[14 + $('canvas').length]);
  333.  
  334. $('<div class="col-8 col-md-4 col-lg-2 text-right border-grid" id = "someInfo1">' + ((earnPerShare === 0) ? "∞" : (stockPrice / earnPerShare).toFixed(2)) + '</div>').insertAfter($('.row.border-grid-body')[0].children[14 + $('canvas').length]);
  335. $('<div class="col-4 col-md-2 col-lg-2 text-right border-grid" id = "someInfo2">' + Dict[lan].PERatio + '</div>').insertAfter($('.row.border-grid-body')[0].children[14 + $('canvas').length]);
  336.  
  337. $('<div class="col-8 col-md-4 col-lg-2 text-right border-grid" id = "someInfo3">' + earnPerShare.toFixed(2) + '</div>').insertAfter($('.row.border-grid-body')[0].children[14 + $('canvas').length]);
  338. $('<div class="col-4 col-md-2 col-lg-2 text-right border-grid" id = "someInfo4">' + Dict[lan].earnPerShare + '</div>').insertAfter($('.row.border-grid-body')[0].children[14 + $('canvas').length]);
  339.  
  340. console.log("addSomeInfo!!");
  341. }
  342. }
  343. // 清出額外新增的資訊
  344. function deleteSomeInfo(){
  345. if($('#someInfo1').length !== 1) // 無資料不須清除
  346. return;
  347. var element = document.getElementById("someInfo1");
  348. element.parentNode.removeChild(element);
  349. element = document.getElementById("someInfo2");
  350. element.parentNode.removeChild(element);
  351. element = document.getElementById("someInfo3");
  352. element.parentNode.removeChild(element);
  353. element = document.getElementById("someInfo4");
  354. element.parentNode.removeChild(element);
  355. element = document.getElementById("someInfo5");
  356. element.parentNode.removeChild(element);
  357. element = document.getElementById("someInfo6");
  358. element.parentNode.removeChild(element);
  359.  
  360. }
  361.  
  362. /**************company****************/
  363. /*************************************/
  364. /************accountInfo**************/
  365.  
  366. /*************accountInfoStockPrice***/
  367.  
  368. function detectHoldStockInfo(){
  369. if(jsonObj === null)
  370. getJsonObj();
  371. else{
  372. var i, holdStockElement, companyLink, price, hold, index, total = 0, pageNum = 1;
  373. for(i = 0; i < 4 && i < $('.col-12.border-grid').length; ++i){
  374. // 持股資訊只有可能在前四個col-12 border-grid中 先找出來
  375. if($('.col-12.border-grid')[i].innerText.match(/擁有.+公司的.+股票/) !== null)
  376. break;
  377. }
  378. if(i !== 4 && i !== $('.col-12.border-grid').length && $('.col-12.border-grid')[i].innerText.match(/參考股價/) === null){ // 持股資訊未開啟 或已插入資料
  379. holdStockElement = $('.col-12.border-grid')[i];
  380. for(i = 0; i < holdStockElement.children.length; ++i){
  381. if(holdStockElement.children[i].innerHTML.match(/href="(\/company[^"]+)/) !== null){
  382. companyLink = holdStockElement.children[i].innerHTML.match(/href="([^"]+)/)[1];
  383. index = jsonObj.companys.findIndex(function(e, i){
  384. return e.companyLink === companyLink;
  385. });
  386. if(index === -1){
  387. price = 0;
  388. hold = 0;
  389. }
  390. else{
  391. price = Number(jsonObj.companys[index].companyPrice);
  392. hold = Number(holdStockElement.children[i].innerText.match(/擁有.+公司的([0-9]+)股股票/)[1]);
  393. }
  394. total += price * hold;
  395. holdStockElement.children[i].innerHTML += "參考股價" + price + "元,有" + price * hold + "元資產。";
  396. }
  397. }
  398. if($('#assetDisplayDiv').length === 0)
  399. $('<div id="assetDisplayDiv"><p>公司股價更新時間為' + jsonObj.publishTime + '</p><p>目前共有<span id="totalAsset">0</span>元資產</p></div>').insertAfter(holdStockElement.children[i - 1]);
  400. if($('.page-item.active').length !== 0) // 看看是否能找出頁碼
  401. pageNum = $('.page-item.active')[0].innerText;
  402. $('#assetDisplayDiv')[0].innerHTML += '<p>第' + pageNum + '頁共有' + total + '元資產</p>';
  403. $('#totalAsset')[0].innerText = (Number($('#totalAsset')[0].innerText) + total);
  404.  
  405. if($('#clearAssetMessageBtn').length === 0){
  406. $('<button class="btn btn-danger btn-sm" type="button" id="clearAssetMessageBtn">清除總資產訊息</button>').insertAfter(holdStockElement.children[i - 1]);
  407. $('#clearAssetMessageBtn')[0].addEventListener("click", function(){$('#assetDisplayDiv').remove();});
  408. }
  409. if($('#computeBtn').length === 0){
  410. $('<button class="btn btn-danger btn-sm" type="button" id="computeBtn">計算此頁資產</button>').insertAfter(holdStockElement.children[i - 1]);
  411. $('#computeBtn')[0].addEventListener("click", detectHoldStockInfo);
  412. }
  413. }
  414. // console.log("Triggered ShowSubscribesListener");
  415. }
  416. if($('#computeBtn').length === 0)
  417. setTimeout(detectHoldStockInfo, 500);
  418. }
  419.  
  420. /*************accountInfoStockPrice***/
  421.  
  422. /*************Tax*********************/
  423. function AddTaxListener(){
  424. $('<div class="row border-grid-body" style="margin-top: 15px;"><div class="col-12 border-grid" id="customtax"><a class="d-block h4" href="" data-toggle-panel="customTax">' + Dict[lan].taxCalculation + '<i class="fa fa-folder" aria-hidden="true"></i></a></div></div>').insertAfter($(".row.border-grid-body")[0]);
  425. if($("#customtax").length > 0){
  426. $("#customtax")[0].addEventListener("click", taxfolderevent);
  427. taxfoldericon = $("#customtax .fa")[0];
  428. }
  429. else{
  430. setTimeout(AddTaxListener, 500);
  431. }
  432. console.log("Triggered Tax");
  433.  
  434. }
  435. var taxfoldericon, taxtxt, taxinpt, taxvalue;
  436. function taxfolderevent(){
  437.  
  438. if(taxfoldericon.classList[1] === "fa-folder"){
  439. taxfoldericon.classList.remove("fa-folder");
  440. taxfoldericon.classList.add("fa-folder-open");
  441. taxtxt = $('<div class="col-6 text-right border-grid" id = "taxtext"><h5>' + Dict[lan].enterTotalAssets + '</h5></div>');
  442. taxtxt.insertAfter($('#customtax')[0]);
  443. taxinpt = $('<div class="col-6 text-right border-grid" id = "taxinputrect"><input id="input-text" class="form-control" type="text"></div>');
  444. taxinpt.insertAfter($('#taxtext')[0]);
  445. taxvalue = $('<div class="col-6 text-right border-grid" id = "outputtext"><h5>' + Dict[lan].yourTax + '</h5></div><div class="col-6 text-right border-grid" id = "outputdiv"><h5 id="output">$ ' + 0 + '</h5></div>');
  446. taxvalue.insertAfter($('#taxinputrect')[0]);
  447. $('#input-text').bind('input', computeTax);
  448. }
  449. else
  450. {
  451. taxfoldericon.classList.add("fa-folder");
  452. taxfoldericon.classList.remove("fa-folder-open");
  453. taxtxt.remove();
  454. taxinpt.remove();
  455. taxvalue.remove();
  456. }
  457. }
  458. var taxlimit = [10000, 100000, 500000, 1000000];
  459. var taxalllimit = 1000000;
  460. var taxpecent = 0.03;
  461. function computeTax(){
  462. var input = $('#input-text').val().match(/[0-9]+/);
  463. console.log(input);
  464. if(!input || 0 === input.length){
  465. console.log("N");
  466. return;
  467. }
  468. var output = 0;
  469. var lastlimit = 0;
  470.  
  471. for(var i = 0;;i++){
  472. var limit = taxalllimit;
  473. var tax = taxpecent * i;
  474. if(i < taxlimit.length){
  475. limit = taxlimit[i] - lastlimit;
  476. }
  477. if(tax > 0.6){
  478. tax = 0.6;
  479. output += input * tax;
  480. break;
  481. }
  482. else{
  483. if(input < limit){
  484. output += input * tax;
  485. break;
  486. }
  487. else{
  488. output += limit * tax;
  489. input -= limit;
  490. lastlimit += limit;
  491. }
  492. }
  493. }
  494. $("#output").text("$ " + Math.ceil(output));
  495.  
  496. }
  497. /*************Tax*********************/
  498.  
  499. /************accountInfo**************/
  500. /*************************************/
  501. /************foundationPlan***********/
  502.  
  503. /***********foundationPlanInformation*/
  504.  
  505. function getStockPrice(i, cardmode = true){
  506. var intervalUp = 1, temp;
  507. if(cardmode){
  508. temp = $('.company-card-mask')[i].children[5].innerText.match(/[0-9]+/)[0];
  509. }
  510. else{
  511. temp = $('.media-body.row.border-grid-body:eq(' + i + ') .col-8.col-lg-3.text-right.border-grid:eq(3)')[0].innerText.match(/[0-9]+/)[0];
  512. }
  513. temp /= 1000;
  514. while(temp > intervalUp)
  515. intervalUp = intervalUp << 1; // 乘以2
  516. return intervalUp >> 1;
  517. }
  518.  
  519. function getPersonalStockAmount(i, stockPrice, cardmode = true){
  520. if(cardmode){
  521. return ($('.company-card-mask')[i].children[6].innerText.match(/[0-9]+/)[0]) / stockPrice;
  522. }
  523. else{
  524. if($('.media-body.row.border-grid-body:eq(' + i + ') .mb-1')[0].innerText.search("您尚未對此計劃進行過投資。") != -1){
  525. return 0;
  526. }
  527. else return $('.media-body.row.border-grid-body:eq(' + i + ') .mb-1')[0].innerText.match(/[0-9]+/)[0] / stockPrice;
  528.  
  529. }
  530. }
  531. // 股權
  532. function getStockRight(i, stockPrice, cardmode = true){
  533. // (個人投資額/預估股價) / (總投資/預估股價)
  534. if(cardmode){
  535. if($('.company-card-mask')[i].children[6].innerText.match(/[0-9]+/)[0] === 0)
  536. return 0;
  537. return 1.0 * ($('.company-card-mask')[i].children[6].innerText.match(/[0-9]+/)[0] / stockPrice) / ($('.company-card-mask')[i].children[5].innerText.match(/[0-9]+/)[0] / stockPrice);
  538. }
  539. else{
  540. if($('.media-body.row.border-grid-body:eq(' + i + ') .mb-1')[0].innerText.search("您尚未對此計劃進行過投資。") != -1){
  541. return 0;
  542. }
  543. return $('.media-body.row.border-grid-body:eq(' + i + ') .mb-1')[0].innerText.match(/[0-9]+/)[0] / stockPrice / ( $('.media-body.row.border-grid-body:eq(' + i + ') .col-8.col-lg-3.text-right.border-grid:eq(3)')[0].innerText.match(/[0-9]+/)[0] / stockPrice);
  544. }
  545. }
  546. // 卡片版
  547. function addInfoToCompanyCardVersion(i){
  548. var stockPrice, stockAmount, stockRight;
  549. stockPrice = getStockPrice(i);
  550. stockAmount = getPersonalStockAmount(i, stockPrice);
  551. stockRight = getStockRight(i, stockPrice);
  552. $('<div name="foundationPlanNewInfo" class="row row-info d-flex justify-content-between"><p>' + Dict[lan].foundationPlanStock + '</p><p>' + (stockRight * 100).toFixed(2) + '%' + '</p></div>').insertAfter($('.company-card-mask')[i].children[5]);
  553. $('<div name="foundationPlanNewInfo" class="row row-info d-flex justify-content-between"><p>' + Dict[lan].foundationPlanShare + '</p><p>' + Math.floor(stockAmount) + '股' + '</p></div>').insertAfter($('.company-card-mask')[i].children[5]);
  554. $('<div name="foundationPlanNewInfo" class="row row-info d-flex justify-content-between"><p>' + Dict[lan].foundationPlanStockPrice + '</p><p>$' + stockPrice + '</p></div>').insertAfter($('.company-card-mask')[i].children[5]);
  555. }
  556. function addInfoToCompanyListVersion(i){
  557. var stockPrice, stockAmount, stockRight;
  558. stockPrice = getStockPrice(i, false);
  559. stockAmount = getPersonalStockAmount(i, stockPrice, false);
  560. stockRight = getStockRight(i, stockPrice, false);
  561. $('<div name="foundationPlanNewInfo" class="col-4 col-lg-6 text-right border-grid"></div>').insertAfter($('.media-body.row.border-grid-body:eq(' + i + ') .col-8.col-lg-3.text-right.border-grid:eq(3)')[0]);
  562. $('<div name="foundationPlanNewInfo" class="col-4 col-lg-3 text-right border-grid">' + Dict[lan].foundationPlanStock + '</div><div class="col-8 col-lg-3 text-right border-grid" id="customStockRight' + i + '">' + (stockRight * 100).toFixed(2) + '%</div>').insertAfter($('.media-body.row.border-grid-body:eq(' + i + ') .col-8.col-lg-3.text-right.border-grid:eq(3)')[0]);
  563. $('<div name="foundationPlanNewInfo" class="col-4 col-lg-3 text-right border-grid">' + Dict[lan].foundationPlanShare + '</div><div class="col-8 col-lg-3 text-right border-grid" id="customStockAmount' + i + '">' + Math.floor(stockAmount) + '股</div>').insertAfter($('.media-body.row.border-grid-body:eq(' + i + ') .col-8.col-lg-3.text-right.border-grid:eq(3)')[0]);
  564. $('<div name="foundationPlanNewInfo" class="col-4 col-lg-3 text-right border-grid">' + Dict[lan].foundationPlanStockPrice + '</div><div class="col-8 col-lg-3 text-right border-grid" id="customStockPrice' + i + '">$ ' + stockPrice + '</div>').insertAfter($('.media-body.row.border-grid-body:eq(' + i + ') .col-8.col-lg-3.text-right.border-grid:eq(3)')[0]);
  565. }
  566. var FPModeCard = "fa-th", FPModeList = "fa-th-list";
  567. function addFPEvent(){
  568. setTimeout(checkFPInfo, 500);
  569. setTimeout(addFormControlEvent, 500); // 新創既有公司搜尋提示
  570.  
  571. $('.btn.btn-secondary.mr-1')[0].addEventListener("click", () => {setTimeout(addFPEvent, 1000);}, {once: true});
  572. var linkitem = $('.pagination.pagination-sm.justify-content-center.mt-1 a');
  573. count = linkitem.length;
  574. for(var i = 0;i < count;i++){
  575. linkitem[i].addEventListener("click", () => {setTimeout(addFPEvent, 1000);}, {once: true});
  576. }
  577. console.log("Triggered PFEvent");
  578. }
  579. function checkFPInfo(){
  580. if($('div[name="foundationPlanNewInfo"]').length !== 0)
  581. return;
  582. if($('.btn.btn-secondary.mr-1 i')[0].classList[1] === FPModeCard){
  583. if($('.company-card-mask').length > 0){
  584. showFPCard();
  585. }
  586. else setTimeout(checkFPInfo, 500);
  587. }
  588. else if($('.btn.btn-secondary.mr-1 i')[0].classList[1] === FPModeList){
  589. if($('.media-body.row.border-grid-body').length > 0){
  590. showFPList();
  591. }
  592. else setTimeout(checkFPInfo, 500);
  593. }
  594. }
  595. function showFPCard(){
  596. var i, companyAmount;
  597. companyAmount = $('.company-card-mask').length;
  598. for(i = 0; i < companyAmount; ++i)
  599. addInfoToCompanyCardVersion(i);
  600. }
  601. function showFPList(){
  602. var i, companyAmount;
  603. companyAmount = $('.media-body.row.border-grid-body').length;
  604. for(i = 0; i < companyAmount; ++i)
  605. addInfoToCompanyListVersion(i);
  606.  
  607. }
  608. /***********foundationPlanInformation*/
  609.  
  610. /***********foundationPlanSearCompany*/
  611.  
  612.  
  613. function displayCompanyName(companys){
  614. var i, displayDiv = '<div id="displayResult">';
  615. if(companys.length !== 0){
  616. displayDiv += '<a href="' + companys[0].companyLink + '">' + companys[0].companyName + '</a>';
  617. for(i = 1; i < companys.length; ++i)
  618. displayDiv += ', <a href="' + companys[i].companyLink + '">' + companys[i].companyName + '</a>';
  619. }
  620. else{
  621. displayDiv += '於' + jsonObj.publishTime + '更新公司名冊';
  622. }
  623. displayDiv += '</div>';
  624. if($('#displayResult').length !== 0)
  625. $('#displayResult').remove();
  626. console.log(displayDiv);
  627. $(displayDiv).insertAfter($('.input-group-btn'));
  628. $('#displayResult').css("width", "60%");
  629. $('#displayResult').css("height", "30px");
  630. $('#displayResult').css("overflow", "scroll");
  631. $('#displayResult').css("overflow-x", "hidden");
  632. }
  633.  
  634. function autoCheck(){
  635. var searchString, searchRegExp, companyName = [], result;
  636. searchString = $('.form-control')[0].value;
  637. if(searchString.length !== 0){
  638. searchRegExp = new RegExp(searchString , 'i'); // 'i' makes the RegExp ignore case
  639. result = jsonObj.companys.filter(function(e){ // Filter out any items that don't pass the
  640. return searchRegExp.test(e.companyName) || searchRegExp.test(e.companyTags); // RegExp test.
  641. });
  642. /*
  643. companyName = result.map(function(e){
  644. return e.companyName;
  645. });
  646. */
  647. }
  648. displayCompanyName(result);
  649. }
  650.  
  651. function addFormControlEvent(){
  652. $('.form-control').keyup(autoCheck);
  653. // 考慮資料更新週期極長,已有資料就不用再拿了
  654. if(jsonObj === null){
  655. getJsonObj();
  656. }
  657. }
  658.  
  659.  
  660. /***********foundationPlanSearCompany*/
  661.  
  662. /************foundationPlan***********/
  663. /*************************************/
  664. /**************aboutMe****************/
  665.  
  666. function GotoAboutMe(){
  667. $('.card-block').remove();
  668. SetAboutMeString();
  669. console.log("Triggered AboutMe");
  670.  
  671. }
  672.  
  673.  
  674.  
  675. var aboutmestr;
  676. function SetAboutMeString(){
  677. aboutmestr = '<div class="card-block"><div class="col-5"><h1 class="card-title mb-1">關於插件</h1></div><div class="col-5">by papago89 and Ming</div><hr>';
  678.  
  679. aboutmestr += div('要離開本頁面記得點進來的那一頁以外的其他頁面<hr>');
  680. aboutmestr += div('本插件功能不定時增加中,目前功能有以下幾個:');
  681. aboutmestr += div('');
  682. aboutmestr += div('。在頁面<span class="text-info">股市總覽</span>可以查看本頁股票總值,建議開啟<span class="text-info">只列出我所持有的股票</span>。');
  683. aboutmestr += div('。在頁面<span class="text-info">新創計畫</span>可以查看推測股價、推測股權、推測應得股數。');
  684. aboutmestr += div('。在頁面<span class="text-info">新創計畫</span>搜尋欄鍵入文字時會提示股市總覽中是否已存在相同名稱或標籤之公司。');
  685. aboutmestr += div('。在各公司頁面數據資訊處增加每股盈餘、本益比、益本比。');
  686. aboutmestr += div('。在頁面<span class="text-info">帳號資訊</span>增加稅金試算,輸入總資產後就會算出你應該繳的稅金。');
  687. aboutmestr += div('。在頁面<span class="text-info">帳號資訊</span>增加資產換算。');
  688. aboutmestr += div('。按鈕<span class="text-info">廣告關閉</span>隱藏所有廣告讓你什麼都看不到。');
  689. aboutmestr += div('。在頁面<span class="text-info">關於插件</span>增加插件功能介紹,版本更新紀錄,還有廢話。');
  690. aboutmestr += div('。按鈕<span class="text-info">點我更新插件</span>在greasyfork有新版本時會自動跳出提示大家更新。');
  691. aboutmestr += div('。按鈕<span class="text-info">選擇語言</span>可以更改語言,不過要重新整理頁面才會生效。');
  692. // aboutmestr += div('。各公司頁面可以透過按鈕<span class="text-info">訂閱公司</span>訂閱,在頁面<span class="text-info">帳號資訊</span>可以直接前往已訂閱的公司。');
  693.  
  694. aboutmestr += div('<hr>');
  695. aboutmestr += div('有任何問題或建議請到Discord:ACGN Stock留言');
  696. aboutmestr += div('<a href="https://gf.qytechs.cn/zh-TW/scripts/33359-acgn%E8%82%A1%E7%A5%A8%E7%B3%BB%E7%B5%B1%E6%AF%8F%E8%82%A1%E7%87%9F%E5%88%A9%E5%A4%96%E6%8E%9B" target="_blank">更新插件</a>');
  697.  
  698.  
  699.  
  700. aboutmestr += '</div>';
  701. aboutmestr +='<div class="card-block"><div class="row border-grid-body" style="margin-top: 15px;"><div class="col-12 border-grid" id="customupdate"><a class="d-block h4" href="" data-toggle-panel="update">更新紀錄<i class="fa fa-folder" aria-hidden="true"></i></a></div></div></div>';
  702. $('.card').append($(aboutmestr));
  703. $('#customupdate')[0].addEventListener("click", UpdateEvent);
  704. updatefoldericon = $("#customupdate .fa")[0];
  705. }
  706. var totaldivcount = 0;
  707. function div(str){
  708. return '<div id="customdiv' + totaldivcount + '">' + str + '</div>';
  709. }
  710.  
  711.  
  712. var updatefoldericon;
  713. function UpdateEvent(){
  714.  
  715. if(updatefoldericon.classList[1] === "fa-folder"){
  716. updatefoldericon.classList.remove("fa-folder");
  717. updatefoldericon.classList.add("fa-folder-open");
  718. V_2_500();
  719. V_2_300();
  720. V_2_200();
  721. V_2_000();
  722. V_1_900();
  723. V_1_900();
  724. V_1_800();
  725. V_1_73();
  726. V_1_72();
  727. V_1_70();
  728. V_1_63();
  729. V_1_62();
  730. V_1_61before();
  731. }
  732. else
  733. {
  734. updatefoldericon.classList.add("fa-folder");
  735. updatefoldericon.classList.remove("fa-folder-open");
  736. $('.col-12.border-grid:gt(0)').remove();
  737. }
  738. console.log("Triggered UpdateInfo");
  739.  
  740. }
  741.  
  742. function V_2_500(){
  743. var vid = addversion(2, 500);
  744. var vtext = div('<span class="text-info">更新腳本</span>連動到Ming,現在Ming也可以自己發布新版腳本讓大家更新了。');
  745.  
  746. $('#' + vid).append($(vtext));
  747. }
  748. function V_2_300(){
  749. var vid = addversion(2, 300);
  750. var vtext = div('移除<span class="text-info">訂閱</span>功能');
  751.  
  752.  
  753. $('#' + vid).append($(vtext));
  754. }
  755. function V_2_200(){
  756. var vid = addversion(2, 200);
  757. var vtext = div('新增<span class="text-info">新創搜尋提示</span>功能');
  758. vtext += div('新增<span class="text-info">帳號頁面持股換算資產</span>功能');
  759.  
  760.  
  761. $('#' + vid).append($(vtext));
  762. }
  763. function V_2_000(){
  764. var vid = addversion(2, 000);
  765. var vtext = div('新增<span class="text-info">訂閱</span>功能');
  766.  
  767.  
  768. $('#' + vid).append($(vtext));
  769. }
  770. function V_1_900(){
  771. var vid = addversion(1, 900);
  772. var vtext = div('新增<span class="text-info">選擇語言</span>');
  773.  
  774.  
  775. $('#' + vid).append($(vtext));
  776. }
  777. function V_1_800(){
  778. var vid = addversion(1, 800);
  779. var vtext = div('新增<span class="text-info">點我更新插件</span>按鈕');
  780.  
  781.  
  782. $('#' + vid).append($(vtext));
  783. }
  784.  
  785. function V_1_73(){
  786. var vid = addversion(1, 73);
  787. var vtext = div('<span class="text-info">更新插件</span>連結現在會在新分頁開啟連結,讓原本的頁面可以繼續看股票。');
  788. vtext += div('修正<span class="text-info">關於插件</span>中,更新紀錄排序錯亂的問題。');
  789. vtext += div('新增<span class="text-info">新創計畫</span>下,列表模式的推測股價、推測股權、推測應得股數。');
  790. vtext += div('優化一些日誌顯示,讓開發人員在除錯更方便一些。');
  791.  
  792.  
  793. $('#' + vid).append($(vtext));
  794. }
  795. function V_1_72(){
  796. var vid = addversion(1, 72);
  797. var vtext = div('優化<span class="text-info">廣告關閉</span>功能。');
  798. vtext += div('好像還有新增一些功能什麼的。');
  799. $('#' + vid).append($(vtext));
  800. }
  801. function V_1_70(){
  802. var vid = addversion(1, 70);
  803. var vtext = div('新增功能<span class="text-info">廣告關閉</span>將會隱藏所有廣告,按過後只要不關閉頁面你就再也看不到任何廣告了,包含公告以及新發布的廣告。');
  804. $('#' + vid).append($(vtext));
  805.  
  806. }
  807.  
  808. function V_1_63(){
  809. var vid = addversion(1, 63);
  810. var vtext = div('修正<span class="text-info">股市總覽</span>中列表模式如果出現有交易尚未完成會造成計算錯誤');
  811. $('#' + vid).append($(vtext));
  812.  
  813. }
  814.  
  815. function V_1_62(){
  816. var vid = addversion(1, 62);
  817. var vtext = div('新增頁面<span class="text-info">關於插件</span>');
  818. //vtext += div('隨便一些字');
  819. $('#' + vid).append($(vtext));
  820.  
  821. }
  822. function V_1_61before(){
  823. $('<div class="col-12 border-grid" id="V1_61before"><h4>版本1.61以前:</h4><div id="customdiv0">新增了一些功能,不過不是很重要</div></div>').insertAfter($('.col-12.border-grid')[$('.col-12.border-grid').length - 1]);
  824. }
  825. function addversion(majorV, minorV){
  826. var vtext = '<div class="col-12 border-grid" id = "V' + majorV + '_' + minorV + '"><h4>版本' + majorV + '.' + minorV + ':</h4></div>';
  827. if($('.col-12.border-grid').length > 0){
  828. $(vtext).insertAfter($('.col-12.border-grid')[$('.col-12.border-grid').length - 1]);
  829. }
  830. else{
  831. $(vtext).insertAfter($('#customupdate')[0]);
  832. }
  833. return "V" + majorV + "_" + minorV;
  834. }
  835.  
  836. var totaldivcount = 0;
  837. function adddiv(str){
  838. aboutmestr += '<div class="row mb-1" id="customdiv' + totaldivcount + '">' + str + '</div>';
  839. }
  840. /**************aboutMe****************/
  841. /*************Language****************/
  842.  
  843. var lan = "";
  844. lan = null !== window.localStorage.getItem ("PM_language") ? window.localStorage.getItem ("PM_language") : "tw";
  845. function ChangeLanguage(l){
  846. if(lan === l)return;
  847. lan = l;
  848. window.localStorage.setItem ("PM_language", l);
  849. window.location.reload();
  850. }
  851. var Dict = {
  852. tw: {
  853. language: "選擇語言",
  854. adBlock : "關閉廣告",
  855. aboutScript: "關於插件",
  856. updateScript: "更新腳本",
  857. totalAssetsInThisPage: "本頁股票總值:",
  858. benefitRatio: "益本比:",
  859. PERatio: "本益比:",
  860. earnPerShare: "每股盈餘:",
  861. taxCalculation: "稅金試算",
  862. enterTotalAssets: "輸入你的總資產:",
  863. yourTax: "你應繳的稅金:",
  864. foundationPlanStock: "當前股權應為:",
  865. foundationPlanShare: "當前投資應得:",
  866. foundationPlanStockPrice: "當前股價應為:",
  867. subscribe: "訂閱公司",
  868. unsubscribe: "取消訂閱",
  869. showMySubscribes: "我的訂閱",
  870. goToCompany: "前往",
  871.  
  872. },
  873. en: {
  874. language: "language",
  875. adBlock : "Block Ad",
  876. aboutScript: "About Script",
  877. updateScript: "Update Script",
  878. totalAssetsInThisPage: "Total assets in this page :",
  879. benefitRatio: "benefit ratio :",
  880. PERatio: "P/E ratio :",
  881. earnPerShare: "Earning per share :",
  882. taxCalculation: "Tax calculation",
  883. enterTotalAssets: "Enter your total assets :",
  884. yourTax: "your tax :",
  885. foundationPlanStock: "Your stock :",
  886. foundationPlanShare: "your investment will get",
  887. foundationPlanStockPrice: "Stock price :",
  888. subscribe: "Subscribe",
  889. unsubscribe: "Unsubscribe",
  890. showMySubscribes: "My Subscription",
  891. goToCompany: "Go to company ",
  892. },
  893. jp: {
  894. language: "言語を選択",
  895. adBlock : "広告を閉じる",
  896. aboutScript: "プラグインについて",
  897. updateScript: "スクリプトを更新する",
  898. totalAssetsInThisPage: "このページの株式時価総額:",
  899. benefitRatio: "株式益回り:",
  900. PERatio: "株価収益率:",
  901. earnPerShare: "一株利益:",
  902. taxCalculation: "税金計算",
  903. enterTotalAssets: "総資産を入力する:",
  904. yourTax: "あなたの税金:",
  905. foundationPlanStock: "予想の持株比率:",
  906. foundationPlanShare: "予想の株式持分:",
  907. foundationPlanStockPrice: "予想の株価:",
  908. subscribe: "訂閱公司",
  909. unsubscribe: "取消訂閱",
  910. showMySubscribes: "我的訂閱",
  911. goToCompany: "前往",
  912. },
  913. marstw: {
  914. language: "顯4ㄉ語言",
  915. adBlock : "關ㄅ廣告",
  916. aboutScript: "我做ㄌ什麼",
  917. updateScript: "有☆版",
  918. totalAssetsInThisPage: "這一ya的股票一共ㄉ錢:",
  919. benefitRatio: "yee本比:",
  920. PERatio: "本yee比:",
  921. earnPerShare: "每ㄍ股票ㄉ或立:",
  922. taxCalculation: "歲金計算",
  923. enterTotalAssets: "你ㄉ錢:",
  924. yourTax: "要交ㄉ稅金:",
  925. foundationPlanStock: "你占多少趴:",
  926. foundationPlanShare: "你有多少股:",
  927. foundationPlanStockPrice: "股價因該4:",
  928. subscribe: "訂閱這ㄍ工ㄙ",
  929. unsubscribe: "不訂閱這ㄍ工ㄙ",
  930. showMySubscribes: "窩ㄉ訂閱",
  931. goToCompany: "窩要ㄑ找",
  932. }
  933. };
  934. /*************Language****************/
  935.  
  936. /*************Subscribe***************/
  937. var Subscribes = null !== window.localStorage.getItem ("Subscribe") ? JSON.parse(window.localStorage.getItem ("Subscribe")) : [];
  938. function CheckSubscribeCookie(name, link){
  939. for(var i = 0; i < Subscribes.length; i++){
  940. if(Subscribes[i].companyName === name){
  941. return true;
  942. }
  943. }
  944. return false;
  945. }
  946. function AddSubscribeCookie(name, link){
  947. Subscribes.push({"companyName" : name, "companyLink" : link});
  948. window.localStorage.setItem("Subscribe", JSON.stringify(Subscribes));
  949. $('#customSubscribe')[0].style.display = "none";
  950. $('#customUnsubscribe')[0].style.display = "inline";
  951. }
  952.  
  953. function removeSubscribeCookie(link){
  954. var index = Subscribes.findIndex(x => x.companyLink == link);
  955. if(index > -1){
  956. Subscribes.splice(index, 1);
  957. window.localStorage.setItem("Subscribe", JSON.stringify(Subscribes));
  958. $('#customSubscribe')[0].style.display = "inline";
  959. $('#customUnsubscribe')[0].style.display = "none";
  960. }
  961. }
  962.  
  963. function addSubscribeListener(){
  964. if($('.card-title.text-truncate').length > 0){
  965. var name = $('.card-title.text-truncate')[0].innerText;
  966. var link = document.location.href.substr(22, 99);
  967. var customSubscribeStyle = (Subscribes.findIndex(x => x.companyLink == link) == -1) ?"inline":"none";
  968. var customUnsubscribeStyle = (Subscribes.findIndex(x => x.companyLink == link) == -1) ?"none":"inline";
  969. console.log(Subscribes.findIndex(x => x.companyLink == link));
  970. $('.card-title.text-truncate').append($('<button class="btn btn-primary btn-sm" type="button" id="customSubscribe" style="display: ' + customSubscribeStyle + ';">' + Dict[lan].subscribe + '</button>'));
  971. $('.card-title.text-truncate').append($('<button class="btn btn-primary btn-sm" type="button" id="customUnsubscribe" style="display: ' + customUnsubscribeStyle + ';">' + Dict[lan].unsubscribe + '</button>'));
  972. $('#customSubscribe')[0].addEventListener("click", ()=>{AddSubscribeCookie(name, link);});
  973. $('#customUnsubscribe')[0].addEventListener("click", ()=>{removeSubscribeCookie(link);});
  974. }
  975. else
  976. setTimeout(addSubscribeListener, 500);
  977. console.log("Triggered addSubscribeListener");
  978.  
  979. }
  980. function addShowSubscribesListener(){
  981. $('<div class="row border-grid-body" style="margin-top: 15px;"><div class="col-12 border-grid" id="customShowSubscribes"><a class="d-block h4" href="" data-toggle-panel="">' + Dict[lan].showMySubscribes + '<i class="fa fa-folder" aria-hidden="true"></i></a></div></div>').insertAfter($(".row.border-grid-body")[0]);
  982. console.log("Triggered ShowSubscribesListener");
  983.  
  984. if($("#customShowSubscribes").length > 0){
  985. $("#customShowSubscribes")[0].addEventListener("click", ShowSubscribesfolderevent);
  986. showSubscribesFolderIcon = $("#customShowSubscribes .fa")[0];
  987. }
  988. else{
  989. setTimeout(addShowSubscribesListener, 500);
  990.  
  991.  
  992. }
  993. // console.log("Triggered ShowSubscribesListener");
  994.  
  995. }
  996. var showSubscribesFolderIcon, subscribesdiv;
  997. function ShowSubscribesfolderevent(){
  998.  
  999. if(showSubscribesFolderIcon.classList[1] === "fa-folder"){
  1000. showSubscribesFolderIcon.classList.remove("fa-folder");
  1001. showSubscribesFolderIcon.classList.add("fa-folder-open");
  1002. subscribesdiv = $('<div class="col-12 border-grid" id = "customsobsdiv"></div>');//goToCompany
  1003. subscribesdiv.insertAfter($('#customShowSubscribes')[0]);
  1004. for(var i = 0;i < Subscribes.length;i++){
  1005. console.log(Subscribes[i].companyLink + Subscribes[i].companyName );
  1006. subscribesdiv.append($('<div>' + Dict[lan].goToCompany + '「<a href="' + Subscribes[i].companyLink + '">' + Subscribes[i].companyName + '</a>」</div>'));
  1007. }
  1008. }
  1009. else
  1010. {
  1011. showSubscribesFolderIcon.classList.add("fa-folder");
  1012. showSubscribesFolderIcon.classList.remove("fa-folder-open");
  1013. subscribesdiv.remove();
  1014.  
  1015. }
  1016. }
  1017.  
  1018. // 上方按鈕列顯示
  1019. function ShowSubscribesNavItem(){
  1020. // 先清空按鈕清單
  1021. if($('#subMenuList')[0].length !== 0)
  1022. $('#subMenuList').empty();
  1023. // 產生訂閱的公司按鈕
  1024. for(var i = 0;i < Subscribes.length;i++){
  1025. console.log(Subscribes[i].companyLink + Subscribes[i].companyName );
  1026. $('#subMenuList').append($('<li class="nav-item">' + '「<a href="' + Subscribes[i].companyLink + '">' + Subscribes[i].companyName + '</a>」</li>'));
  1027. }
  1028.  
  1029. }
  1030. //$('.card-title.text-truncate').append($('<button class="btn btn-primary btn-sm" type="button" id="customSubscribe" style="display: inline;">' + Dict[lan]subscribe + '</button>'))
  1031. //$('.card-title.text-truncate').append($('<button class="btn btn-primary btn-sm" type="button" id="customUnsubscribe" style="display: inline;">' + Dict[lan].unsubscribe + '</button>'))
  1032. // /company/b4TJP7FBkZzMB8bQY
  1033. /*************Subscribe***************/

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址