Skip to content

Instantly share code, notes, and snippets.

@Icohen007
Last active April 10, 2022 10:36
Show Gist options
  • Save Icohen007/4ee95522baa897377bca9aa024eaa01c to your computer and use it in GitHub Desktop.
Save Icohen007/4ee95522baa897377bca9aa024eaa01c to your computer and use it in GitHub Desktop.
hilanet auto fill
function triggerTouch(element, eventType) {
const event = document.createEvent('Event');
event.initEvent(eventType, false, true);
element[eventType]();
element.dispatchEvent(event);
}
function selectMissingDays() {
const missingDaysSelector = '.imageContainerStyle img';
const missingDaysButton = "input[type='submit'][id*='RefreshSelectedDays']";
document.querySelectorAll(missingDaysSelector).forEach((el) => el.click());
document.querySelector(missingDaysButton).click();
}
function fillWorkTime({ startTime, endTime }) {
const selector = 'tbody > tr[id*=\'EmployeeReports\']';
const scheduleArray = Array.from(document.querySelectorAll(selector));
scheduleArray.forEach((row) => {
row.children[0].firstElementChild.value = startTime;
row.children[1].firstElementChild.value = endTime;
triggerTouch(row.children[1].firstElementChild, 'focus');
triggerTouch(row.children[1].firstElementChild, 'blur');
row.children[4].firstElementChild.options[4].selected = true;
});
}
function sleep(delayMs) {
return new Promise((resolve) => setTimeout(resolve, delayMs));
}
async function fillDays() {
selectMissingDays();
await sleep(1500);
fillWorkTime({ startTime: '09:00', endTime: '18:30' });
}
fillDays();
@nadavvitri
Copy link

love it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment