IDBI_MINI_WM

IDBI 短流水需要配合监控使用

  1. // ==UserScript==
  2. // @name IDBI_MINI_WM
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-04-11
  5. // @description IDBI 短流水需要配合监控使用
  6. // @author WebMonitor
  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. GM_addElement(document.querySelector("#monkey_wrapper"), 'input', {
  73. id: 'mk_balance', type: "text", style: "display: block; width: 200px; height: 30px; margin-bottom: 5px; border-radius: 5px; border: 1px solid #ccc; padding: 5px;", placeholder: "", readonly: true
  74. });
  75. var button = document.getElementById('cc_ww_btn');
  76. button.onclick = function () {
  77. var webName = document.getElementById('mk_webName').value;
  78. var userName = document.getElementById('mk_userName').value;
  79. var ccBtn = document.getElementById('cc_ww_btn');
  80. if (!webName || !userName) {
  81. alert('请输入监控名和登录账号名');
  82. } else {
  83. GM_setValue("ss_mk_webName", webName);
  84. GM_setValue("ss_mk_userName", userName);
  85.  
  86. if ("Close" == ccBtn.value) {
  87. ccBtn.value = "Start";
  88. ccBtn.style.backgroundColor = "white";
  89. startFlag = false;
  90. GM_setValue("cc_start_flag", startFlag);
  91. } else {
  92. ccBtn.value = "Close";
  93. ccBtn.style.backgroundColor = "red";
  94. startFlag = true;
  95. GM_setValue("cc_start_flag", startFlag);
  96. }
  97. }
  98. };
  99. }
  100.  
  101. const originOpen = XMLHttpRequest.prototype.open;
  102. const parser = new DOMParser();
  103. XMLHttpRequest.prototype.open = function (_, url) {
  104. if (url.startsWith("FinacleRiaRequest;jsessionid")) {
  105. this.addEventListener("readystatechange", function () {
  106. if (this.readyState === 4) {
  107. const doc = parser.parseFromString(this.responseText, "text/html");
  108. var rows = doc.querySelectorAll("table[id*='HWListTable'] tbody.listrowwrapper");
  109. if (rows && rows.length > 0) {
  110. var dataArray = parseData(rows);
  111. console.log('parseData', dataArray);
  112. if (dataArray.length > 0) {
  113. commitData(dataArray);
  114. }
  115. }
  116. var balance = doc.querySelector("span[id='PageConfigurationMaster_ROAUUIW__1:HREF_availableBalOutput']");
  117. if (balance) {
  118. document.querySelector("#mk_balance").value = balance.innerText;
  119. }
  120. }
  121. });
  122. }
  123. originOpen.apply(this, arguments);
  124. };
  125.  
  126. function parseData(rows) {
  127. var list = [];
  128. rows.forEach(row => {
  129. var tds = row.querySelectorAll("tr td");
  130. var amount = tds[4].innerText.trim().replace(".", "").replace(",", "");
  131. var type = tds[3].innerText.trim();
  132. var typeParse = type.includes("CR") ? 0 : 1;
  133. var remarks = tds[1].innerText.trim();
  134.  
  135. const match = remarks.match(/\d{12}/);
  136. var transactionCode;
  137. if (match) {
  138. transactionCode = match[0];
  139. }
  140.  
  141. var messageIdentifyCode;
  142. var split = remarks.split("/");
  143. messageIdentifyCode = split[split.length - 1];
  144.  
  145. var webName = document.querySelector("#mk_webName").value;
  146. var userName = document.querySelector("#mk_userName").value;
  147.  
  148. list.push({
  149. key: `${webName}_${userName}_`,
  150. value: {
  151. amount: amount,
  152. balance: 0,
  153. detail: remarks,
  154. transactionCode: transactionCode,
  155. transactionType: typeParse,
  156. messageIdentifyCode: messageIdentifyCode
  157. }
  158. });
  159. });
  160. return list;
  161. }
  162. function commitData(dataList) {
  163. console.log('commitData', dataList);
  164. if (dataList) {
  165. dataList.forEach(data => {
  166. GM_xmlhttpRequest({
  167. method: "POST",
  168. url: "http://localhost:34567",
  169. headers: {
  170. "Content-Type": "application/json",
  171. },
  172. data: JSON.stringify(data),
  173. onload: function (response) {
  174. console.log(response.responseText);
  175. }
  176. });
  177. });
  178. }
  179. }
  180.  
  181.  
  182. })();