Skip to content

Instantly share code, notes, and snippets.

@icio
Created November 29, 2013 14:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icio/7706239 to your computer and use it in GitHub Desktop.
Save icio/7706239 to your computer and use it in GitHub Desktop.
Dominos Slack notifier

Dominos → Slack Notifier

Paste this snippet into your web browser's console when viewing the Pizza Tracker page offered after submitting a Dominos order. When the state changes it'll post the order state to your specified Slack Incoming Webhook. Use the URL at the top of your existing integration to paste into the prompt you receive when running the snippet. It should be in the form of: "https://TEAM.slack.com/services/hooks/incoming-webhook?token=TOKEN".

You'll need to leave your browser window open until it's done, of course. Tested in Chrome in the UK. Not tested with collections.

(function(endpoint) {
var prevState = null;
function notify(state) {
var params = "payload="+encodeURIComponent(JSON.stringify({
text: state,
username: "Dominos",
icon_emoji: ":pizza:",
}));
var n = new XMLHttpRequest();
n.open("POST", endpoint);
n.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
n.send(params);
}
setInterval(function () {
var state = (Array.prototype.slice.call(
pizzaTracker.document.getElementsByClassName("step-wrap")
).filter(function(e) {
return ~e.className.indexOf("-selected")
})[0] || {textContent: "Done"}).textContent.trim();
if (state != prevState) {
prevState = state;
notify(state);
}
}, 1000);
})(prompt("Slack Incoming Integration\n(https://TEAM.slack.com/services/hooks/incoming-webhook?token=TOKEN)"));
@schoeffman
Copy link

I made a chrome extension for this...only works on Domino's Canada at the moment. https://chrome.google.com/webstore/detail/slackn-dominos-tracking-n/ffbcjeiappfhhegcmccbhlhfkmldghpn

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