Skip to content

Instantly share code, notes, and snippets.

@alexanderbird
Created December 18, 2021 01:15
Show Gist options
  • Save alexanderbird/82693d3d6b65b24b085ab350d90abb0b to your computer and use it in GitHub Desktop.
Save alexanderbird/82693d3d6b65b24b085ab350d90abb0b to your computer and use it in GitHub Desktop.
JavaScript to highlight Skip The Dishes receipts for Friday purchases (and add a link for receipt ID to receipt so you can open in new tab)
/* let each of the order IDs be links to the receipt */
Array.from(document.querySelectorAll('[class*="OrderData"] [class*="OrderDataText"]:first-child')).forEach(orderSpan => {
const orderId = orderSpan.textContent.replace(/^#/, '');
const url = `/user/account/orders/${orderId}/details`;
orderSpan.innerHTML = `<a href="${url}">#${orderId}</a>`;
});
/* let each of the dates show day of week. Highlight the Fridays */
Array.from(document.querySelectorAll('span'))
.filter(span => span.textContent.trim().match(/202[0-9]-\d\d-\d\d/))
.forEach(span => {
const dateText = span.textContent.match(/.*(202[0-9]-\d\d-\d\d).*/)[1];
const date = new Date(dateText + 'T12:00:00+0000');
const day = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date.getDay()];
span.textContent = day + ', ' + dateText;
if (day === 'Fri') {
span.style.backgroundColor = '#88FF88';
span.style.color = 'black';
}
});
@alexanderbird
Copy link
Author

You can turn it into a bookmarklet with a tool like https://caiorss.github.io/bookmarklet-maker/. This produces a link which you can drag into your bookmarks bar. Click the link to execute the script.

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