// ==UserScript==
// @name pizza.de ausleiter
// @namespace http://t-animal.de
// @include *pizza.de/*
// @exclude *pizza.de/0_static/orderload
// @grant none
// @version 1.1
// @run-at document-end
// ==/UserScript==
function sendOrder(event){
event.stopPropagation()
event.preventDefault()
var cartInfo;
for(var propName in cart) {
if(typeof(cart[propName]) == "function") {
if(cart[propName].toString().indexOf("coos") != -1){
cartInfo = cart[propName]();
}
}
}
if(cartInfo == undefined || cartInfo.shopversion == undefined){
alert("Bisher unbekannte Javascriptversion entdeckt. Bitte ruf manuell an: "+cart.config.store.phone+". Ausserdem wäre es sehr hilfreich, wenn du eine Javascript-Datei aus dem Source speichern und mir , zusammen mit der url dieses shops, schicken koenntest. Ihr Pfad beginnt mit /0_js/libs/shop. und sie ist wahrscheinlich in Zeile 41 des Quelltexts referenziert. Vielen Dank!" );
return false;
}
items = cartInfo.items
if(items == undefined){
alert("Bitte leg Dinge in den Warenkorb");
return false;
}
i=0;
$(".itemorderer").each(function(){
items[i++].orderer = $(this).val();
});
i=0;
$(".paidFor").each(function(){
items[i++].paidFor = $(this).val();
});
action="http://pizza.t-animal.de/createOrder";
// action="http://localhost:63255/createOrder";
$("body").prepend($('
'));
$("#jokerSubmitionForm").children("input").eq(0).val(JSON.stringify(items));
cart.config.store.name = document.title.substr(0,document.title.indexOf(","))
$("#jokerSubmitionForm").children("input").eq(1).val(JSON.stringify(cart.config.store));
$("#jokerSubmitionForm").children("input").eq(2).val(window.title);
$("#jokerSubmitionForm").submit();
}
function insertCustomButton(htmlCart){
elem = $(""+htmlCart+"
");
elem.find("#button-2012").html('
');
elem.find("#customSendButton").css({"background-position": "-790px -20px", "background-size": "950px 1600px", "height": "4em", "line-height": "1.5em", "padding-top": "0.5em"});
elem.find("#permkv8").remove();
elem.find(".cartitems-itemsum").each(function(){
id = $(this).parentsUntil("table").parent().attr("id")+"_orderer";
ordererValue = eval("window.savedOrderers."+id);
if(!ordererValue)
ordererValue = "";
if($("#"+id).val())
ordererValue = $("#"+id).val();
ordererPaidForValue = eval("window.paidForValue."+id+"_paidFor");
if(!ordererPaidForValue)
ordererPaidForValue = "";
if($("#"+id+"_paidFor").val())
ordererPaidForValue = $("#"+id+"_paidFor").val();
$(this).before(' | \
Besteller/gegeben: \
\
€\
|
');
});
window.setTimeout(function(){$('#customSendButton').get(0).addEventListener('click', sendOrder);}, 50);
window.setTimeout('$("#bestellform").attr({"action":"", "target":"", "method":"", "onsubmit":""});', 100);
return elem.html();
}
/*
* overwrite the cart's html generation method, insert our code, as soon as all the code is loaded
*/
//when the page is relocated all orderers are lost
window.savedOrderers = {};
window.paidForValue = {};
if(cart){
cart.origHTMLCart = cart.HTMLCart;
cart.HTMLCart = function(){
// return cart.origHTMLCart();
return insertCustomButton(cart.origHTMLCart());
}
cart.origNavigate = cart.navigate
cart.navigate = function(some, stuff){
window.savedOrderers = {};
$(".itemorderer").each(function(){eval("window.savedOrderers."+$(this).attr('id')+"='"+$(this).val()+"';")});
window.paidForValue = {};
$(".paidFor").each(function(){eval("window.paidForValue."+$(this).attr('id')+"='"+$(this).val()+"';")});
return cart.origNavigate(some, stuff);
}
//if this is not a greasemonkey script, we're probably called from bookmarklet
if(!(typeof GM_getValue != 'undefined' && typeof GM_getValue('a', 'b') != 'undefined')){
tmp=$(".navbars").find(".activ");
$(".navbars").find("a").not(".activ").first().click();
tmp.click();
alert("Der Joker wurde aktiviert");
}
}