Skip to content

Instantly share code, notes, and snippets.

@kevinAlbs
Last active June 30, 2016 14:26
Show Gist options
  • Save kevinAlbs/53273503e1362c1b28ab to your computer and use it in GitHub Desktop.
Save kevinAlbs/53273503e1362c1b28ab to your computer and use it in GitHub Desktop.
Ordering from Seamless for the lazy.
/*
Modify and copy-paste into console on the restaurant page
*/
var ITEM = "Chopt Cobb Salad";
var CHOICES = [
"Grape Tomatoes",
"California Walnuts",
"Hard-Boiled Egg",
"California Extra Virgin Olive Oil",
"Wisconson Cheddar",
];
function findCheckbox(content) {
var win = jQuery("#TB_window");
if(win.size() == 0) {
console.log("No window");
return;
}
var lbls = win.find("label");
for(var i = 0; i < lbls.size(); i++) {
var el = jQuery(lbls.get(i));
if(el.text().match(content)) {
return el.find("input");
}
}
return false;
}
function makeSelection(){
for(var i = 0; i < CHOICES.length; i++) {
var checkbox = findCheckbox(CHOICES[i]);
if (!checkbox) {
console.log("Could not find " + CHOICES[i]);
return;
}
// for pre jQuery 1.6.1
// Seamless uses 1.4.2
checkbox.attr("checked", true);
}
}
jQuery("a").each(function(i,e) {
var el = jQuery(e);
if(el.html() == ITEM) {
el.click();
window.setTimeout(makeSelection, 5000);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment