0% found this document useful (0 votes)
120 views2 pages

Stockyard Select

This userscript selects a district, stockyard, and purpose for an online booking form: 1. It waits for the district dropdown to appear and selects a specific district ID. 2. It then waits for the stockyard table to load and clicks the radio button of the stockyard with a matching name. 3. Finally, it selects a purpose value from another dropdown and clicks a radio button before completing.

Uploaded by

venkiscribd444
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views2 pages

Stockyard Select

This userscript selects a district, stockyard, and purpose for an online booking form: 1. It waits for the district dropdown to appear and selects a specific district ID. 2. It then waits for the stockyard table to load and clicks the radio button of the stockyard with a matching name. 3. Finally, it selects a purpose value from another dropdown and clicks a radio button before completing.

Uploaded by

venkiscribd444
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// ==UserScript==

// @name stock point


// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://onlinebooking.sand.telangana.gov.in/Order/NEWBOOKING.aspx?
KLM=*
// @grant none
// ==/UserScript==

(function() {
'use strict';
var DISTRICT_ID = 27;
var RADIO_BUTTON_TEXT = "";
var changeEvent = new Event('change');
var clickEvent = new Event('click');
function waitForTheElement(searchElement, callback) {
var element;
var intervalId = setInterval(function () {
element = searchElement();
if(element) {
clearInterval(intervalId);
callback(element);
}
},10);
}
function selectDistrict1(nextStep) {
waitForTheElement(function() {
return
document.querySelector("#ccMain_tblDistricts").querySelector("select");
}, function(elem) {
elem.value = DISTRICT_ID;
elem.dispatchEvent(changeEvent);
nextStep();
});
}

function selectStockYard(nextStep){
waitForTheElement(function(){
var elem = null;
var trElements =
Array.from(document.querySelectorAll(".GridviewScrollTable")
[0].querySelectorAll("tr"));
if(!trElements) {return null};
trElements.some(function (tr, index) {
if (index == 0) { return 0;}
if (tr.querySelectorAll("td")[2].innerHTML.trim().toLowerCase() ==
RADIO_BUTTON_TEXT.trim().toLowerCase()) {
elem = tr.querySelector("input");
return true;
}
}
);
return elem;
},function(elem){
elem.click();
nextStep();
});
}

function selectPurpose(nextStep){
waitForTheElement(function(){
return
document.querySelector("select[name='ctl00$ccMain$ddlsandpurpose']");
},function(elem){
elem.value = "2";

//document.querySelector('select[name="ctl00$ccMain$ddlVehicleType"]').value = "L";
document.querySelector('input[name="ctl00$ccMain$txtVehzNo"]')
document.querySelector("#ccMain_rbtPG_0").click();
nextStep();
});
}
selectDistrict1(function(){
selectStockYard(selectPurpose);
});
})()

You might also like