Skip to content

Instantly share code, notes, and snippets.

@mbruno-kr
Last active June 20, 2022 15:25
Show Gist options
  • Save mbruno-kr/fabb92c76b2d93b6fdf21bb648183096 to your computer and use it in GitHub Desktop.
Save mbruno-kr/fabb92c76b2d93b6fdf21bb648183096 to your computer and use it in GitHub Desktop.
Auto fill timesheets

Auto Fill ur Oneview timesheets :)

Install

  1. Download a plugin called code injector.

    1. Chrome Extension
  2. Add the host oneview\.kroger\.com

  3. Enable on page load

  4. paste the script above in it

  5. Click autofill and submit :)

Sometimes the page doesnt load the auto fill button when you populate your timesheet, just give the page a quick refresh and it will reappear.

// Type your JavaScript code here.
const tasks = [
{
name: "Item A",
time: 1
}, {
name: "Item B",
time: 6.5
}, {
name: "Item C",
time: .5
}
]
function getDays() {
let days = []
document.querySelectorAll('[data-columnid="day"]').forEach(e => {
let content = e.innerText;
if (content.length > 0) {
days.push(content.replace(/\n/g, " ").trim().replace(" ", ", "))
}
})
return days;
}
function autoFill() {
let days = getDays();
let weekDays = days.slice(1,6);
weekDays.forEach(dayOfWeek => {
tasks.forEach(task => {
let day = document.querySelector(`input[alt*='${dayOfWeek}'][alt*='${task.name}']`)
if (!day.value) {
day.value = task.time
}
})
})
}
function main() {
let container = document.querySelector('div[class*="ppm_button_bar"]');
if (!container) {
setTimeout(main, 200)
return;
}
if (!container.querySelector('button[id="auto-fill"]')) {
let button = document.createElement("button");
button.id = "auto-fill"
button.innerText = "Auto Fill"
button.style = "padding: .5em; background-color: gray; color: white; margin: 1em;"
button.onclick = autoFill;
container.appendChild(button)
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment