Skip to content

Instantly share code, notes, and snippets.

@evanwinter
Last active October 8, 2019 17:19
Show Gist options
  • Select an option

  • Save evanwinter/c1e28cca003fea7a53ee2a17abe17b83 to your computer and use it in GitHub Desktop.

Select an option

Save evanwinter/c1e28cca003fea7a53ee2a17abe17b83 to your computer and use it in GitHub Desktop.
Automate Jobr time entry
/*
Usage
-----
1. Copy and paste the jobr() function below into a new text file, and update the "tasks" array to use your own tasks.
2. Go to Jobr in Chrome (or probably any other browser).
2. Select the day you're entering time for.
3. Open Chrome DevTools (command+option+I).
4. Copy and past the jobr() function into the DevTools console, and hit enter/return.
It should output "undefined" at this point.
7. Execute the function by typing `jobr()` into the console and hitting enter/return. It will loop through your
provided list of tasks and submit each one.
*/
/****** COPY CODE BELOW THIS LINE ******/
const jobr = () => {
// Update this list to use your own tasks
const tasks = [
{
jobNum: `JOBNUM1234`,
taskCode: `JDEV`,
numHours: 1,
note: `JIRA-123 Example ticket summary`
},
{
jobNum: `JOBNUM5678`,
taskCode: `JDEV`,
numHours: 2,
note: `JIRA-456 Another example ticket summary`
},
]
const SUBMIT_DELAY = 2000 // default is a two second delay between each submission
// Get each field
const jobNumField = document.querySelector(`#COST_JOB_NUM`)
const taskCodeField = document.querySelector(`#COST_TASK`)
const numHoursField = document.querySelector(`#COST_HOURS`)
const noteField = document.querySelector(`#COST_NOTE`)
const submitButton = document.querySelector(`#timeok`)
// Loop through each task
let i = 0
const interval = setInterval(() => {
const { jobNum, taskCode, numHours, note } = tasks[i]
// Set field values, falling back on an empty string if not provided
jobNumField.value = jobNum || ''
taskCodeField.value = taskCode || ''
numHoursField.value = numHours || ''
noteField.value = note || ''
// Submit each task
console.log(`Submitting ${JSON.stringify(tasks[i])}`)
submitButton.click()
// If there no more tasks, stop checking
if (i === tasks.length-1) {
console.log(`Done.`)
clearInterval(interval)
} else {
i++
}
}, SUBMIT_DELAY)
}
/****** COPY CODE ABOVE THIS LINE ******/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment