Dealer Userscript

This makes HRMS more user friendly and easy to use for dealers

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Dealer Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  This makes HRMS more user friendly and easy to use for dealers
// @author       You
// @match        https://hrms.indianrail.gov.in/HRMS/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gov.in
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    $(document).ready(function() {
    var currentUrl = window.location.href;
 
    if (currentUrl === "https://hrms.indianrail.gov.in/HRMS/assign-bill-unit") {
        console.log('On Assign Bill Unit page');

        var ids = prompt('Enter HRMS ids with comma').replace(/\s+/g, '').split(",");
        for (i = 0; i < ids.length; i++) {
            $("#addRowButton").click(); console.log(ids[i]); $("#ipasEmployeeId" + i).val(ids[i]).change();
        }
    }

    else if (currentUrl === "https://hrms.indianrail.gov.in/HRMS/cadre-management/seniority-list-updation-status#") {

        $("#cadre-heirarchy-reset").after('<button type="button" onclick="serializeSeniority()" class="btn btn-primary-grad" id="serialize-seniority">Serialize</button>');
    }



    else {
        console.log('Not on expected pages. Current URL:', currentUrl);
    }

	window.serializeSeniority = function () {
		$("input.seniorityPosition").each(function(i) {
			$(this).val(i+1);
		});
	}

    window.delay = function (ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

	window.exit = function () {
		throw new Error('This is not an error. This is just to abort javascript');
	} 
});

})();