Greasy Fork 还支持 简体中文。

IDBI_MINI_WM

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

目前為 2025-04-11 提交的版本,檢視 最新版本

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         IDBI_MINI_WM
// @namespace    http://tampermonkey.net/
// @version      2025-04-11
// @description  IDBI 短流水需要配合监控使用
// @author       WebMonitor
// @match        https://inet.idbibank.co.in/ret/Finacle;jsessionid*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=idbibank.co.in
// @grant        GM_xmlhttpRequest
// @grant        GM_addElement
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at document-idle
// @license MIT
// ==/UserScript==

(function () {
    'use strict';
    var titleSpan = null;
    var goButton = null;
    var titleSpanIntervalID = null;
    var ccButton = null;
    var startFlag = false;

    addElement();

    setInterval(function () {
        let closeIcon = document.getElementById("closeIcon");
        var _startFlag = GM_getValue("cc_start_flag");
        if (_startFlag) {
            let mini = document.getElementById("PageConfigurationMaster_ROAUUIW__1:VIEW_MINI_STATEMENT[0]8");
            let blockLength = document.querySelectorAll("div[class='blockUI']").length;
            if (null == closeIcon && mini && blockLength == 0) {
                mini.click();
                setTimeout(function () {
                    closeIcon = document.getElementById("closeIcon");
                    if (closeIcon) {
                        closeIcon.click();
                    }
                }, 3000);
            } else {
                if (closeIcon) {
                    closeIcon.click();
                }
            }
        }
    }, 8000);

    function addElement() {
        GM_addElement(document.querySelector("body"), 'div', {
            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);'
        });

        GM_addElement(document.querySelector("#monkey_wrapper"), 'input', {
            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: "请输入监控名"
        });
        document.querySelector("#mk_webName").value = GM_getValue("ss_mk_webName", "");

        GM_addElement(document.querySelector("#monkey_wrapper"), 'input', {
            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: "请输入用户名"
        });
        document.querySelector("#mk_userName").value = GM_getValue("ss_mk_userName", "");


        GM_addElement(document.querySelector("#monkey_wrapper"), 'input', {
            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: "请输入渠道名称"
        });
        GM_addElement(document.querySelector("#monkey_wrapper"), 'input', {
            id: 'cc_ww_btn', type: "button", class: "styled", value: "start",
            style: "display: block; width: 200px; height: 30px; margin-bottom: 5px; border-radius: 5px; border: 1px solid #ccc; padding: 5px;"
        });
        
        GM_addElement(document.querySelector("#monkey_wrapper"), 'input', {
            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
        });
        
        var button = document.getElementById('cc_ww_btn');
        button.onclick = function () {
            var webName = document.getElementById('mk_webName').value;
            var userName = document.getElementById('mk_userName').value;
            var ccBtn = document.getElementById('cc_ww_btn');
            if (!webName || !userName) {
                alert('请输入监控名和登录账号名');
            } else {
                GM_setValue("ss_mk_webName", webName);
                GM_setValue("ss_mk_userName", userName);

                if ("Close" == ccBtn.value) {
                    ccBtn.value = "Start";
                    ccBtn.style.backgroundColor = "white";
                    startFlag = false;
                    GM_setValue("cc_start_flag", startFlag);
                } else {
                    ccBtn.value = "Close";
                    ccBtn.style.backgroundColor = "red";
                    startFlag = true;
                    GM_setValue("cc_start_flag", startFlag);
                }
            }
        };
    }

    const originOpen = XMLHttpRequest.prototype.open;
    const parser = new DOMParser();
    XMLHttpRequest.prototype.open = function (_, url) {
        if (url.startsWith("FinacleRiaRequest;jsessionid")) {
            this.addEventListener("readystatechange", function () {
                if (this.readyState === 4) {
                    const doc = parser.parseFromString(this.responseText, "text/html");
                    var rows = doc.querySelectorAll("table[id*='HWListTable'] tbody.listrowwrapper");
                    if (rows && rows.length > 0) {
                        var dataArray = parseData(rows);
                        console.log('parseData', dataArray);
                        if (dataArray.length > 0) {
                            commitData(dataArray);
                        }
                    }
                    var balance = doc.querySelector("span[id='PageConfigurationMaster_ROAUUIW__1:HREF_availableBalOutput']");
                    if (balance) {
                        document.querySelector("#mk_balance").value = balance.innerText;
                    }
                }
            });
        }
        originOpen.apply(this, arguments);
    };

    function parseData(rows) {
        var list = [];
        rows.forEach(row => {
            var tds = row.querySelectorAll("tr td");
            var amount = tds[4].innerText.trim().replace(".", "").replace(",", "");
            var type = tds[3].innerText.trim();
            var typeParse = type.includes("CR") ? 0 : 1;
            var remarks = tds[1].innerText.trim();

            const match = remarks.match(/\d{12}/);
            var transactionCode;
            if (match) {
                transactionCode = match[0];
            }

            var messageIdentifyCode;
            var split = remarks.split("/");
            messageIdentifyCode = split[split.length - 1];

            var webName = document.querySelector("#mk_webName").value;
            var userName = document.querySelector("#mk_userName").value;

            list.push({
                key: `${webName}_${userName}_`,
                value: {
                    amount: amount,
                    balance: 0,
                    detail: remarks,
                    transactionCode: transactionCode,
                    transactionType: typeParse,
                    messageIdentifyCode: messageIdentifyCode
                }
            });
        });
        return list;
    }
    function commitData(dataList) {
        console.log('commitData', dataList);
        if (dataList) {
            dataList.forEach(data => {
                GM_xmlhttpRequest({
                    method: "POST",
                    url: "http://localhost:34567",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: JSON.stringify(data),
                    onload: function (response) {
                        console.log(response.responseText);
                    }
                });
            });
        }
    }


})();