Teufelskreis
NGBler
- Registriert
- 14 Juli 2013
- Beiträge
- 207
Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.

function getClassElement(e,t){if(null==e)return null;if(e.className===t)return e;for(var r=0;r<e.childNodes.length;r++){var n=getClassElement(e.childNodes[r],t);if(n)return n}return null}function getClassElements(e,t){if(null==e)return null;if(e.className===t)return[e];for(var r=[],n=0;n<e.childNodes.length;n++)r=r.concat(getClassElements(e.childNodes[n],t));return r}function findOrders(e,t,r){var n=e.querySelectorAll(".order-card");orders[t]&&orders[t].pages[r]&&(orders[t].pages[r].done=!0),n.forEach((function(e){var n={price:"0,00",date:"?",link:"",names:[],prices:[],products:0,recip:""};e.querySelectorAll(".order-header__header-list-item").forEach((function(e){var t=e.textContent.trim();if(t.includes("Bestellung aufgegeben")){var r=e.querySelector(".a-size-base");r&&(n.date=r.textContent.trim())}else if(t.includes("Summe")){var a=e.querySelector(".a-size-base");a&&(n.price=a.textContent.replace(/EUR/,"").replace("€","").replace(/Summe/,"").trim())}}));var a=e.querySelector(".yohtmlc-recipient .a-popover-trigger");n.recip=a?a.textContent.trim():"?";var o=e.querySelector(".yohtmlc-order-level-connections a");o&&(n.link=o.href);var i=e.querySelectorAll(".item-box");n.products=i.length;var l=e.querySelectorAll(".delivery-box"),d=!1;l.forEach((function(e){var t=!1,r=e.querySelector(".yohtmlc-shipment-status-primaryText span");if(r){var a=r.textContent.trim().toLowerCase();(a.includes("erstattet")||a.includes("rücksendung abgeschlossen"))&&(t=!0)}e.querySelectorAll(".item-box").forEach((function(e){var r=e.querySelector(".yohtmlc-product-title a"),a=r?r.textContent.trim():"Unbekanntes Produkt";t&&(a+=" [ERSTATTET]"),n.names.push(a);var o=e.querySelector(".a-size-small.a-color-price");n.prices.push(o?o.textContent.trim():"?")})),t&&1===n.products&&(d=!0)})),d&&(n.price="0,00"),orders[t]&&orders[t].pages[r]&&orders[t].pages[r].entries.push(n)}))}function findShipments(e,t,r){e.querySelectorAll(".order-card").forEach((function(e){var t="",r="0,00",n="?",a=e.querySelector(".yohtmlc-order-id span:nth-child(2)");a&&(t=a.textContent.trim()),e.querySelectorAll(".order-header__header-list-item").forEach((function(e){var t=e.textContent.trim();if(t.includes("Bestellung aufgegeben")){var a=e.querySelector(".a-size-base");a&&(n=a.textContent.trim())}else if(t.includes("Summe")){var o=e.querySelector(".a-size-base");o&&(r=o.textContent.replace(/EUR/,"").replace("€","").trim())}}));var o=e.querySelectorAll(".item-box").length,i=e.querySelectorAll(".delivery-box");i.forEach((function(e){var a={orderNumber:t,orderPrice:r,orderDate:n,date:"?",names:[],prices:[],price:0,products:0},l=!1,d=e.querySelector(".yohtmlc-shipment-status-primaryText span");if(d){a.date=d.textContent.trim();var s=a.date.toLowerCase();(s.includes("erstattet")||s.includes("rücksendung abgeschlossen"))&&(l=!0)}var c=e.querySelectorAll(".item-box"),u=0;c.forEach((function(e){var t=e.querySelector(".yohtmlc-product-title a"),r=t?t.textContent.trim():"Unbekanntes Produkt";l&&(r+=" [ERSTATTET]"),a.names.push(r);var n=e.querySelector(".item-view-qty"),o=1;n&&(o=parseInt(n.textContent.trim()),isNaN(o)&&(o=1)),u+=o;var i=e.querySelector(".a-size-small.a-color-price");a.prices.push(i?i.textContent.trim():"?")})),a.products=u,1===i.length?a.price=r:a.price="*"+r,l&&1===o&&(a.price="0,00",a.orderPrice="0,00"),shipments.push(a)}))}))}function printState(){for(var e="",t=0;t<orders.length;t++){e+=orders[t].year+":",0==orders[t].pages.length&&(e+=" waiting...");for(var r=0;r<orders[t].pages.length;r++)e+=" "+(orders[t].pages[r].done?"X":".");e+="\n"}document.body.innerHTML="<pre>"+e+"</pre>"}function getEuroString(e){for(var t=(e.toFixed(2)+"").split("."),r=t[0],n="",a=0;a<r.length-1;a++)n+=r.charAt(a),(r.length-a)%3==1&&(n+=".");return(n+=r.charAt(r.length-1))+","+t[1]}function getOverviewLine(e){if(e.products)var t='<td align="right">'+getEuroString(e.cent/100/e.products)+'</td><td align="right">'+getEuroString(e.cent/100/e.month)+"</td>";else t='<td align="right">0,00</td><td align="right">0,00</td>';return'<tr><td align="right">'+e.name+'</td><td align="right">'+getEuroString(e.cent/100)+'</td><td align="right">'+e.orders+'</td><td align="right">'+e.products+"</td>"+t+"</tr>"}function getOrderLine(e){for(var t='<ul style="margin:0; padding:0 0 0 2em">',r=0;r<e.names.length;r++)t+="<li>"+e.names[r]+" | "+e.prices[r]+"</li>";return t+="</ul>",'<tr><td align="center" valign="top"><a href="'+e.link+'">Link</a></td><td align="right" valign="top">'+e.date+'</td><td align="center" valign="top">'+e.products+'</td><td align="right" valign="top">'+e.price+'</td><td align="left" valign="top">'+e.recip+'</td><td align="left" valign="top">'+t+"</td></tr>"}function getShipmentLine(e){for(var t="",r=0;r<e.names.length;r++)t+=e.names[r]+" | "+e.prices[r]+" # ";return'<tr><td align="center" valign="top">'+e.orderNumber+'</td><td align="right" valign="top">'+e.orderDate+'</td><td align="center" valign="top">'+e.orderPrice+'</td><td align="right" valign="top">'+e.date+'</td><td align="left" valign="top">'+e.products+'</td><td align="left" valign="top">'+e.price+'</td><td align="left" valign="top">'+t+"</td></tr>"}function printOrders(){for(var e=new Date,t=""+(1900+e.getYear()),r=e.getMonth()+1,n=[],a=[],o={name:"Insg.",cent:0,orders:0,products:0,month:0},i=0;i<orders.length;i++){for(var l=orders[i].year.substr(5),d={name:l,cent:0,orders:0,products:0,month:l===t?r:12},s=0;s<orders[i].pages.length;s++)for(var c=0;c<orders[i].pages[s].entries.length;c++){var u=orders[i].pages[s].entries[c],g=u.price.replace(/\./,"").split(","),h=100*parseInt(g[0])+parseInt(g[1]);d.cent+=h,d.products+=u.products,d.orders++,n.push(u)}o.cent+=d.cent,o.products+=d.products,o.orders+=d.orders,o.month+=d.month,a.push(d)}var p="<h2>Uebersicht</h2>";p+='<table cellspacing="0" cellpadding="4" border="1"><tr><th>Jahr</th><th>Euro</th><th>Bestell.</th><th>Produkte</th><th>Euro/Prod.</th><th>Euro/Monat</th></tr>',p+=getOverviewLine(o);for(i=0;i<a.length;i++)p+=getOverviewLine(a[i]);p+="</table>",p+="<h2>Einzel-Bestellungen</h2>",p+='<table cellspacing="0" cellpadding="4" border="1"><tr><th>Link</th><th>Datum</th><th>Produkte</th><th>Preis</th><th>Versandadresse</th><th>Produktbeschreibungen</th></tr>';for(i=0;i<n.length;i++)p+=getOrderLine(n[i]);p+="</table>",p+="<h2>Lieferungen</h2>",p+='<table cellspacing="0" cellpadding="4" border="1"><tr><th>Bestellnummer</th><th>Bestelldatum</th><th>Bestellsumme</th><th>Lieferdatum</th><th>Anzahl Produkte</th><th>Summe / Abbuchung</th><th>Produkte | Preis</th></tr>';for(i=0;i<shipments.length;i++)p+=getShipmentLine(shipments[i]);p+="</table>",document.body.innerHTML=p}function loadOrders(e){e.currentTarget.onlyOnce||(e.currentTarget.onlyOnce=!0,findOrders(e.currentTarget.document,e.currentTarget.yearIndex,e.currentTarget.pageIndex),findShipments(e.currentTarget.document,e.currentTarget.yearIndex,e.currentTarget.pageIndex),e.currentTarget.close())}function loadYear(e){if(!e.currentTarget.onlyOnce){e.currentTarget.onlyOnce=!0;for(var t=e.currentTarget.document,r=t.getElementsByTagName("a"),n=0,a=0;a<r.length;a++)r[a].href.match(/startIndex=(\d+)/)&&(n=Math.max(n,parseInt(RegExp.$1)));var o=e.currentTarget.yearIndex;for(a=0;a<=n;a+=10)orders[o].pages.push({done:!1,entries:[]});findOrders(t,o,0),findShipments(t,o,0);var i="https://www.amazon.de/your-orders/orders?timeFilter="+orders[o].year+"&startIndex=",l=1;for(a=10;a<=n;a+=10){var d=window.open(i+a);d.yearIndex=o,d.pageIndex=l,d.addEventListener("load",loadOrders,!0),l++}e.currentTarget.close()}}function loadYearCount(e){if(!e.currentTarget.onlyOnce){e.currentTarget.onlyOnce=!0;var t=e.currentTarget.document,r=t.querySelector(".js-time-filter-form"),n=t.querySelector('select[name="timeFilter"]');if(n){for(var a=0;a<n.options.length;a++){if(/year-(\d\d\d\d)/.exec(n.options[a].value)){var o=n.options[a].value;!1!==yearToLoad&&yearToLoad!==o||orders.push({year:n.options[a].value,pages:[]})}}var i="https://www.amazon.de/your-orders/orders?";if(r)for(a=0;a<r.elements.length;a++){var l=r.elements[a];l!==n&&l.name&&(i+=encodeURIComponent(l.name)+"="+encodeURIComponent(l.value)+"&")}i+="timeFilter=";for(a=0;a<orders.length;a++){var d=window.open(i+orders[a].year);d.yearIndex=a,d.addEventListener("load",loadYear,!0)}waitInterval=setInterval(waitForFinish,1e3),e.currentTarget.close()}else console.log("Jahresfilter nicht gefunden!")}}function waitForFinish(){printState();for(var e=0;e<orders.length;e++){if(0===orders[e].pages.length)return;for(var t=0;t<orders[e].pages.length;t++)if(!orders[e].pages[t].done)return}clearInterval(waitInterval),printOrders()}var waitInterval,orders=[],shipments=[],yearToLoad=!1,mainTab=window.open("https://www.amazon.de/your-orders/orders");mainTab.addEventListener("load",loadYearCount,!0);
