Skip to content

Instantly share code, notes, and snippets.

@vinaygopinath
Created September 24, 2014 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinaygopinath/c02e7aef195a80f014ec to your computer and use it in GitHub Desktop.
Save vinaygopinath/c02e7aef195a80f014ec to your computer and use it in GitHub Desktop.
This script automatically selects various fields in the "Delay in Payment" section of the Mahatma Gandhi National Rural Employment Guarantee Act ( MGNREGA) website
/**
* This script does the following on the "Delay in Payment" section of NREGA
* "Approved" = No
* "Disapproval reason" = "Funds not available at the paying authority level"
* "Select" = check
*
* Usage: When the website (http://164.100.129.3/netnrega/payorder_delayPayment.aspx) is open, press
* Ctrl + Shift + K in Firefox and Ctrl + Shift + J in Chrome, select Console (if it isn't already selected)
* and paste the code into the console. Some values may need modification depending on your internet connection
*
* The fields will be updated after 20 seconds. In case it fails (because of server response delays),
* consider changing the timeout value in the script.
*
* Running this multiple times is perfectly safe.
*
* Date: 24 September 2014
* Author: Vinay Gopinath (on behalf of Payir Trust, Thenur. Website: payir.org)
*
* P.S: Note to NREGA IT folks - Please make an option to mark everyone in a village as not having received payment!
**/
/*
* The MGNREGA page for "Delay in Payment" shows 50 items per page, the IDs
* of rows ranging from 2 to 51
*/
var i;
for (i = 2; i < 52; i++) {
// The website uses 02, 03, so a "0" is prefixed to any number less than 10
var paddedNum = (i < 10) ? "0" + i : i;
// Invokes the function to show options for "Disapproval reason"
setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$grvPay$ctl' + paddedNum + '$rbnApp$1\',\'\')', 0);
// Clicks "No" under "Approved?" - rbnApp_1 represents "No" and "rbnApp_0" represents "Yes"
document.getElementById("ctl00_ContentPlaceHolder1_grvPay_ctl" + paddedNum + "_rbnApp_1").checked = true;
// Clicks the "Select" option
document.getElementById("ctl00_ContentPlaceHolder1_grvPay_ctl" + paddedNum + "_chk").checked = true;
}
/* Waits 20000 milliseconds (20 seconds) before attempting to select the first option in the
* "Disapproval reason" dropdown - "Funds not available at the paying authority level"
* Other options can be selected by changing the .value = 1 to higher values
*/
setTimeout(function () {
for (i = 2; i < 52; i++) {
var paddedNum = (i < 10) ? "0" + i : i;
document.getElementsByName("ctl00$ContentPlaceHolder1$grvPay$ctl" + paddedNum + "$drpReason")[0].value = 1;
}
}, 20000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment