Dealer Userscript

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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');
	} 
});

})();