Skip to content

Instantly share code, notes, and snippets.

@adminy
Created March 10, 2022 20:01
Show Gist options
  • Save adminy/edebc14bd5b12396da2cae44506564b1 to your computer and use it in GitHub Desktop.
Save adminy/edebc14bd5b12396da2cae44506564b1 to your computer and use it in GitHub Desktop.
nct.ie Dates ... sorted by fastest
// call it until you get error
document.getElementById('showMoreStations').click()
const select = document.getElementById('nctCentresDropdown')
const options = []; for (const child of select.children) { options.push(child) }
const selectedIndex = options.findIndex(option => option.selected)
const magic = localStorage['magic'] ? JSON.parse(localStorage['magic']) : []
magic.push([options[selectedIndex].innerText, document.getElementsByClassName('owl-item active')[0].innerText.replace('\n', ' ')])
localStorage['magic'] = JSON.stringify(magic)
select.value = options[selectedIndex + 1].value
document.getElementsByTagName('form')[0].submit()
// execute once at the end
for (const [location, time] of JSON.parse(localStorage.magic).sort((a, b) => new Date(a[1].replace(/^.*day\s(\d+)[a-z]+\s(.*?)$/, '$1 $2 2022')) - new Date(b[1].replace(/^.*day\s(\d+)[a-z]+\s(.*?)$/, '$1 $2 2022'))) ) { console.log(location, time) }
localStorage.clear()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment