Skip to content

Instantly share code, notes, and snippets.

@headquarters
Last active October 19, 2020 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headquarters/295902e7f443cdef8dc42a3cc49d9891 to your computer and use it in GitHub Desktop.
Save headquarters/295902e7f443cdef8dc42a3cc49d9891 to your computer and use it in GitHub Desktop.
Bookmarklet to sort the ATO 6Connex briefcase list
javascript:(function()%7Bvar%20button%20%3D%20document.createElement('button')%3B%0Abutton.type%20%3D%20'button'%3B%0Abutton.innerText%20%3D%20'Sort'%3B%0Abutton.style%20%3D%20'position%3Aabsolute%3Bright%3A45px%3Btop%3A5px%3Bpadding%3A5px'%3B%0Abutton.addEventListener('click'%2C%20sortBriefcaseList)%3B%0A%0Avar%20briefcaseHeader%20%3D%20document.querySelector('%23briefcaseModal%20.dialog-header')%3B%0AbriefcaseHeader.append(button)%3B%0A%0Afunction%20sortBriefcaseList()%20%7B%0A%20%20var%20briefcase%20%3D%20document.querySelector('%23briefcase-contents')%3B%0A%20%20var%20nodes%20%3D%20briefcase.querySelectorAll('%23briefcase-contents%20li')%3B%0A%0A%0A%0A%20%20var%20nodesArray%20%3D%20%5B%5D.slice.call(nodes)%3B%0A%0A%20%20nodesArray.sort((a%2C%20b)%20%3D%3E%20%7B%0A%20%20%20%20var%20aStart%20%3D%20getStartTime(a)%3B%0A%20%20%20%20var%20bStart%20%3D%20getStartTime(b)%3B%0A%0A%20%20%20%20console.log(aStart%2C%20bStart%2C%20new%20Date('1970%2F01%2F01%20'%20%2B%20aStart)%20-%20new%20Date('1970%2F01%2F01%20'%20%2B%20bStart))%3B%0A%0A%20%20%20%20return%20new%20Date('1970%2F01%2F01%20'%20%2B%20aStart)%20-%20new%20Date('1970%2F01%2F01%20'%20%2B%20bStart)%3B%0A%20%20%7D)%3B%0A%0A%20%20briefcase.innerHTML%20%3D%20''%3B%0A%0A%20%20nodesArray.forEach(function%20(node)%20%7B%0A%20%20%20%20briefcase.appendChild(node.cloneNode(true))%3B%0A%20%20%7D)%3B%0A%0A%20%20function%20getStartTime(node)%20%7B%0A%20%20%20%20var%20timeString%20%3D%20node.querySelector('.content-info').innerText%3B%0A%0A%20%20%20%20var%20timeParts%20%3D%20timeString.split('-')%3B%0A%20%20%20%20var%20startTime%20%3D%20timeParts%5B0%5D%3B%0A%0A%20%20%20%20if%20(!%2F%5Cd%2F.test(startTime))%20%7B%0A%20%20%20%20%20%20startTime%20%3D%20'11%3A59%20PM'%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20startTime%20%3D%20startTime.replace('pm'%2C%20'%20PM').replace('am'%2C%20'%20AM')%3B%0A%0A%20%20%20%20return%20startTime%3B%0A%20%20%7D%0A%0A%20%20function%20toNodeList(nodesArray)%20%7B%0A%20%20%20%20var%20fragment%20%3D%20document.createDocumentFragment()%3B%0A%0A%20%20%20%20nodesArray.forEach(function%20(node)%20%7B%0A%20%20%20%20%20%20fragment.appendChild(node.cloneNode())%3B%0A%20%20%20%20%7D)%3B%0A%0A%20%20%20%20return%20fragment.childNodes%3B%0A%20%20%7D%0A%7D%7D)()%3B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment