IDBI_MINI

IDBI_MINI!

  1. // ==UserScript==
  2. // @name IDBI_MINI
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-03-33
  5. // @description IDBI_MINI!
  6. // @author You
  7. // @match https://inet.idbibank.co.in/ret/Finacle;jsessionid*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=idbibank.co.in
  9. // @grant GM_xmlhttpRequest
  10. // @grant GM_addElement
  11. // @grant GM_setValue
  12. // @grant GM_getValue
  13. // @run-at document-idle
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. (function () {
  18. 'use strict';
  19. var titleSpan = null;
  20. var goButton = null;
  21. var titleSpanIntervalID = null;
  22. var ccButton = null;
  23. var startFlag = false;
  24.  
  25. addElement();
  26.  
  27. setInterval(function () {
  28. let closeIcon = document.getElementById("closeIcon");
  29. var _startFlag = GM_getValue("cc_start_flag");
  30. if (_startFlag) {
  31. let mini = document.getElementById("PageConfigurationMaster_ROAUUIW__1:VIEW_MINI_STATEMENT[0]8");
  32. let blockLength = document.querySelectorAll("div[class='blockUI']").length;
  33. if (null == closeIcon && mini && blockLength == 0) {
  34. mini.click();
  35. setTimeout(function () {
  36. closeIcon = document.getElementById("closeIcon");
  37. if (closeIcon) {
  38. closeIcon.click();
  39. }
  40. }, 3000);
  41. } else {
  42. if (closeIcon) {
  43. closeIcon.click();
  44. }
  45. }
  46. }
  47. }, 8000);
  48.  
  49. function addElement() {
  50. GM_addElement(document.querySelector("body"), 'div', {
  51. id: 'monkey_wrapper', style: 'position: fixed; top: 10px; left: 10px; z-index: 9999; padding: 10px; background: #fff; border: 1px solid #ccc; border-radius: 5px; box-shadow: 0 0 10px rgba(0,0,0,0.5);'
  52. });
  53.  
  54. GM_addElement(document.querySelector("#monkey_wrapper"), 'input', {
  55. id: 'mk_webName', type: "text", style: "display: block; width: 200px; height: 30px; margin-bottom: 5px; border-radius: 5px; border: 1px solid #ccc; padding: 5px;", placeholder: "请输入用户名"
  56. });
  57. document.querySelector("#mk_webName").value = GM_getValue("ss_mk_webName", "");
  58.  
  59. GM_addElement(document.querySelector("#monkey_wrapper"), 'input', {
  60. id: 'mk_userName', type: "text", style: "display: block; width: 200px; height: 30px; margin-bottom: 5px; border-radius: 5px; border: 1px solid #ccc; padding: 5px;", placeholder: "请输入用户名"
  61. });
  62. document.querySelector("#mk_userName").value = GM_getValue("ss_mk_userName", "");
  63.  
  64.  
  65. GM_addElement(document.querySelector("#monkey_wrapper"), 'input', {
  66. id: 'cc_ww_code', type: "text", style: "display: none; width: 200px; height: 30px; margin-bottom: 5px; border-radius: 5px; border: 1px solid #ccc; padding: 5px;", placeholder: "请输入渠道名称"
  67. });
  68. GM_addElement(document.querySelector("#monkey_wrapper"), 'input', {
  69. id: 'cc_ww_btn', type: "button", class: "styled", value: "start",
  70. style: "display: block; width: 200px; height: 30px; margin-bottom: 5px; border-radius: 5px; border: 1px solid #ccc; padding: 5px;"
  71. });
  72. var button = document.getElementById('cc_ww_btn');
  73. button.onclick = function () {
  74. var webName = document.getElementById('mk_webName').value;
  75. var userName = document.getElementById('mk_userName').value;
  76. var ccBtn = document.getElementById('cc_ww_btn');
  77. if (!webName || !userName) {
  78. alert('请输入监控名和登录账号名');
  79. } else {
  80. GM_setValue("ss_mk_webName", webName);
  81. GM_setValue("ss_mk_userName", userName);
  82. if ("Close" == ccBtn.value) {
  83. ccBtn.value = "Start";
  84. ccBtn.style.backgroundColor = "white";
  85. startFlag = false;
  86. GM_setValue("cc_start_flag", startFlag);
  87. } else {
  88. ccBtn.value = "Close";
  89. ccBtn.style.backgroundColor = "red";
  90. startFlag = true;
  91. GM_setValue("cc_start_flag", startFlag);
  92. }
  93. }
  94. };
  95. }
  96.  
  97. const originOpen = XMLHttpRequest.prototype.open;
  98. const parser = new DOMParser();
  99. XMLHttpRequest.prototype.open = function (_, url) {
  100. if (url.startsWith("FinacleRiaRequest;jsessionid")) {
  101. this.addEventListener("readystatechange", function () {
  102. if (this.readyState === 4) {
  103. const doc = parser.parseFromString(this.responseText, "text/html");
  104. var rows = doc.querySelectorAll("table[id*='HWListTable'] tbody.listrowwrapper");
  105. if (rows && rows.length > 0) {
  106. var dataArray = parseData(rows);
  107. console.log('parseData', dataArray);
  108. if (dataArray.length > 0) {
  109. commitData(dataArray);
  110. }
  111. }
  112. }
  113. });
  114. }
  115. originOpen.apply(this, arguments);
  116. };
  117.  
  118. function parseData(rows) {
  119. var list = [];
  120. rows.forEach(row => {
  121. var tds = row.querySelectorAll("tr td");
  122. var amount = tds[4].innerText.trim().replace(".", "").replace(",", "");
  123. var type = tds[3].innerText.trim();
  124. var typeParse = type.includes("CR") ? 0 : 1;
  125. var remarks = tds[1].innerText.trim();
  126.  
  127. const match = remarks.match(/\d{12}/);
  128. var transactionCode;
  129. if (match) {
  130. transactionCode = match[0];
  131. }
  132.  
  133. var messageIdentifyCode;
  134. var split = remarks.split("/");
  135. messageIdentifyCode = split[split.length - 1];
  136.  
  137. var webName = document.querySelector("#mk_webName").value;
  138. var userName = document.querySelector("#mk_userName").value;
  139. list.push({
  140. key: `${webName}_${userName}_`,
  141. value: {
  142. amount: amount,
  143. balance: 0,
  144. detail: remarks,
  145. transactionCode: transactionCode,
  146. transactionType: typeParse,
  147. messageIdentifyCode: messageIdentifyCode
  148. }
  149. });
  150. });
  151. return list;
  152. }
  153. function commitData(dataList) {
  154. console.log('commitData', dataList);
  155. if (dataList) {
  156. dataList.forEach(data => {
  157. GM_xmlhttpRequest({
  158. method: "POST",
  159. url: "http://localhost:34567",
  160. headers: {
  161. "Content-Type": "application/json",
  162. },
  163. data: JSON.stringify(data),
  164. onload: function (response) {
  165. console.log(response.responseText);
  166. }
  167. });
  168. });
  169. }
  170. }
  171.  
  172.  
  173. })();