49 lines
2.2 KiB
JavaScript
49 lines
2.2 KiB
JavaScript
// ==UserScript==
|
|
// @name Gesamtkosten Handyflash
|
|
// @namespace http://tampermonkey.net/
|
|
// @version 0.6
|
|
// @description Berechnet die Gesamtkosten der Verträge auf handyflash.de
|
|
// @author Jan Bader <jan@javil.eu>
|
|
// @match http*://www.handyflash.de/handys/*
|
|
// @updateUrl https://git.javil.eu/jacob1123/userscripts/raw/master/total-cost.handyflash.user.js
|
|
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
|
|
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
|
|
// @grant GM_addStyle
|
|
// ==/UserScript==
|
|
|
|
(function() {
|
|
'use strict';
|
|
waitForKeyElements("article.rate", actionFunction);
|
|
function actionFunction() {
|
|
jQuery("article.rate").each(
|
|
function(i, tarif) {
|
|
if(jQuery(tarif).data('gesamt') !== undefined)
|
|
return;
|
|
|
|
var grundgebuehr_text = jQuery(tarif).find(".tariff_price").text();
|
|
var grundgebuehr = parseFloat(grundgebuehr_text.split("€")[0].replace(',', '.'));
|
|
grundgebuehr = Math.round(grundgebuehr, 2);
|
|
jQuery(tarif).data("monatlich", grundgebuehr);
|
|
|
|
var anzahlung_text = jQuery(tarif).find(".tariff_payout").text();
|
|
var anzahlung = parseFloat(anzahlung_text.split("€")[0].replace(',', '.'));
|
|
anzahlung = Math.round(anzahlung, 2);
|
|
jQuery(tarif).data("geraet", anzahlung);
|
|
var gesamt = grundgebuehr * 24 + anzahlung;
|
|
jQuery(tarif).data("gesamt", gesamt);
|
|
|
|
var details = jQuery(tarif).find(".tariff_links");
|
|
var header = jQuery(tarif).find(".tarife_box_header").text().replace(/^\s+|\s+$/g, '');
|
|
var info = (grundgebuehr * 24) + " + " + anzahlung + " = " + gesamt;
|
|
details.append("<p>"+info+"</p>");
|
|
console.log(header + ": " + info);
|
|
}
|
|
);
|
|
jQuery('article.rate').sort(function(a,b) {
|
|
var valA = $(a).data('gesamt');
|
|
var valB = $(b).data('gesamt');
|
|
return (valA < valB) ? -1 : (valA > valB) ? 1 : 0;
|
|
}).appendTo('#tariff_list_all');
|
|
}
|
|
})();
|