// ==UserScript==
// @name Pfandflaschensammler
// @namespace http://userscripts.org/scripts/show/85124
// @author lmk (wieder lauffaehig gemacht und erweitert von We1hnachtsmann)
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @copyright (c) 2009, lmk.
// @description Nach beendetem Pfandflaschensammeln wird ein Hinweis auf der zuletzt geoeffneten Seite ausgegeben und es kann zur Pfandflaschensammelseite weitergeleitet werden.
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant GM_deleteValue
// @grant GM_listValues
// @include http://*.pennergame.de/*
// @include http://pennergame.de/*
// @include http://*.dossergame.co.uk/*
// @include http://dossergame.co.uk/*
// @include http://*.menelgame.pl/*
// @include http://menelgame.pl/*
// @include http://*.bumrise.com/*
// @include http://bumrise.com/*
// @include http://*.clodogame.fr/*
// @include http://clodogame.fr/*
// @include http://*.mendigogame.es/*
// @include http://mendigogame.es/*
// @include http://*.mendigogame.com/*
// @include http://mendigogame.com/*
// @include http://*.faveladogame.com/*
// @include http://faveladogame.com/*
// @include http://*.bomzhuj.ru/*
// @include http://bomzhuj.ru/*
// @exclude http://*board.pennergame.de/*
// @exclude http://mobile.pennergame.de/*
// @version 2.7.4 "Freche Früchtchen": Korrekturen und Liste mit gefundenen Gegenständen
// ==/UserScript==
// @version 2.7.3 Fehler bei TA behoben; Spiele "Freche Früchtchen" und "Eiswürfelspiel" neu
// @version 2.7.2 Spiele "Freche Früchtchen" und "Eiswürfelspiel" auf Wunsch automatisch
// @version 2.7.1 Anpassungen wegen des neuen Bildungsslots
// @version 2.6.12 Korrektur Geld in Bandenkasse einzahlen
// @version 2.6.11 keine Texte bei Geldeinzahlung; Korrekturen bei TA
// @version 2.6.10 Korrektur TA Flaschen sammeln
// @version 2.6.9 Korrektur Flaschen verkaufen; ggf. Seife bei TA "100% sauber" benutzen
// @version 2.6.8 Korrektur TA Lose kaufen; Wut/WiWu-abhängiger Plunderwechsel
// @version 2.6.7 automatischer Flaschenverkauf im Vatikan funktionierte nicht mehr
// @version 2.6.6 weitere Korrekturen an Tagesaufgaben
// @version 2.6.5 kleine Korrekturen
// @version 2.6.4 Plunder für Eigentumupgrades nicht verschrotten, wenn er noch benötigt wird.
// @version 2.6.3 Anpassungen für Mini-Spiel "Zecken für Ecken"
// @version 2.6.2 Kleine Anpassungen für Missionsplunder; Probleme mit Fußballspiel behoben
// @version 2.6.1 Erweiterung Erledigung Tägliche Aufgabe und Mini-Spiel "Umkleidekabine"
// @version 2.5.16 Erweiterung für Mini-Spiel "Russisch Roulette"
// @version 2.5.15 Abschalten des Mini-Spiels "Russisch Roulette"
// @version 2.5.14 Anpassungen für Mini-Spiel "Eierklau 2015"
// @version 2.5.13 Mini-Spiel "Osterfeuer 2015"
// @version 2.5.12 Spenden holen
// @version 2.5.11 Kamellen suchen
// @version 2.5.10 Unnötige Aufrufe der Eventseite abgestellt
// @version 2.5.9 Automatik funktionierte nicht mehr
// @version 2.5.8 Probleme mit Event-Seite behoben
// @version 2.5.7 Vatikan: Flaschenverkauf bei Überschreiten eines maximalen Füllgrads
// @version 2.5.6 Adventsspiel: Plätzchenklau, Korrektur
// @version 2.5.5 Adventsspiel: Plätzchenklau
// @version 2.5.4 Fehler bei Erkennung eines vorhandenen Updates behoben
// @version 2.5.3 Erkennung des beendeten Minigames fehlerhaft; Sammelmarken einlösen
// @version 2.5.2 automatischer Aufruf der Event-Seite falls nötig
// @version 2.5.1 erste Version Vatikan und neues Rentier-Spiel
// @version 2.4.3 Korrekturen; Gehalt automatisch abholen
// @version 2.4.2 Erweiterungen und Korrekturen für Eckfahnenspiel 2014
// @version 2.4.1 Wechsel auf greasyfork.org; Verbrechensstart erweitert
// @version 2.3.34 Anpassungen für Sommergame 2014 (Zollbeamter)
// @version 2.3.33 noch eine Korrektur zu Anpassungen für Ostergame 2014
// @version 2.3.32 Korrektur zu Anpassungen für Ostergame 2014
// @version 2.3.31 Anpassungen für Ostergame 2014
// @version 2.3.30 Fehler bei Anpassung an neues Karnevalgame behoben
// @version 2.3.29 Anpassung an neues Karnevalgame
// @version 2.3.28 kleine Korrektur: bei automatischen Verbrechen kam u.U. eine Abfrage
// @version 2.3.27 2. Korrektur zu Anpassungen an Xmas-Minigame 2013
// @version 2.3.26 Korrektur zu Anpassungen an Xmas-Minigame 2013
// @version 2.3.25 Anpassungen an Xmas-Minigame 2013
// @version 2.3.24 Skript lief nicht mehr richtig
// @version 2.3.23 Checkbox auf Login-Seite fehlte
// @version 2.3.22 Fehler im letzten Update behoben
// @version 2.3.21 Anpassung wegen anderen Aufbaus der Counter; Beseitigung von Fehlermeldungen
// @version 2.3.20 Erweiterung um Minispiel Piratenschatz
// @version 2.3.19 Erweiterung um Minispiel Zollkontrolle
// @version 2.3.18 Erweiterung um Kofferpackspiel
// @version 2.3.17 kein automatisches Wiedereinloggen, wenn explizit ausgeloggt wurde
// @version 2.3.16 automatisches Wiedereinloggen
// @version 2.3.15 Korrektur wegen Stadtfeind
// @version 2.3.14 Testmeldung entfernt
// @version 2.3.13 kleinere Erweiterungen; Reparatur nach Totalausfall
// @version 2.3.12 Korrektur wegen Stadtfeind
// @version 2.3.11 noch einmal Updateverfahren korrigiert
// @version $Id: pfandflaschensammler.user.js 108 2015-07-27 20:35:30Z mkl $
/* Automatic click on "start collecting" | Automatischer Klick auf "Sammeln" */
var autoSubmit = true; //false;
/* Alert messages */
var msgDone1 = "Das Pfandflaschensammeln wurde beendet."; // "Collecting done";
var msgDone2 = "Klicke auf OK um die Aktionsseite zu " + unescape("%F6") + "ffnen."; // "Click ok to open actions-page";
var msgAttackEnemy = "Es wurde ein Angriff auf den Stadtfeind Nr. 1 gestartet. Seite aktualisieren ?";
/* Captcha select title*/
var strTime = "Zeit: "; // "Time: ";
var intervalTime = 4000;
var done = " -/-"; // text after counter reached 0:00
var done0 = "00:00"; // alternative text after counter reached 0:00
var time = String(new Date().getTime());
var counter = done;
var fcounter = done;
var nameTime = "time";
var nameLastCollectTime = "LastCollectTime";
var checkInterval;
var TOWNEXTENSION = window.location.host;
var m_ownuserid;
var THISSCRIPTVERSION = GM_info.script.version.match(/[\d\.]*/)[0];
var THISSCRIPTNAME = GM_info.script.name;
var THISSCRIPTINSTALL_URLGF = "https://greasyfork.org/scripts/1049-pfandflaschensammler";
var language = document.getElementsByName("language")[0].content;
// Version ermitteln
var oldVersion = 1;
if (!document.getElementById("login")) {
var host = location.toString();
var pos = host.lastIndexOf("//") + 2;
host = host.substr(pos);
pos = host.indexOf("/");
host = host.substr(0, pos);
GM_setValue("ErrorCounter_" + host, GM_getValue("ErrorCounter_" + host, 0) + 1);
oldVersion = 0;
setTimeout(reload, 10000, "main");
}
else
doTheAction();
// **********************************************************************************
// **********************************************************************************
// Funktion extrahiert die eigene UserID
// **********************************************************************************
// **********************************************************************************
function getOwnUserID() {
// Eigene UserID ermitteln
var ownuserid = document.getElementById('my-profile').innerHTML.split('href="/profil/id:')[1];
ownuserid = ownuserid.split('/"')[0];
return ownuserid;
}
// Holen einer Variablen ohne User-Id
function PG_getValue(varname, deflt) {
return GM_getValue(TOWNEXTENSION + varname, deflt);
}
// Setzen einer Variablen ohne User-Id
function PG_setValue(varname, value) {
GM_setValue(TOWNEXTENSION + varname, value);
}
// Holen einer Variablen mit User-Id
function PGu_getValue(varname, deflt) {
return GM_getValue(TOWNEXTENSION + varname + m_ownuserid, deflt);
}
// Setzen einer Variablen mit User-Id
function PGu_setValue(varname, value) {
GM_setValue(TOWNEXTENSION + varname + m_ownuserid, value);
}
// Leschen einer Variablen mit User-Id
function PGu_delete(varname) {
GM_deleteValue(TOWNEXTENSION + varname + m_ownuserid);
}
// ***********************************************************************************************
// ***********************************************************************************************
// formats a date into the format "YYYY-MM-DD"
// ***********************************************************************************************
// ***********************************************************************************************
function FormatDate(DateToFormat) {
var year = DateToFormat.getFullYear();
var month = DateToFormat.getMonth() + 101 + "";
var day = DateToFormat.getDate() + 100 + "";
return year + "-" + month.slice(1) + "-" + day.slice(1);
}
// **********************************************************************************
// **********************************************************************************
// returns the money value
// **********************************************************************************
// **********************************************************************************
function GetMoney(doc) {
var money = doc.getElementsByClassName("icon money")[0].getElementsByTagName("a")[0];
money = Number(money.innerHTML.match(/[\d.,]+/)[0].replace(/[.,]/g, "")) / 100;
return money;
}
// **********************************************************************************
// **********************************************************************************
// returns the promille value
// **********************************************************************************
// **********************************************************************************
function GetPromille(doc) {
var promille = doc.getElementsByClassName("icon beer")[0].getElementsByTagName("a")[0];
promille = Number(promille.innerHTML.match(/[\d.,]+/)[0].replace(/[.,]/,''))/100;
return promille;
}
// ***********************************************************************************************
// ***********************************************************************************************
// check for a new script version and display a message, if there is one
// ***********************************************************************************************
// ***********************************************************************************************
function CheckForUpdate() {
// create and format actual date
var today = new Date();
var tagesdatum = FormatDate(today);
// if not searched for a new version of the script today
if (GM_getValue("LastUpdateCheckGF","") != tagesdatum) {
// **********************************************************************************
// *** GM_XMLHTTPREQUEST *** Abrufen der Skriptseite von greasyfork.org
// **********************************************************************************
GM_xmlhttpRequest({method: 'GET',
url: THISSCRIPTINSTALL_URLGF,
headers:{ "Accept":"text/javascript; charset=UTF-8" },
overrideMimeType:"application/javascript; charset=UTF-8",
onload:function(responseDetails) {
// Wenn die Seite erfolgreich abgerufen werden konnte
if (responseDetails.status == 200) {
var content = responseDetails.responseText;
// Ermitteln der Skriptversion
if (content.indexOf("@version") != -1)
var scriptfullversion = content.split('@version')[1].trim().split('\n')[0];
else
var scriptfullversion = content.split('"script-show-version">').pop().split('</span')[0].split('<span>').pop();
var scriptversion = scriptfullversion.split(' ')[0];
scriptfullversion = scriptfullversion.substr(scriptversion.length+1);
// if there is a new version of the script
if (scriptversion != THISSCRIPTVERSION) {
// build the message
var alerttext = "Es gibt eine neue Version des Skriptes '" + THISSCRIPTNAME + "':\n\n" + scriptfullversion + "\n\nDie neue Version kann Fehlerbehebungen und/oder neue Funktionen beinhalten.\nHier gibt es weitere Infos über die neue Version:\n\n" + THISSCRIPTINSTALL_URLGF + "\n\nEine Aktualisierung ist empfehlenswert und kann direkt anschließend durchgeführt werden.\n\nHinweis: Die überprüfung auf neue Versionen wird nur einmal pro Tag durchgeführt."
// display the message
alert(alerttext);
// load the page with the new script for installation
window.location.href = THISSCRIPTINSTALL_URLGF+'/code/Pfandflaschensammler.user.js';
}
}
}
});
// memorize the new date
GM_setValue("LastUpdateCheckGF", tagesdatum)
}
}
// ***********************************************************************************************
// ***********************************************************************************************
// check for new minigame
// ***********************************************************************************************
// ***********************************************************************************************
function CheckNewMinigame() {
var today = new Date();
var tagesdatum = FormatDate(today);
var timeout = Math.min(PGu_getValue("minigame_wait", -1), PGu_getValue("slipgame_wait", -1)) - today.getTime();
if (timeout < 2000)
timeout = 2000;
var enemy = document.getElementById("enemy_info");
if (enemy) {
var einfo = document.getElementById("wrap").innerHTML.split("#enemy_info").pop();
if (einfo.indexOf("window.location") == -1)
return;
var addr = einfo.split("location")[1].split('"')[1];
var tagesdatum = FormatDate(today);
if (PGu_getValue("gamechkr_date", "xx") == tagesdatum && PGu_getValue("gamechkr_noon", "xx") != tagesdatum) {
if (today.getHours() > 12) {
PGu_setValue("gamechkr_noon", tagesdatum);
PGu_setValue("gamechkr_date", "xx");
}
}
if (PGu_getValue("gamechkr_date", "xx") != tagesdatum) {
if (PGu_getValue("gamechkr_noon", "xx") != tagesdatum)
PGu_setValue("junkfound", "");
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.host + addr, onload:function(responseDetails) {
var content = responseDetails.responseText.split('id="content"')[1];
if (content.indexOf('href="javascript:slipgame_show') == -1) {
PGu_setValue("slipgame_date", tagesdatum);
if (today.getHours() > 12)
PGu_setValue("slipgame_noon", tagesdatum);
}
if (content.indexOf('href="javascript:minigame_show') == -1) {
PGu_setValue("minigame_date", tagesdatum);
if (today.getHours() > 12)
PGu_setValue("minigame_noon", tagesdatum);
}
if (content.indexOf('href="/livegame/bb/"') == -1) {
PGu_setValue("livegame_date", tagesdatum);
if (today.getHours() > 12)
PGu_setValue("livegamew_noon", tagesdatum);
}
if (content.indexOf("javascript:display_show(") == -1) {
PGu_setValue("dispshow_date", tagesdatum);
if (today.getHours() > 12)
PGu_setValue("displshow_noon", tagesdatum);
}
if (tagesdatum == PGu_getValue("slipgame_date", "xx") && PGu_getValue("slipgame_noon", "xx") != tagesdatum) {
if (today.getHours() > 12) {
PGu_setValue("slipgame_noon", tagesdatum);
PGu_setValue("slipgame_date", "xx");
}
}
if (tagesdatum == PGu_getValue("minigame_date", "xx") && PGu_getValue("minigame_noon", "xx") != tagesdatum) {
if (today.getHours() > 12) {
PGu_setValue("minigame_noon", tagesdatum);
PGu_setValue("minigame_date", "xx");
}
}
if (tagesdatum == PGu_getValue("dispshow_date", "xx") && PGu_getValue("dispshow_noon", "xx") != tagesdatum) {
if (today.getHours() > 12) {
PGu_setValue("dispshow_noon", tagesdatum);
PGu_setValue("dispshow_date", "xx");
}
}
if (tagesdatum == PGu_getValue("livegame_date", "xx") && PGu_getValue("livegame_noon", "xx") != tagesdatum) {
if (today.getHours() > 12) {
PGu_setValue("livegame_noon", tagesdatum);
PGu_setValue("livegame_date", "xx");
}
}
if (PGu_getValue("livegame_date", "xx") != tagesdatum) {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.host + "/livegame/bb/", onload:function(responseDetails) {
var content = responseDetails.responseText.split('id="content"')[1];
if (content.indexOf('id="gameshell"') != -1) {
content = content.split('class="counters"')[1];
//alert(content);
var free = content.split('id="counter_free"')[1].split("<")[0].split(">")[1];
var free2 = content.split('id="counter"')[1].split("<")[0].split(">")[1];
// alert(free+"/"+free2);
if (free == "0" && free2 == "0")
PGu_setValue("livegame_date", tagesdatum);
}
}});
}
if (PGu_getValue("dispshow_date", "xx") != tagesdatum) {
if (content.indexOf("javascript:display_show(") != -1) {
var game = content.split("javascript:display_show('")[1].split("'")[0];
PGu_setValue("dispshow_game", game);
if (PGu_getValue(game+"auto", false) && PGu_getValue(game+"date", "xx") != tagesdatum) {
var addr = content.split("function display_show(")[1].split('url = "')[1].split('"')[0] + game + "/";
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.host + addr, onload:function(responseDetails) {
var content = responseDetails.responseText;
var div = content.split('class="button_container"')[1].split("<div")[2];
if (div.indexOf("KK") != -1) {
PGu_setValue("dispshow_date", tagesdatum);
PGu_setValue(game+"date", tagesdatum);
}
}});
}
}
else
PGu_setValue("dispshow_date", tagesdatum);
}
PGu_setValue("gamechkr_date", tagesdatum);
}});
timeout = 2000;
}
if (PGu_getValue("slipgame_date", "xx") != tagesdatum || PGu_getValue("minigame_date", "xx") != tagesdatum ||
PGu_getValue("dispshow_date", "xx") != tagesdatum && PGu_getValue(PGu_getValue("dispshow_game", "")+"auto", false)) {
if (window.location.pathname.indexOf(addr) == -1) {
window.location.href = window.location.protocol + '//' + window.location.host + addr;
return;
}
}
else if (PGu_getValue("livegame_date", "xx") != tagesdatum && PGu_getValue("livegameauto", false)) {
if (document.getElementById("gameshell"))
timeout = DoLiveGame(1);
else {
window.location.href = window.location.protocol + '//' + window.location.host + "/livegame/bb/";
return;
}
}
else {
if (today.getHours() < 12)
timeout = 43500000 - Number(today.getTime())%86400000;
else
timeout = 86400000 - Number(today.getTime())%86400000;
}
}
else
PGu_setValue("dispshow_game", "");
if (document.getElementById("display")) {
if (document.getElementById("display").getElementsByClassName("cbox").length > 0)
timeout = DoNewMinigame(1);
else if (document.getElementById("display").getElementsByClassName("field").length > 0)
timeout = DoNewMinigame(2);
else if (document.getElementById("display").getElementsByClassName("die_results").length > 0)
timeout = DoNewMinigame(3);
else if (document.getElementById("display").getElementsByClassName("modal_close").length == 0 ||
document.getElementById("display").style.display == "none") {
if (PGu_getValue("dispshow_date", "xx") != tagesdatum) {
var game = PGu_getValue("dispshow_game", "");
if (PGu_getValue(game+"date", "xx") == tagesdatum) {
PGu_setValue("dispshow_date", tagesdatum);
timeout = 0;
}
else if (PGu_getValue(game+"auto", false)) {
var addr = document.getElementById("content").innerHTML.split("function display_show(")[1].split('url = "')[1].split('"')[0] + game + "/";
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.host + addr, onload:function(responseDetails) {
var content = responseDetails.responseText;
var div = content.split('class="button_container"')[1].split("<div")[2];
if (div.indexOf("KK") == -1)
unsafeWindow.display_show(game);
else {
PGu_setValue(game+"date", tagesdatum);
PGu_setValue("dispshow_date", tagesdatum);
}
}});
timeout = 2000;
}
else
timeout = 0;
}
else if (PGu_getValue("slipgame_date", "xx") != tagesdatum ||
PGu_getValue("minigame_date", "xx") != tagesdatum ||
PGu_getValue("minigame_success", 0) == 0) {
var gamepre = "mini";
if (PGu_getValue("slipgame_date", "xx") != tagesdatum)
gamepre = "slip";
var pos = document.getElementById("content").innerHTML.indexOf("javascript:"+gamepre+"game_show");
if (pos != -1) {
if (gamepre == "mini")
unsafeWindow.minigame_show();
else
unsafeWindow.slipgame_show();
timeout = 2000;
}
else {
PGu_setValue(gamepre+"game_date", tagesdatum);
if (today.getHours() > 12)
PGu_setValue(gamepre+"game_noon", tagesdatum);
}
}
}
}
if (timeout == -1)
window.location.href = window.location.protocol + '//' + window.location.host + addr;
else if (timeout > 0)
window.setTimeout(CheckNewMinigame, timeout);
}
// ***********************************************************************************************
// ***********************************************************************************************
// play the livegame
// ***********************************************************************************************
// ***********************************************************************************************
function DoLiveGame (mode) {
function checkField(fx, fy) {
if (fx < 0 || fx >= x || fy < 0 || fy >= y)
return true;
var nr = (fy + fx*y + 1)*2;
return fields[nr].style.background == "";
}
function checkPic(fx, fy, bild) {
if (fx < 0 || fx >= x || fy < 0 || fy >= y)
return false;
var nr = (fy + fx*y + 1)*2;
var pic = fields[nr].style.background;
if (pic != "")
pic = pic.split("url(")[1].split(")")[0].split("/").pop().split(".")[0];
if (pic == "" && fields[nr].className.indexOf("disabled") != -1)
return false;
return pic == bild;
}
var game = document.getElementById("gameshell");
var fields = game.getElementsByTagName("div");
if (fields[fields.length-2].className.indexOf("fieldshown") != -1) {
var msg = fields[fields.length-1].innerHTML;
var h1 = msg.split(">")[1].split("<")[0];
var plunder = msg.split('>').pop().trim();
var gw = false;
if (h1.indexOf("Glückwunsch") != -1) {
gw = true;
if (msg.indexOf("ergattert") != -1)
plunder = plunder.match(/\d+ [^ ]*/)[0];
else
plunder = "";
}
else if (plunder.indexOf('"') != -1)
plunder = plunder.split('"')[1];
else if (h1 == "Niete")
plunder = plunder.match(/\d+[^ ]*/)[0] + " Niete";
else if (h1.substr(-10) == "Kronkorken")
plunder = h1;
else if (h1 == "Leinen")
plunder = plunder.match(/\d+ [^ ]*/)[0];
else if (plunder.indexOf("Provokationen") != -1)
plunder = plunder.match(/\d+/)[0] + " Provokationen";
else if (plunder.substr(0, 13) == "Deine aktiven")
plunder = plunder.match(/\d+ [^ ]*/)[0] + " für aktive Haustiere";
else if (plunder.indexOf("Gästebuch") != -1)
plunder = plunder.match(/\d+ [^ ]*/)[0] + " für Profil-Gästebuch";
else if (plunder.substr(0, 12) == "Deine Bande ")
plunder = plunder.match(/\d+/)[0] + " Banden-Kronkorken";
else if (plunder.substr(0, 8) == "Du hast ")
plunder = plunder.substring(8, plunder.indexOf(" gefunden"));
if (plunder != "") {
var pAnz = plunder.match(/^\d+[^ ]*/);
if (pAnz) {
pAnz = ":" + pAnz[0];
var pos = plunder.indexOf(" ");
plunder = plunder.substr(pos+1);
}
else
pAnz = "";
var junkfound = PGu_getValue("junkfound", "");
if (junkfound == "")
junkfound = plunder + pAnz + ":1" +(gw?";":"");
else {
var junkArr = junkfound.split(";");
var pos = junkfound.replace(/:[\d€]*/g, "").split(";").indexOf(plunder);
if (pos == -1) {
if (gw) {
pos = junkArr.indexOf("");
if (pos == -1) {
junkArr.splice(0, 0, "");
pos = 0;
}
junkArr.splice(pos, 0, plunder + pAnz + ":1");
}
else
junkArr.push(plunder + pAnz + ":1");
}
else {
var anz = Number(junkArr[pos].split(":").pop()) + 1;
junkArr[pos] = junkArr[pos].substring(0, junkArr[pos].lastIndexOf(":")) + pAnz + ":" + anz;
}
junkfound = junkArr.join(";");
}
PGu_setValue("junkfound", junkfound);
if (!document.getElementById("junkfound"))
insertCheckBox11();
}
var f = document.getElementById(fields[fields.length-2].id);
if (f.className.indexOf("disabled") != -1)
fields[fields.length-2].parentNode.removeChild(fields[fields.length-2]);
return 1000;
}
var fieldanz = (fields.length - 1) / 2;
var lastfield = fields[fieldanz * 2];
var spl = lastfield.id.split("_");
var y = Number(spl.pop()) + 1;
var x = Number(spl.pop()) + 1;
var free = Number(document.getElementById("counter_free").innerHTML) + Number(document.getElementById("counter").innerHTML);
var kkAnz = Number(document.getElementsByClassName("icon crowncap")[0].innerHTML.split(">")[1].split("<")[0].trim());
var anzloch = game.innerHTML.split("loch").length - 1;
if (free == 0 && (anzloch == 0 || kkAnz < 2 || !PGu_getValue("livegameKK", false))) {
var today = new Date();
var tagesdatum = FormatDate(today);
PGu_setValue("livegame_date", tagesdatum);
return 2000;
}
var field = 0;
var newField = 0;
var forms = new Array();
var forms2cnt = new Array(0,22,22,11,12,12,11,13,11);
var countrs = document.getElementsByClassName("counters")[0].innerHTML;
for (var i = 1; i <= 8; i++) {
if (countrs.indexOf("counter_"+i) == -1)
continue;
var counter = countrs.split("counter_"+i)[1].split("<");
var counterg = Number(counter[1].split("/").pop());
counter = Number(counter[0].split(">").pop());
if (counter != counterg)
if (forms.indexOf(forms2cnt[i]) == -1)
forms.push(forms2cnt[i]);
}
var highfields = new Array();
if (anzloch > 0) {
field = game.innerHTML.split("loch")[0].split("<div").length - 2;
var fx = Math.floor((field-2)/y/2);
var fy = (field - fx*2*y - 2)/2;
if (forms.indexOf(22) != -1) {
if (anzloch == 3) {
if (checkPic(fx+1, fy-1, "loch") && checkPic(fx+1, fy, "loch"))
newField = field - 2;
else if (checkPic(fx+1, fy, "loch") && checkPic(fx+1, fy+1, "loch"))
newField = field + 2;
else if (checkPic(fx, fy+1, "loch") && checkPic(fx+1, fy+1, "loch"))
newField = field + 2*y;
else if (checkPic(fx+1, fy, "loch") && checkPic(fx, fy+1, "loch"))
newField = field + 2*y + 2;
}
if (anzloch >= 2 && newField == 0) {
if (checkPic(fx+1, fy-1, "loch")) {
if (checkPic(fx, fy-1, "") && checkPic(fx+1, fy, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+2, fy) && checkField(fx+1, fy+1)) {
highfields.push(field - 2);
highfields.push(field + 2*y);
}
}
if (checkPic(fx+1, fy, "loch")) {
if (checkPic(fx, fy-1, "") && checkPic(fx+1, fy-1, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+1, fy-2) && checkField(fx+2, fy-1) && checkField(fx+2, fy)) {
if (highfields.indexOf(field - 2) == -1)
highfields.push(field - 2);
//highfields.push(field - 2 + 2*y);
}
if (checkPic(fx, fy+1, "") && checkPic(fx+1, fy+1, "") && checkField(fx-1, fy+1) && checkField(fx, fy+2) && checkField(fx+1, fy+2) && checkField(fx+1, fy+1) && checkField(fx+2, fy)) {
highfields.push(field + 2);
//highfields.push(field + 2 + 2*y);
}
}
if (checkPic(fx+1, fy+1, "loch")) {
if (checkPic(fx, fy+1, "") && checkPic(fx+1, fy, "") && checkField(fx-1, fy+1) && checkField(fx, fy+2) && checkField(fx+1, fy-1) && checkField(fx+2, fy)) {
if (highfields.indexOf(field + 2) == -1)
highfields.push(field + 2);
if (highfields.indexOf(field + 2*y) == -1)
highfields.push(field + 2*y);
}
}
if (checkPic(fx, fy+1, "loch")) {
if (checkPic(fx-1, fy, "") && checkPic(fx-1, fy+1, "") && checkField(fx-1, fy-1) && checkField(fx-2, fy) && checkField(fx-2, fy+1) && checkField(fx-1, fy+2)) {
highfields.push(field - 2*y);
//highfields.push(field + 2 - 2*y);
}
if (checkPic(fx+1, fy, "") && checkPic(fx+1, fy+1, "") && checkField(fx+1, fy-1) && checkField(fx+2, fy) && checkField(fx+2, fy+1) && checkField(fx+1, fy+2)) {
if (highfields.indexOf(field + 2*y) == -1)
highfields.push(field + 2*y);
//if (highfields.indexOf(field + 2 + 2*y) == -1)
// highfields.push(field + 2 + 2*y);
}
}
if (highfields.length > 0)
newField = highfields[Math.floor(Math.random() * highfields.length)];
}
if (newField == 0) {
if (checkPic(fx, fy-1, "") && checkPic(fx+1, fy-1, "") && checkPic(fx+1, fy, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+1, fy-2) && checkField(fx+2, fy-1) && checkField(fx+2, fy) && checkField(fx+1, fy+1)) {
highfields.push(field - 2);
//highfields.push(field - 2 + 2*y);
highfields.push(field + 2*y);
}
if (checkPic(fx+1, fy, "") && checkPic(fx+1, fy+1, "") && checkPic(fx, fy+1, "") && checkField(fx+1, fy-1) && checkField(fx+2, fy) && checkField(fx+2, fy+1) && checkField(fx+1, fy+2) && checkField(fx, fy+2) && checkField(fx-1, fy+1)) {
highfields.push(field + 2);
if (highfields.indexOf(field + 2*y) == -1)
highfields.push(field + 2*y);
//highfields.push(field + 2 + 2*y);
}
if (checkPic(fx-1, fy, "") && checkPic(fx-1, fy+1, "") && checkPic(fx, fy+1, "") && checkField(fx-1, fy-1) && checkField(fx-2, fy) && checkField(fx-2, fy+1) && checkField(fx-1, fy+2) && checkField(fx, fy+2) && checkField(fx+1, fy+1)) {
highfields.push(field - 2*y);
//highfields.push(field + 2 - 2*y);
if (highfields.indexOf(field + 2) == -1)
highfields.push(field + 2);
}
if (checkPic(fx-1, fy, "") && checkPic(fx-1, fy-1, "") && checkPic(fx, fy-1, "") && checkField(fx-1, fy+1) && checkField(fx-2, fy) && checkField(fx-2, fy-1) && checkField(fx-1, fy-2) && checkField(fx, fy-2) && checkField(fx+1, fy-1)) {
if (highfields.indexOf(field - 2*y) == -1)
highfields.push(field - 2*y);
//highfields.push(field - 2 - 2*y);
if (highfields.indexOf(field - 2) == -1)
highfields.push(field - 2);
}
if (highfields.length > 0)
newField = highfields[Math.floor(Math.random() * highfields.length)];
}
}
if (forms.indexOf(13) != -1 && newField == 0) {
if (checkPic(fx+1, fy, "loch")) {
if (checkPic(fx+2, fy, "") && checkField(fx+2, fy-1) && checkField(fx+3, fy) && checkField(fx+2, fy+1))
highfields.push(field + 4*y);
if (checkPic(fx-1, fy, "") && checkField(fx-2, fy) && checkField(fx-1, fy-1) && checkField(fx-1, fy+1))
highfields.push(field - 2*y);
}
if (checkPic(fx+2, fy, "loch") && checkPic(fx+1, fy, "") && checkField(fx+1, fy-1) && checkField(fx+1, fy+1))
highfields.push(field + 2*y);
if (checkPic(fx, fy+1, "loch")) {
if (checkPic(fx, fy+2, "") && checkField(fx-1, fy+2) && checkField(fx, fy+3) && checkField(fx+1, fy+2))
highfields.push(field + 4);
if (checkPic(fx, fy-1, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+1, fy-1))
highfields.push(field - 2);
}
if (checkPic(fx, fy+2, "loch") && checkPic(fx, fy+1, "") && checkField(fx-1, fy+1) && checkField(fx+1, fy+1))
highfields.push(field + 2);
if (highfields.length > 0)
newField = highfields[Math.floor(Math.random() * highfields.length)];
}
if (newField == 0) {
if (checkPic(fx, fy-1, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+1, fy-1))
highfields.push(field - 2);
if (checkPic(fx+1, fy, "") && checkField(fx+1, fy-1) && checkField(fx+2, fy) && checkField(fx+1, fy+1))
highfields.push(field + 2*y);
if (checkPic(fx, fy+1, "") && checkField(fx-1, fy+1) && checkField(fx, fy+2) && checkField(fx+1, fy+1))
highfields.push(field + 2);
if (checkPic(fx-1, fy, "") && checkField(fx-1, fy-1) && checkField(fx-2, fy) && checkField(fx-1, fy+1))
highfields.push(field - 2*y);
if (highfields.length > 0)
newField = highfields[Math.floor(Math.random() * highfields.length)];
}
}
if (newField == 0) {
var probs = new Array();
for (var i = 0; i < x; i++) {
probs[i] = new Array();
for (var j = 0; j < y; j++)
probs[i][j] = 0;
}
fx = 0;
fy = 0;
for (var i = 2; i < fields.length; i += 2) {
if (checkPic(fx, fy, "")) {
for (var j = 0; j < forms.length; j++) {
switch (forms[j]) {
case 11:
if (checkField(fx-1, fy) && checkField(fx, fy-1) && checkField(fx+1, fy) && checkField(fx, fy+1)) {
probs[fx][fy]++;
}
break;
case 12:
if (checkPic(fx, fy-1, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+1, fy-1)) {
probs[fx][fy]++;
probs[fx][fy-1]++;
}
if (checkPic(fx, fy+1, "") && checkField(fx-1, fy+1) && checkField(fx, fy+2) && checkField(fx+1, fy+1)) {
probs[fx][fy]++;
probs[fx][fy+1]++;
}
if (checkPic(fx-1, fy, "") && checkField(fx-1, fy-1) && checkField(fx-2, fy) && checkField(fx-1, fy+1)) {
probs[fx][fy]++;
probs[fx-1][fy]++;
}
if (checkPic(fx+1, fy, "") && checkField(fx+1, fy-1) && checkField(fx+2, fy) && checkField(fx+1, fy+1)) {
probs[fx][fy]++;
probs[fx+1][fy]++;
}
break;
case 13:
if (checkPic(fx, fy-1, "") && checkPic(fx, fy-2, "") && checkField(fx-1, fy-1) && checkField(fx-1, fy-2) && checkField(fx, fy-3) && checkField(fx+1, fy-2) && checkField(fx+1, fy-1)) {
probs[fx][fy]++;
probs[fx][fy-1]++;
probs[fx][fy-2]++;
}
if (checkPic(fx, fy+1, "") && checkPic(fx, fy+2, "") && checkField(fx+1, fy+1) && checkField(fx+1, fy+2) && checkField(fx, fy+3) && checkField(fx-1, fy+2) && checkField(fx-1, fy+1)) {
probs[fx][fy]++;
probs[fx][fy+1]++;
probs[fx][fy+2]++;
}
if (checkPic(fx-1, fy, "") && checkPic(fx-2, fy, "") && checkField(fx-1, fy+1) && checkField(fx-2, fy+1) && checkField(fx-3, fy) && checkField(fx-2, fy-1) && checkField(fx-1, fy-1)) {
probs[fx][fy]++;
probs[fx-1][fy]++;
probs[fx-2][fy]++;
}
if (checkPic(fx+1, fy, "") && checkPic(fx+2, fy, "") && checkField(fx+1, fy-1) && checkField(fx+2, fy-1) && checkField(fx+3, fy) && checkField(fx+2, fy+1) && checkField(fx+1, fy+1)) {
probs[fx][fy]++;
probs[fx+1][fy]++;
probs[fx+2][fy]++;
}
if (checkPic(fx, fy-1, "") && checkPic(fx, fy+1, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+1, fy-1) && checkField(fx-1, fy+1) && checkField(fx, fy+2) && checkField(fx+1, fy+1)) {
probs[fx][fy]++;
probs[fx][fy-1]++;
probs[fx][fy+1]++;
}
if (checkPic(fx-1, fy, "") && checkPic(fx+1, fy, "") && checkField(fx-1, fy-1) && checkField(fx-2, fy) && checkField(fx-1, fy+1) && checkField(fx+1, fy+1) && checkField(fx+2, fy) && checkField(fx+1, fy-1)) {
probs[fx][fy]++;
probs[fx-1][fy]++;
probs[fx+1][fy]++;
}
break;
case 14:
break;
case 22:
if (checkPic(fx-1, fy, "") && checkPic(fx-1, fy-1, "") && checkPic(fx, fy-1, "") && checkField(fx-1, fy+1) && checkField(fx-2, fy) && checkField(fx-2, fy-1) && checkField(fx-1, fy-2) && checkField(fx, fy-2) && checkField(fx+1, fy-1)) {
probs[fx][fy]++;
probs[fx][fy-1]++;
probs[fx-1][fy]++;
probs[fx-1][fy-1]++;
}
if (checkPic(fx, fy-1, "") && checkPic(fx+1, fy-1, "") && checkPic(fx+1, fy, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+1, fy-2) && checkField(fx+2, fy-1) && checkField(fx+2, fy) && checkField(fx+1, fy+1)) {
probs[fx][fy]++;
probs[fx][fy-1]++;
probs[fx+1][fy-1]++;
probs[fx+1][fy]++;
}
if (checkPic(fx-1, fy, "") && checkPic(fx-1, fy+1, "") && checkPic(fx, fy+1, "") && checkField(fx-1, fy-1) && checkField(fx-2, fy) && checkField(fx-2, fy+1) && checkField(fx-1, fy+2) && checkField(fx, fy+2) && checkField(fx+1, fy+1)) {
probs[fx][fy]++;
probs[fx][fy+1]++;
probs[fx-1][fy]++;
probs[fx-1][fy+1]++;
}
if (checkPic(fx+1, fy, "") && checkPic(fx+1, fy+1, "") && checkPic(fx, fy+1, "") && checkField(fx+1, fy-1) && checkField(fx+2, fy) && checkField(fx+2, fy+1) && checkField(fx+1, fy+2) && checkField(fx, fy+2) && checkField(fx-1, fy+1)) {
probs[fx][fy]++;
probs[fx][fy+1]++;
probs[fx+1][fy+1]++;
probs[fx+1][fy]++;
}
break;
default:
break;
}
}
}
fy++;
if (fy == y) {
fy = 0;
fx++;
}
}
var high = 0;
for (var i = 0; i < x; i++)
for (var j = 0; j < y; j++)
if (probs[i][j] > high)
high = probs[i][j];
var highfields = new Array();
fx = 0;
fy = 0;
for (var i = 2; i < fields.length; i += 2) {
if (probs[fx][fy] == high)
highfields.push(i);
fy++;
if (fy == y) {
fy = 0;
fx++;
}
}
newField = highfields[Math.floor(Math.random() * highfields.length)];
}
while (newField == 0) {
var rnd = Math.floor(Math.random() * fieldanz);
field = (rnd+1)*2;
var pic = fields[field].style.background;
if (pic != "")
continue;
var fx = Math.floor((field-2)/y/2);
var fy = (field - fx*2*y - 2)/2;
/*if (forms.indexOf(22) != -1) {
if (fx == 0 || fx == x-1 || fy == 0 || fy == y-1)
continue;
if (checkPic(fx-1, fy, "") && checkPic(fx-1, fy-1, "") && checkPic(fx, fy-1, "") && checkField(fx-2, fy, "") && checkField(fx-2, fy-1, "") && checkField(fx-1, fy-2, "") && checkField(fx, fy-2) && checkField(fx+1, fy-1, "") && checkField(fx+1, fy, "") && checkField(fx, fy+1, "") && checkField(fx-1, fy+1, "") ||
checkPic(fx, fy-1, "") && checkPic(fx+1, fy-1, "") && checkPic(fx+1, fy, "") && checkField(fx, fy-2, "") && checkField(fx+1, fy-2, "") && checkField(fx+2, fy-1, "") && checkField(fx+2, fy) && checkField(fx+1, fy+1, "") && checkField(fx, fy+1, "") && checkField(fx-1, fy, "") && checkField(fx-1, fy-1, "") ||
checkPic(fx+1, fy, "") && checkPic(fx+1, fy+1, "") && checkPic(fx, fy+1, "") && checkField(fx, fy-1, "") && checkField(fx+1, fy-1, "") && checkField(fx+2, fy, "") && checkField(fx+2, fy+1) && checkField(fx+1, fy+2, "") && checkField(fx, fy+2, "") && checkField(fx-1, fy+1, "") && checkField(fx-1, fy, "") ||
checkPic(fx, fy+1, "") && checkPic(fx-1, fy+1, "") && checkPic(fx-1, fy, "") && checkField(fx, fy-2, "") && checkField(fx+1, fy, "") && checkField(fx+1, fy+1, "") && checkField(fx, fy+2) && checkField(fx-1, fy+2, "") && checkField(fx-2, fy+1, "") && checkField(fx-2, fy, "") && checkField(fx-1, fy-1, ""))
newField = field;
}*/
if (checkField(fx-1, fy, "") && checkField(fx, fy-1, "") && checkField(fx+1, fy, "") && checkField(fx, fy+1, ""))
newField = field;
}
fields[newField].click();
return 2000;
}
// ***********************************************************************************************
// ***********************************************************************************************
// play the new minigame
// ***********************************************************************************************
// ***********************************************************************************************
function DoNewMinigame (mode) {
var today = new Date();
var tagesdatum = FormatDate(today);
if (mode == 1) {
var tbl = document.getElementById("display").getElementsByClassName("cbox")[0];
var game = "roulette_";
var className = "chamber";
}
else if (mode == 2) {
var tbl = document.getElementById("display").getElementsByTagName("div")[0];
if (tbl.innerHTML.indexOf("icon_freispiel") == -1) {
PGu_setValue("slipgame_date", tagesdatum);
if (today.getHours() > 12)
PGu_setValue("slipgame_noon", tagesdatum);
if (today.getHours() < 12)
var to = 43500;
else
var to = 86400;
to = (to - today.getHours()*3600-today.getMinutes()*60-today.getSeconds()) * 1000 + today.getTime();
PGu_setValue("slipgame_wait", to.toString());
return -1;
}
var game = "slipgame_";
var className = "field";
}
else if (mode == 3) {
var buttons = document.getElementById("display").getElementsByClassName("button_container")[0];
if (buttons) {
var div = buttons.getElementsByTagName("div")[1];
if (div.innerHTML.indexOf("Würfeln") != -1)
buttons.click();
else if (div.innerHTML.indexOf("KK") != -1) {
PGu_setValue("icecubegame", tagesdatum);
PGu_setValue("dispshow_date", tagesdatum);
return 2000;
}
else {
var results = document.getElementById("display").getElementsByClassName("die_results")[0].getElementsByClassName("dice");
var saved = document.getElementById("display").getElementsByClassName("die_results_saved")[0].getElementsByTagName("div");
if (saved.length + results.length < 6)
return 2000;
var high = 0;
var draw = 0;
var nmbr = -1;
for (var i = 0; i < results.length; i++) {
var dice = results[i].style.backgroundImage;
if (dice == "")
continue;
dice = dice.split("/").pop().split(".")[0].split("_")[1];
if (PGu_getValue("icecubekeep"+dice, dice == 6)) {
results[i].click();
draw++;
break;
}
else if (dice > high) {
high = dice;
nmbr = i;
}
}
if (draw == 0 && nmbr >= 0 && div.className.indexOf("disabled") != -1)
results[nmbr].click();
else if (draw == 0 && div.className.indexOf("disabled") == -1)
buttons.click();
}
}
return 2000;
}
else
return 0;
if (tbl.innerHTML.indexOf(game) != -1) {
var chamber = tbl.getElementsByClassName(className);
if (chamber.length > (game == "roulette_"?1:0)) {
var rnd = Math.floor(Math.random()* chamber.length);
chamber[rnd].click();
return 2000;
}
}
if (tbl.innerHTML.indexOf("_success.png") != -1 || tbl.innerHTML.indexOf("minigame_count") == -1 || tbl.innerHTML.indexOf("roulette_") != -1) {
PGu_setValue("minigame_success", 1);
PGu_setValue("minigame_date", tagesdatum);
if (today.getHours() > 12)
PGu_setValue("minigame_noon", tagesdatum);
if (today.getHours() < 12)
var to = 43500;
else
var to = 86400;
to = (to - today.getHours()*3600-today.getMinutes()*60-today.getSeconds()) * 1000 + today.getTime();
PGu_setValue("minigame_wait", to.toString());
return to - today.getTime();
}
var trs = tbl.getElementsByTagName("tr");
for (var j = 0; j < trs.length; j++)
if (trs[j].innerHTML.indexOf("minigame_count") != -1)
break;
if (j == trs.length)
return 0;
var pos = trs[j].innerHTML.indexOf("minigame_count");
PGu_setValue("minigame_date", tagesdatum);
if (today.getHours() > 12)
PGu_setValue("minigame_noon", tagesdatum);
if (trs[j].innerHTML.indexOf("minigame_countdown") != -1) {
var span = trs[j].getElementsByTagName("span");
var seks = 0;
if (span.length > 0)
for (var jj = 0; jj < 1; jj++) {
var timer = span[jj].innerHTML;
if (timer == done) {
seks = 0;
}
else if (timer.indexOf(":") != -1) {
var time = timer.split(":");
seks = (parseInt(time[0])*60 + parseInt(time[1])) * 1000;
}
}
if (seks == 0) {
unsafeWindow.minigame_show();
seks = 2000;
}
var time = Number(new Date().getTime()) + seks;
PGu_setValue("minigame_wait", String(time));
return seks;
}
if (trs[j].style.background.indexOf("_success.png") != -1 || trs[j].style.background.indexOf("_unsuccess.png") != -1 || trs[j].style.background.indexOf("_normal.png") != -1 ||
trs[j].style.background.indexOf("_success.jpg") != -1 || trs[j].style.background.indexOf("_unsuccess.jpg") != -1 || trs[j].style.background.indexOf("_normal.jpg") != -1) {
var success = PGu_getValue("minigame_success", 0);
if (success == 1) {
if (trs[j].style.background.indexOf("_success.png") == -1 ||
trs[j].innerHTML.indexOf("minigame_count") != -1) {
PGu_setValue("minigame_value", -1);
PGu_setValue("minigame_success", 0);
success = 0;
}
else
return (86400-today.getHours()*3600-today.getMinutes()*60-today.getSeconds()) * 1000;
}
if (success == 0) {
if (trs[j].style.background.indexOf("_success.png") != -1 || trs[j].innerHTML.indexOf("minigame_count") == -1) {
PGu_setValue("minigame_success", 1);
PGu_setValue("minigame_date", tagesdatum);
PGu_setValue("minigame_noon", tagesdatum);
return (86400-today.getHours()*3600-today.getMinutes()*60-today.getSeconds()) * 1000;
}
else {
var nextValue = PGu_getValue("minigame_value", -1) + 1;
var plnd = trs[j].innerHTML.substr(pos).match(/<img.*src=".*"/);
if (!plnd || plnd.length == 0) {
var sub = trs[j].innerHTML.split("minigame_try('")[1].split("'")[0];
unsafeWindow.minigame_try(sub);
return 2000;
}
var plndanz = PGu_getValue("minigame_plunderanz", -1);
if (plndanz == -1) {
PGu_setValue("minigame_plunderanz", 0);
plnd = plnd[0].split('src="')[1].split('"')[0];
var pltab = 6;
if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" ||TOWNEXTENSION == "MU")
var pltab = 1;
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
var content = responseDetails.responseText;
PGu_setValue("minigame_plunderreq", String(today.getTime()+300000));
var Plnd = content.split(decodeURI(plnd));
if (Plnd.length < 2)
return;
var plndanz = Plnd[1].split("<td")[1].split("<span")[1].split(">")[1].split("<")[0];
plndanz = Number(plndanz.split("x ")[1].trim());
if (plndanz < nextValue%10+1) {
PGu_setValue("minigame_plunderanz", plndanz);
return;
}
PGu_setValue("minigame_value", nextValue);
PGu_setValue("minigame_plunderanz", plndanz - (nextValue%10+1));
document.getElementById("minigame_count").innerHTML = nextValue%10+1;
var sub = trs[j].innerHTML.split("minigame_try('")[1].split("'")[0];
unsafeWindow.minigame_try(sub);
}});
return 0;
}
if (plndanz < nextValue%10+1)
return 300000;
PGu_setValue("minigame_value", nextValue);
PGu_setValue("minigame_plunderanz", plndanz - (nextValue%10+1));
document.getElementById("minigame_count").innerHTML = nextValue%10+1;
var sub = trs[j].innerHTML.split("minigame_try('")[1].split("'")[0];
unsafeWindow.minigame_try(sub);
}
}
}
return 2000;
}
// ***********************************************************************************************
// ***********************************************************************************************
// check for minigame and play it
// ***********************************************************************************************
// ***********************************************************************************************
function CheckMinigame () {
if (window.location.pathname.indexOf("/activities/") == -1)
return;
var minigames = new Array("halloween", "summer13", "event/aug13_2");
var tbl = document.getElementsByTagName("table");
for (var i = 0; i < tbl.length; i++) {
for (var tk = 0; tk < minigames.length; tk++)
if (tbl[i].innerHTML.indexOf("/" + minigames[tk] + "/") != -1)
break;
var trs = tbl[i].getElementsByTagName("tr");
for (var j = 0; j < trs.length; j++) {
for (var k = 0; k < minigames.length; k++)
if (trs[j].innerHTML.indexOf("/" + minigames[k] + "/") != -1)
break;
if (tk < minigames.length || k < minigames.length) {
var seks = 0;
if (j + 1 < trs.length) {
var span = trs[j+1].getElementsByTagName("span");
if (span.length > 0)
for (var jj = 0; jj < 1; jj++) {
var timer = span[jj].innerHTML;
if (timer == done) {
seks = 0;
}
else if (timer.indexOf(":") != -1) {
var time = timer.split(":");
seks = parseInt(time[0])*60 + parseInt(time[1]);
}
}
}
if (seks > 0) {
checkInt = window.setTimeout(CheckMinigame,seks*1000);
return;
}
else if (trs[j].style.background.indexOf("/success.jpg") != -1 || trs[j].style.background.indexOf("/fail.jpg") != -1 || trs[j].style.background.indexOf("/normal.jpg") != -1) {
var success = PGu_getValue("minigame_success", 0);
if (success == 1) {
if (trs[j].style.background.indexOf("/success.jpg") == -1) {
PGu_setValue("minigame_value", -1);
PGu_setValue("minigame_success", 0);
success = 0;
}
else
checkInt = window.setTimeout(reload, 300000, "CheckMinigame1");
}
if (success == 0) {
if (trs[j].style.background.indexOf("/success.jpg") != -1) {
PGu_setValue("minigame_success", 1);
}
else {
var options = trs[j].innerHTML.split('<option');
if (options.length == 1) {
reload("CheckMinigame2");
break;
}
var nextValue = PGu_getValue("minigame_value", -1) + 1;
var nextVal = nextValue % (options.length-1);
nextVal = options[nextVal+1].split('<')[0];
if (nextVal.substr(0,6) == " value") {
nextVal = nextVal.split('"')[1];
}
else
nextVal = nextVal.substr(1);
GM_xmlhttpRequest({
method:"POST",
url: 'http://' + window.location.host + '/' + minigames[k] + '/minigame/',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('minigame_count='+nextVal),
onload:function(responseDetails) {
var pos = responseDetails.responseText.indexOf('/fail.jpg');
if (pos == -1) {
window.location.href = window.location.protocol + '//' + window.location.host + '/activities/';
}
else {
PGu_setValue("minigame_value", nextValue);
window.location.href = window.location.protocol + '//' + window.location.host + '/activities/';
}
}});
}
}
break;
}
else if (k < minigames.length) {
window.location.href = window.location.protocol + '//' + window.location.host + '/' + minigames[k] + '/minigame/';
}
}
else if (trs[j].style.background.search(/\/xmas.*\/minigame/) != -1) {
var seks = 0;
if (j + 1 < trs.length) {
var span = trs[j+1].getElementsByTagName("span");
for (var jj = 0; jj < 1; jj++) {
var timer = span[jj].innerHTML;
if (timer == done) {
seks = 0;
}
else {
var time = timer.split(":");
seks = parseInt(time[0])*60 + parseInt(time[1]);
}
}
}
if (seks > 0) {
checkInt = window.setTimeout(reload, seks*1000, "CheckMinigame3");
return;
}
else {
var success = PGu_getValue("XmasMini_success", 0);
if (success == 1) {
if (trs[j].style.background.indexOf("minigame_success") == -1) {
PGu_setValue("XmasMini_value", -1);
PGu_setValue("XmasMini_success", 0);
success = 0;
}
else
checkInt = window.setTimeout(reload, 600000, "CheckMinigame4");
}
if (success == 0) {
if (trs[j].style.background.indexOf("minigame_success") != -1) {
PGu_setValue("XmasMini_value", -1);
PGu_setValue("XmasMini_success", 1);
checkInt = window.setTimeout(reload, 600000, "CheckMinigame5");
}
else {
var options = trs[j].innerHTML.split('<option');
if (options.length == 1) {
reload("CheckMinigame6");
break;
}
var nextValue = PGu_getValue("XmasMini_value", -1) + 1;
var nextVal = nextValue % (options.length-1);
nextVal = options[nextVal+1].split('<')[0];
if (nextVal.substr(0,6) == " value") {
nextVal = nextVal.split('"')[1];
}
else
nextVal = nextVal.substr(1);
var action = trs[j].innerHTML.match(/<form.*action=\"[^\"]*\"/)[0].split('"')[1];
GM_xmlhttpRequest({
method:"POST",
url: 'http://' + window.location.host + action,
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('minigame_count='+nextVal),
onload:function(responseDetails) {
var pos = responseDetails.finalUrl.indexOf('event=');
if (pos == -1) {
window.location.href = window.location.protocol + '//' + window.location.host + '/activities/';
}
else {
var rc = parseInt(responseDetails.finalUrl.substr(pos+6));
if (rc == -2)
alert('Bitte Glühwein kaufen !!');
else {
PGu_setValue("XmasMini_value", nextValue);
PGu_setValue("XmasMini_success", (rc==1?1:0));
window.location.href = responseDetails.finalUrl;
}
}
}});
}
}
}
break;
}
else if (trs[j].style.background.indexOf("/events/") != -1) {
//alert(trs[j].style.background);
var eventpos = trs[j].innerHTML.indexOf('/event/');
var eventurl = "";
minigames = new Array("easter14", "summer14", "krnvl");
var multiple = 0;
for (var k = 0; k < minigames.length; k++)
if (tbl[i].innerHTML.indexOf("/" + minigames[k] + "/") != -1)
break;
var dk = (tbl[i].innerHTML.indexOf('span id="counter') != -1?1:2);
if (eventpos != -1) {
var eventposend = trs[j].innerHTML.indexOf('"', eventpos);
eventurl = trs[j].innerHTML.substr(eventpos, eventposend - eventpos);
if (trs[j].innerHTML.substr(eventpos-8,6) == "action") {
var form = trs[j].getElementsByTagName("form")[0].innerHTML;
var inputs = form.split("<input");
var input = "";
for (var ii = 1; ii < inputs.length; ii++) {
var name = inputs[ii].split('name="');
if (name.length > 1)
name = name[1].split('"')[0];
else
continue;
var value = inputs[ii].split('value="');
if (value.length > 1)
value = value[1].split('"')[0];
else
continue;
if (input != "")
input += "&";
input += name + "=" + value;
}
if (k < minigames.length) {
var seks = 0;
dk = 1;
if (j + 1 < trs.length) {
var span = trs[j+1].getElementsByTagName("span");
if (span.length > 0)
for (var jj = 0; jj < 1; jj++) {
var timer = span[jj].innerHTML;
if (timer == done) {
seks = 0;
}
else if (timer.indexOf(":") != -1) {
var time = timer.split(":");
seks = parseInt(time[0])*60 + parseInt(time[1]);
}
}
}
if (seks > 0) {
checkInt = window.setTimeout(CheckMinigame,seks*1000);
return;
}
else if (trs[j].style.background.indexOf("success.jpg") != -1 || trs[j].style.background.indexOf("unsuccess.jpg") != -1 || trs[j].style.background.indexOf("normal.jpg") != -1) {
var success = PGu_getValue("minigame_success", 0);
if (success == 1) {
if (trs[j].style.background.indexOf("success.jpg") == -1) {
PGu_setValue("minigame_value", -1);
PGu_setValue("minigame_success", 0);
success = 0;
}
else
checkInt = window.setTimeout(reload, 300000, "CheckMinigame7");
}
if (success == 0) {
if (trs[j].style.background.indexOf("success.jpg") != -1) {
PGu_setValue("minigame_success", 1);
}
else {
var options = trs[j].innerHTML.split('<option');
if (options.length != 1) {
var nextValue = PGu_getValue("minigame_value", -1) + 1;
var nextVal = nextValue % (options.length-1);
nextVal = options[nextVal+1].split('<')[0];
if (nextVal.substr(0,6) == " value") {
nextVal = nextVal.split('"')[1];
}
else
nextVal = nextVal.substr(1);
if (input != "")
input += "&";
input += 'minigame_count='+nextVal;
multiple = 1;
}
}
}
}
else if (k < minigames.length) {
window.location.href = window.location.protocol + '//' + window.location.host + '/' + minigames[k] + '/minigame/';
}
}
GM_xmlhttpRequest({
method:"POST",
url: 'http://' + window.location.host + eventurl,
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI(input),
onload:function(responseDetails) {
if (multiple == 1)
PGu_setValue("minigame_value", nextValue);
var pos = responseDetails.finalUrl.indexOf('event=');
if (pos == -1 || !multiple) {
window.location.href = window.location.protocol + '//' + window.location.host + '/activities/';
}
else {
var rc = parseInt(responseDetails.finalUrl.substr(pos+6));
PGu_setValue("minigame_success", (rc==1?1:0));
window.location.href = responseDetails.finalUrl;
}
}
});
}
else if (eventurl.indexOf("mayevent") == -1) {
window.location.href = window.location.protocol + '//' + window.location.host + eventurl;
GM_setValue(TOWNEXTENSION + "eventURL", eventurl);
}
break;
}
if (j + dk < trs.length) {
var seks = 0;
var span = trs[j+dk].getElementsByTagName("span");
for (var jj = 0; jj < 1; jj++) {
var timer = span[jj].innerHTML;
if (timer == done) {
seks = 0;
}
else {
var time = timer.split(":");
seks = parseInt(time[0])*60 + parseInt(time[1]);
}
}
if (seks > 0) {
checkInt = window.setTimeout(reload, seks*1000, "CheckMinigame8");
return;
}
else {
var eventurl = PG_getValue(TOWNEXTENSION + "eventURL", "");
if (eventurl != "")
window.location.href = window.location.protocol + '//' + window.location.host + eventurl;
}
}
break;
}
}
}
}
function insertCheckBox() {
var newtd = document.createElement("td");
newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtd.innerHTML = '<input name="BCCheckbox" id="BCCheckbox" type="checkbox"><span style="vertical-align: bottom"> Automatisch sammeln</span>';
document.getElementsByName("xycoords")[0].parentNode.insertBefore(newtd, document.getElementsByName("xycoords")[0]);
document.getElementById("BCCheckbox").checked = PGu_getValue("AutoCollect", false);
// Click-Handler hinzufügen
document.getElementById("BCCheckbox").addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue("AutoCollect", this.checked);
if (this.checked) {
var timeOptions = document.getElementsByName("time")[0];
PGu_setValue(nameLastCollectTime, timeOptions.selectedIndex);
}
}, false);
}
function insertCheckBox2() {
var newtd = document.createElement("td");
newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
var male = "";
if (PGu_getValue("AutoCrime", false))
male = " (noch " + PGu_getValue("AutoCrimeFkt", 0) + " Mal)";
newtd.innerHTML = '<input name="SCCheckbox" id="SCCheckbox" type="checkbox"><span style="vertical-align: bottom"> Automatisch starten' + male + '</span>';
var buttons = document.getElementsByTagName("button");
if (buttons.length > 0)
var button = buttons[0];
else {
buttons = document.getElementsByName("xycoords");
var button = buttons[buttons.length-1];
}
button.parentNode.insertBefore(newtd, button);
document.getElementById("SCCheckbox").checked = PGu_getValue("AutoCrime", false);
// Click-Handler hinzufügen
document.getElementById("SCCheckbox").addEventListener("click", function(event) {
// Klickstatus speichern
if (this.checked) {
if (PGu_getValue("AutoCrimePic", "") == "") {
if (TOWNEXTENSION == "VT")
alert("Bitte erst Sünde festlegen !!");
else
alert("Bitte erst Verbrechen festlegen !!");
this.checked = false;
}
if (PGu_getValue("AutoCrimeFkt", -1) <= 0)
PGu_setValue("AutoCrimeFkt", 1);
}
PGu_setValue("AutoCrime", this.checked);
reload("insertCheckBox2");
}, false);
}
function insertCheckBox3(button) {
var crimepic = button.parentNode.parentNode.innerHTML.split('plunder_crime/')[1].split('"')[0];
var name = 'CbButton_' + crimepic;
var newtd = document.createElement("td");
newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtd.innerHTML = '<input name="CbCrime" id="' + name +'" type="checkbox"><span style="vertical-align: bottom"> diese' + (TOWNEXTENSION=="VT"?" Sünde":"s Verbrechen") + ' </span><input name="CbCrimeFkt" style="width:30px" id="' + name +'Fkt"><span style="vertical-align: bottom">mal automatisch starten</span>';
button.parentNode.appendChild(newtd, button);
var crimep = PGu_getValue("AutoCrimePic", "");
if (crimep == crimepic) {
document.getElementById(name).checked = true;
document.getElementById(name+"Fkt").value=PGu_getValue("AutoCrimeFkt",1);
}
// Click-Handler hinzufügen
document.getElementById(name+"Fkt").addEventListener("change", function(event) {
var crimeFkt = parseInt(document.getElementById(this.id).value);
if (isNaN(crimeFkt))
crimeFkt = 1;
document.getElementById(this.id).value = crimeFkt;
PGu_setValue("AutoCrimeFkt", crimeFkt);
}, false);
// Click-Handler hinzufügen
document.getElementById(name).addEventListener("click", function(event) {
var crimepic = this.id.split("_")[1];
crimepic = this.parentNode.parentNode.parentNode.innerHTML.split('plunder_crime/')[1].split('"')[0];
if (this.parentNode.parentNode.innerHTML.split("start_crime(").length > 1)
var crimeNr = this.parentNode.parentNode.innerHTML.split("start_crime(")[1].split(")")[0];
else
var crimeNr = 0;
// Klickstatus speichern
if (this.checked) {
PGu_setValue("AutoCrime", true);
PGu_setValue("AutoCrimePic", crimepic);
PGu_setValue("AutoCrimeNr", crimeNr);
var crimeFkt = parseInt(document.getElementById(this.id+"Fkt").value);
if (isNaN(crimeFkt) || crimeFkt <= 0)
crimeFkt = 1;
document.getElementById(this.id+"Fkt").value = crimeFkt;
PGu_setValue("AutoCrimeFkt", crimeFkt);
var buttons = document.getElementsByName("CbCrime");
for (var i = 0; i < buttons.length; i++) {
var crimep = buttons[i].parentNode.parentNode.parentNode.innerHTML.split('plunder_crime/')[1].split('"')[0];
if (crimepic != crimep) {
document.getElementById(buttons[i].id).checked = false;
document.getElementById(buttons[i].id+"Fkt").value = "";
}
}
}
else {
PGu_setValue("AutoCrimePic", "");
PGu_setValue("AutoCrimeNr", 0);
PGu_setValue("AutoCrimeFkt", 0);
PGu_setValue("AutoCrime", false);
}
}, false);
}
function insertCheckBox4() {
var newtd = document.createElement("li");
newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtd.innerHTML = '<input name="GSCheckbox" id="GSCheckbox" type="checkbox"><span style="vertical-align: bottom"> Geld automatisch einsacken</span>';
var tieritems = document.getElementsByClassName("tieritemA");
for (var i = 0; i < tieritems.length; i++) {
if (tieritems[i].innerHTML.indexOf("minijobs") != -1 || tieritems[i].innerHTML.indexOf("change_please") != -1) {
var lis = tieritems[i].getElementsByClassName("double");
if (lis.length == 0)
lis = tieritems[i].getElementsByClassName("first");
lis = lis[lis.length-1].getElementsByTagName("li");
lis[lis.length-1].parentNode.appendChild(newtd, lis[lis.length-1]);
document.getElementById("GSCheckbox").checked = PGu_getValue("getSalary", false);
// Click-Handler hinzufügen
document.getElementById("GSCheckbox").addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue("getSalary", this.checked);
}, false);
}
}
}
function selectcraft(i, craftlist, usedPlunder, tr) {
function handleClick(id, value) {
// neuen Wert speichern
var craftnr = id.replace("craftid", "");
if (value == "0")
usedPlunder.splice(craftnr, 1);
else {
usedPlunder[craftnr] = value;
PGu_setValue("craftindex", 0);
}
PGu_setValue("craftlist", usedPlunder.join(";"));
for (var i = 0; document.getElementById("craftid"+i); i++) {
if (i == usedPlunder.length - 1) {
if (document.getElementById("craftid"+(i+1)))
document.getElementById("craft"+(i+1)).parentNode.parentNode.style.visibility = "visible";
else {
var newtd = document.createElement("td");
newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
var newtr = document.createElement("tr");
var option = '<option value="0"> </option> ';
for (var j = 0; j < craftlist.length; j++) {
var pos = usedPlunder.indexOf(craftlist[j][1]);
if (pos == -1)
option += '<option value="' + craftlist[j][1] + '">' + craftlist[j][0] + '</option> ';
}
newtd.innerHTML = '<form name="craft' + (i+1) + '" id="craft' + (i+1) + '">wenn nicht möglich, dann: <select id="craftid' + (i+1) +'" name="craftid' + (i+1) + '"> ' + option + ' </select> </form>';
newtr.appendChild(newtd, newtr);
tr.parentNode.appendChild(newtr, tr);
// Click-Handler hinzufügen
document.getElementById("craftid"+(i+1)).addEventListener("change", function(event) {
handleClick(this.id, this.value);
}, false);
continue;
}
}
if (i > usedPlunder.length) {
document.getElementById("craft"+i).parentNode.parentNode.style.visibility = "hidden";
continue;
}
var option = '<option value="0"> </option> ';
for (var j = 0; j < craftlist.length; j++) {
var pos = usedPlunder.indexOf(craftlist[j][1]);
if (pos == -1 || pos == i)
option += '<option value="' + craftlist[j][1] + '">' + craftlist[j][0] + '</option> ';
}
document.getElementById("craftid"+i).innerHTML = option;
document.getElementById("craftid"+i).value = i < usedPlunder.length?usedPlunder[i]:"0";
}
}
var option = '<option value="0"> </option> ';
for (var j = 0; j < craftlist.length; j++) {
var pos = usedPlunder.indexOf(craftlist[j][1]);
if (pos == -1 || pos == i)
option += '<option value="' + craftlist[j][1] + '">' + craftlist[j][0] + '</option> ';
}
var newtd = document.createElement("td");
var newtr = document.createElement("tr");
newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
var pid = i < usedPlunder.length?usedPlunder[i]:"0";
newtd.innerHTML = '<form name="craft' + i + '" id="craft' + i + '">' + (i==0?"Plunder basteln":"wenn nicht möglich, dann") + ': <select id="craftid' + i +'" name="craftid' + i + '"> ' + option + ' </select> </form>';
newtr.appendChild(newtd, newtr);
tr.parentNode.appendChild(newtr, tr);
document.getElementById("craftid"+i).value = pid;
if (!PGu_getValue("autoDaily", false))
document.getElementById("craft"+i).parentNode.parentNode.style.visibility = "hidden";
else
document.getElementById("craft"+i).parentNode.parentNode.style.visibility = "visible";
// Click-Handler hinzufügen
document.getElementById("craftid"+i).addEventListener("change", function(event) {
handleClick(this.id, this.value);
}, false);
}
function getPlunderlist(k, pltab, allplunder, tr, mode, mincost)
{
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/plunder/ajax/?c='+k, onload:function(responseDetails) {
var content = responseDetails.responseText;
var trs = content.split("<tr ");
for (var i = 1; i < trs.length; i++) {
var plname = trs[i].split(">x ")[0].split("</strong")[0].split(">").pop().trim();
var plAnz = trs[i].split(">x ")[1].split("<")[0].trim();
var pid = trs[i].split('pm_')[1].split("'")[0].trim();
var cost = trs[i].split("show_multiple_sell")[1].split("<li>")[1].split("</li>")[0].split("(")[1].match(/ .*[\d.,]+/)[0].trim();
var cost2 = Number(cost.match(/[\d.,]+/)[0].replace(/[.,]/g, ""));
for (var j = 0; j < allplunder.length; j++)
if (allplunder[j][4] < cost2)
break;
allplunder.splice(j, 0, new Array(plname, plAnz, pid, cost, cost2));
}
if (k < pltab)
getPlunderlist(k+1, pltab, allplunder, tr, mode, mincost);
else {
var newtd = document.createElement("td");
var newtr = document.createElement("tr");
newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
var option = '<option value="0"> </option> ';
for (var i = 0; i < allplunder.length; i++)
if (allplunder[i][4] >= mincost)
option += '<option value="' + allplunder[i][2] + '">' + allplunder[i][0] + ' [x' + allplunder[i][1] + '] (' + allplunder[i][3] + ')</option> ';
pid = PGu_getValue("sellPlunder" + (mode==0?"":mode), 0);
var text = "Plunder verkaufen" + (mode==0?"":", wenn kein Geld mehr");
newtd.innerHTML = '<form name="plunderdef' + mode + '" id="plunderdef' + mode + '">' + text + ': <select id="pid' + mode + '" name="pid' + mode + '"> ' + option + ' </select> </form>';
newtr.appendChild(newtd, newtr);
tr.parentNode.appendChild(newtr, tr);
document.getElementById("pid" + mode).value = pid;
if (!PGu_getValue("autoDaily", false) && mode == 0)
document.getElementById("plunderdef"+mode).parentNode.parentNode.style.visibility = "hidden";
else
document.getElementById("plunderdef"+mode).parentNode.parentNode.style.visibility = "visible";
// Click-Handler hinzufügen
document.getElementById("pid"+mode).addEventListener("change", function(event) {
// neuen Wert speichern
PGu_setValue("sellPlunder"+(mode==0?"":mode), this.value);
}, false);
if (mode == 1) {
getPlunderlist(pltab+1, pltab, allplunder, tr, 0, 1);
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/friendlist/', onload:function(responseDetails) {
var content = responseDetails.responseText;
// Wenn die Seite abgerufen werden konnte (kein Seitenladefehler)
if (content.indexOf("<strong>Mein Penner</strong>") != -1) {
var friends = content.split('class="listshop"')[1].split("<table ")[1].split("</table")[0].split("/profil/id:");
var option = '<option value="0"> </option> ';
for (var i = 1; i < friends.length; i++) {
option += '<option value="' + friends[i].split("/")[0] + '">' + friends[i].split("<")[0].split(">")[1].trim() + '</option> ';
}
var newtd = document.createElement("td");
var newtr = document.createElement("tr");
newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
var friendid = PGu_getValue("friendid", "0");
newtd.innerHTML = '<form name="frienddef" id="frienddef">PN senden an: <select id="friendid" name="friendid"> ' + option + ' </select> </form>';
newtr.appendChild(newtd, newtr);
tr.parentNode.appendChild(newtr, tr);
document.getElementById("friendid").value = friendid;
if (!PGu_getValue("autoDaily", false))
document.getElementById("frienddef").parentNode.parentNode.style.visibility = "hidden";
else
document.getElementById("frienddef").parentNode.parentNode.style.visibility = "visible";
// Click-Handler hinzufügen
document.getElementById("friendid").addEventListener("change", function(event) {
// neuen Wert speichern
PGu_setValue("friendid", this.value);
}, false);
if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" || TOWNEXTENSION == "MU" ||
TOWNEXTENSION == "HR" || TOWNEXTENSION == "K") {
var newtd2 = document.createElement("td");
var newtr2 = document.createElement("tr");
newtd2.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtd2.innerHTML = '<input name="LoseKaufSofort" id="LoseKaufSofort" type="checkbox"><span style="vertical-align: bottom"> Lose ohne Rücksicht auf Casino-Besuch kaufen</span>';
newtr2.appendChild(newtd2, newtr2);
tr.parentNode.appendChild(newtr2, tr);
document.getElementById("LoseKaufSofort").checked = PGu_getValue("LoseKaufSofort", false);
if (!PGu_getValue("autoDaily", false))
document.getElementById("LoseKaufSofort").parentNode.parentNode.style.visibility = "hidden";
else
document.getElementById("LoseKaufSofort").parentNode.parentNode.style.visibility = "visible";
// Click-Handler hinzufügen
document.getElementById("LoseKaufSofort").addEventListener("change", function(event) {
// neuen Wert speichern
PGu_setValue("LoseKaufSofort", this.checked);
}, false);
}
else
PGu_setValue("LoseKaufSofort", true);
if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" || TOWNEXTENSION == "MU" ||
TOWNEXTENSION == "HR" || TOWNEXTENSION == "K") {
var newtd2 = document.createElement("td");
var newtr2 = document.createElement("tr");
newtd2.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
var donlink = PGu_getValue("donationlink", "");
newtd2.innerHTML = '<form>Spendenlink: <input style="color: black; background-color:white; width:300px" type="text" name="donlink" id="donlink"></form>';
newtr2.appendChild(newtd2, newtr2);
tr.parentNode.appendChild(newtr2, tr);
document.getElementById("donlink").value = donlink;
if (!PGu_getValue("autoDaily", false))
document.getElementById("donlink").parentNode.parentNode.style.visibility = "hidden";
else
document.getElementById("donlink").parentNode.parentNode.style.visibility = "visible";
// Click-Handler hinzufügen
document.getElementById("donlink").addEventListener("change", function(event) {
// neuen Wert speichern
PGu_setValue("donationlink", this.value);
PGu_setValue("donationdate", "");
}, false);
}
}
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/plunder/craftlist/', onload:function(responseDetails) {
var table = responseDetails.responseText.split("<table").pop().split("</table")[0];
var trs = table.split("<tr");
var craftlist = new Array();
for (var i = 1; i < trs.length; i++) {
if (trs[i].indexOf('href="/stock/plunder/craft/details/') == -1)
continue;
var details = trs[i].split('href="/stock/plunder/craft/details/')[1];
if (details.indexOf("disabled") != -1)
continue;
var pid = details.split("/")[0];
var plunder = details.split("</strong")[0].split(">").pop();
craftlist.push(new Array(plunder, pid));
}
var usedPlunder = PGu_getValue("craftlist", "").split(";");
for (var i = 0; i <= usedPlunder.length; i++)
var pid = selectcraft(i, craftlist, usedPlunder, tr);
}});
}});
}
}
}});
}
function insertCheckBox5() {
if (TOWNEXTENSION != "HH" && TOWNEXTENSION != "B" && TOWNEXTENSION != "MU" &&
TOWNEXTENSION != "HR" && TOWNEXTENSION != "K" && TOWNEXTENSION != "SY" &&
TOWNEXTENSION != "ML" && TOWNEXTENSION != "VT")
return;
var newtd = document.createElement("td");
var newtr = document.createElement("tr");
newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtd.innerHTML = '<input name="DTCheckbox" id="DTCheckbox" type="checkbox"><span style="vertical-align: bottom"> Tagesaufgabe automatisch lösen</span>';
newtr.appendChild(newtd, newtr);
var tr = document.getElementsByTagName("table")[0].getElementsByTagName("tr")[2];
tr.parentNode.appendChild(newtr, tr);
var pltab = 6;
if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" || TOWNEXTENSION == "MU")
pltab = 3;
var allplunder = new Array();
getPlunderlist(1, pltab, allplunder, tr, 1, (TOWNEXTENSION == "VT"?100:2500));
document.getElementById("DTCheckbox").checked = PGu_getValue("autoDaily", false);
// Click-Handler hinzufügen
document.getElementById("DTCheckbox").addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue("autoDaily", this.checked);
if (!this.checked) {
document.getElementById("plunderdef0").parentNode.parentNode.style.visibility = "hidden";
document.getElementById("plunderdef1").parentNode.parentNode.style.visibility = "hidden";
document.getElementById("frienddef").parentNode.parentNode.style.visibility = "hidden";
if (document.getElementById("donlink"))
document.getElementById("donlink").parentNode.parentNode.style.visibility = "hidden";
if (document.getElementById("LoseKaufSofort"))
document.getElementById("LoseKaufSofort").parentNode.parentNode.style.visibility = "hidden";
for (var i = 0; true; i++)
if (document.getElementById("craft"+i))
document.getElementById("craft"+i).parentNode.parentNode.style.visibility = "hidden";
else
break;
}
else {
document.getElementById("plunderdef0").parentNode.parentNode.style.visibility = "visible";
document.getElementById("plunderdef1").parentNode.parentNode.style.visibility = "visible";
document.getElementById("frienddef").parentNode.parentNode.style.visibility = "visible";
if (document.getElementById("donlink"))
document.getElementById("donlink").parentNode.parentNode.style.visibility = "visible";
if (document.getElementById("LoseKaufSofort"))
document.getElementById("LoseKaufSofort").parentNode.parentNode.style.visibility = "visible";
for (var i = 0; true; i++)
if (document.getElementById("craft"+i))
document.getElementById("craft"+i).parentNode.parentNode.style.visibility = "visible";
else
break;
}
}, false);
}
function insertCheckBox6() {
var noMissCtrl = (document.getElementById("content").innerHTML.indexOf('onclick="show_city_list') == -1);
//if (noMissCtrl)
return;
var tables = document.getElementsByTagName("table");
var missions = new Array();
var boosts = new Array();
var plunder = new Array();
for (var i = 0; i < tables.length; i++) {
var mission = tables[i].getElementsByClassName("gang_mission")[0].style.backgroundImage.split(/[()]/)[1].split("/").pop().split(".")[0];
missions[i] = mission;
var tr = tables[i].getElementsByTagName("tr")[1];
var div = tr.getElementsByTagName("div");
if (!noMissCtrl) {
var newtd = document.createElement("td");
newtd.setAttribute('style', 'padding-top: 10px');
newtd.innerHTML = '<input name="MissCheckbox'+i+'" id="MissCheckbox'+i+'" type="checkbox"><span style="vertical-align: bottom"> Diese Mission automatisch starten</span>';
div[div.length-1].appendChild(newtd, div);
document.getElementById("MissCheckbox"+i).checked = PGu_getValue(mission+"Auto", false);
// Click-Handler hinzufügen
document.getElementById("MissCheckbox"+i).addEventListener("click", function(event) {
// Klickstatus speichern
var indx = this.id.substr(-1);
PGu_setValue(missions[indx]+"Auto", this.checked);
}, false);
var newbr = document.createElement("br");
div[div.length-1].appendChild(newbr, div);
var newtd2 = document.createElement("td");
newtd2.innerHTML = '<input name="RewardChb'+i+'" id="RewardChb'+i+'" type="checkbox" style="vertical-align:bottom"><span style="vertical-align: bottom"> Belohnung automatisch abholen</span>';
div[div.length-1].appendChild(newtd2, div);
document.getElementById("RewardChb"+i).checked = PGu_getValue(mission+"Rwd", false);
// Click-Handler hinzufügen
document.getElementById("RewardChb"+i).addEventListener("click", function(event) {
// Klickstatus speichern
var indx = this.id.substr(-1);
PGu_setValue(missions[indx]+"Rwd", this.checked);
}, false);
}
if (!noMissCtrl)
if (mission == "kieztour" || mission == "davinci_code" || mission == "schrottplatz" || mission == "kreuzzug") {
var newbr = document.createElement("br");
div[div.length-1].appendChild(newbr, div);
var newtd2 = document.createElement("td");
newtd2.innerHTML = '<input name="TimeCheckbox'+i+'" id="TimeCheckbox'+i+'" type="checkbox" style="vertical-align:bottom"><span style="vertical-align: bottom"> Diese Mission nur starten, wenn noch mindestens </span><input name="MissTime'+i+'" id="MissTime'+i+'" type="text" style="width:30px;color:black;background-color:white" value=""><span style="vertical-align: bottom"> Minuten bis zur nächsten Mission</span>';
div[div.length-1].appendChild(newtd2, div);
document.getElementById("MissTime"+i).value = PGu_getValue(mission+"Time", "");
document.getElementById("TimeCheckbox"+i).checked = PGu_getValue(missions[i]+"MissT", false);
// Click-Handler hinzufügen
document.getElementById("TimeCheckbox"+i).addEventListener("click", function(event) {
// Klickstatus speichern
var indx = this.id.substr(-1);
PGu_setValue(missions[indx]+"MissT", this.checked);
}, false);
// Change-Handler hinzufügen
document.getElementById("MissTime"+i).addEventListener("change", function(event) {
// aktuellen Wert speichern
if (this.value != "" && (isNaN(this.value) || Number(this.value) < 0))
alert ("Bitte nur eine Zahl >= 0 eingeben oder frei lassen");
else {
var indx = this.id.substr(-1);
PGu_setValue(missions[indx]+"Time", this.value);
}
}, false);
}
var lis = tables[i].getElementsByClassName("stage_area")[0].getElementsByTagName("li");
plunder[i] = new Array();
var first = noMissCtrl;
for (var j = 0; j < lis.length; j++) {
if (lis[j].innerHTML.indexOf('">x ') == -1)
continue;
var plnd = lis[j].innerHTML.split("<span>")[1].split("</span>")[0].trim();
var amnt = Number(lis[j].innerHTML.split(">x ")[1].match(/\d+/)[0].trim());
plunder[i].push(new Array(plnd, amnt));
if (amnt >= 1000 || !noMissCtrl) {
if (!first) {
var newbr = document.createElement("br");
div[div.length-1].appendChild(newbr, div);
}
var newtd = document.createElement("td");
newtd.innerHTML = '<input name="'+plnd+'payin'+i+'" id="'+plnd+'payin'+i+'" type="checkbox"><span style="vertical-align: bottom"> '+plnd+' bei Bedarf in Plunderbank einzahlen'+'</span>';
div[div.length-1].appendChild(newtd, div);
PGu_setValue(plnd+"PayIn", PGu_getValue(plnd+"PayIn", false));
document.getElementById(plnd+"payin"+i).checked = PGu_getValue(plnd+"PayIn", false);
// Click-Handler hinzufügen
document.getElementById(plnd+"payin"+i).addEventListener("click", function(event) {
// Klickstatus speichern
var plnd = this.id.split("payin")[0];
PGu_setValue(plnd+"PayIn", this.checked);
}, false);
first = false;
if (amnt >= 1000 && !noMissCtrl) {
var newbr = document.createElement("br");
div[div.length-1].appendChild(newbr, div);
var newtd = document.createElement("td");
newtd.innerHTML = '<input name="'+plnd+'Smml'+i+'" id="'+plnd+'Smml'+i+'" type="checkbox"><span style="vertical-align: bottom"> '+plnd+' nach Missionsstart wieder sammeln</span>';
div[div.length-1].appendChild(newtd, div);
PGu_setValue(plnd+"Coll", PGu_getValue(plnd+"Coll", false));
document.getElementById(plnd+"Smml"+i).checked = PGu_getValue(plnd+"Coll", false);
// Click-Handler hinzufügen
document.getElementById(plnd+"Smml"+i).addEventListener("click", function(event) {
// Klickstatus speichern
var plnd = this.id.split("Smml")[0];
PGu_setValue(plnd+"Coll", this.checked);
}, false);
}
}
}
if (noMissCtrl)
continue;
var divs = tables[i].getElementsByClassName("stage_area")[2].getElementsByClassName("icon_display");
var boost = divs[divs.length-1].innerHTML.split('src="')[1].split("/").pop().split(".")[0];
boosts[i] = boost;
if (boost.substr(0,5) == "boost") {
var newbr = document.createElement("br");
div[div.length-1].appendChild(newbr, div);
var newtd = document.createElement("td");
newtd.innerHTML = '<input name="MissAbhol'+i+'" id="MissAbhol'+i+'" type="checkbox"><span style="vertical-align: bottom"> diesen Boost überschreiben</span>';
div[div.length-1].appendChild(newtd, div);
document.getElementById("MissAbhol"+i).checked = PGu_getValue(boost+"Over", false);
// Click-Handler hinzufügen
document.getElementById("MissAbhol"+i).addEventListener("click", function(event) {
// Klickstatus speichern
var indx = this.id.substr(-1);
PGu_setValue(boosts[indx]+"Over", this.checked);
}, false);
var newbr2 = document.createElement("br");
div[div.length-1].appendChild(newbr2, div);
var newtd2 = document.createElement("td");
newtd2.innerHTML = '<input name="BoostStart'+i+'" id="BoostStart'+i+'" type="checkbox"><span style="vertical-align: bottom"> diesen Boost sofort starten</span>';
div[div.length-1].appendChild(newtd2, div);
document.getElementById("BoostStart"+i).checked = PGu_getValue(boost+"Start", false);
// Click-Handler hinzufügen
document.getElementById("BoostStart"+i).addEventListener("click", function(event) {
// Klickstatus speichern
var indx = this.id.substr(-1);
PGu_setValue(boosts[indx]+"Start", this.checked);
}, false);
}
if (mission == "schrottplatz" || mission == "kreuzzug") {
var newbr = document.createElement("br");
div[div.length-1].appendChild(newbr, div);
var newtd = document.createElement("td");
newtd.innerHTML = '<input name="trashAll" id="trashAll" type="checkbox"><span style="vertical-align: bottom"> Missionsplunder unter 60 auch verschrotten</span>';
div[div.length-1].appendChild(newtd, div);
document.getElementById("trashAll").checked = PGu_getValue("trashAllMissPlund", false);
// Click-Handler hinzufügen
document.getElementById("trashAll").addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue("trashAllMissPlund", this.checked);
}, false);
for (var j = 0; j < plunder.length; j++) {
for (var k = 0; k < plunder[j].length; k++) {
if (plunder[j][k][1] >= 1000)
continue;
var newbr = document.createElement("br");
div[div.length-1].appendChild(newbr, div);
var newtd = document.createElement("td");
newtd.innerHTML = '<input name="Schr'+plunder[j][k][0]+'" id="Schr'+plunder[j][k][0]+'" type="checkbox"><span style="vertical-align: bottom"> ' + plunder[j][k][0] + ' kann verschrottet werden</span>';
div[div.length-1].appendChild(newtd, div);
document.getElementById("Schr"+plunder[j][k][0]).checked = PGu_getValue(plunder[j][k][0]+"Schrott", false);
// Click-Handler hinzufügen
document.getElementById("Schr"+plunder[j][k][0]).addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue(this.id.substr(4)+"Schrott", this.checked);
}, false);
}
}
}
}
}
function insertCheckBox7() {
if (TOWNEXTENSION != "HH" && TOWNEXTENSION != "B" && TOWNEXTENSION != "MU" &&
TOWNEXTENSION != "HR" && TOWNEXTENSION != "K" && TOWNEXTENSION != "SY" &&
TOWNEXTENSION != "ML" && TOWNEXTENSION != "VT")
return;
var newtd = document.createElement("td");
var newtr = document.createElement("tr");
newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtd.setAttribute('colspan', '2');
newtd.innerHTML = '<input name="moneyover" id="moneyover" type="checkbox" style="vertical-align:bottom"><span style="vertical-align: bottom"> bei mehr als </span><input name="moreThan" id="moreThan" type="text" style="width:60px;color:black;background-color:white" value=""><span style="vertical-align: bottom"> folgenden Betrag einzahlen: </span><input name="payIn" id="payIn" type="text" style="width:60px;color:black;background-color:white" value="">';
newtd.innerHTML += '<br><input name="minmoneychb" id="minmoneychb" type="checkbox" style="vertical-align:bottom"><span style="vertical-align: bottom"> Mindestgeldbetrag: </span><input name="minMoney" id="minMoney" type="text" style="width:60px;color:black;background-color:white" value="">';
newtr.setAttribute('align', 'left');
newtr.setAttribute('valign', 'top');
newtr.appendChild(newtd, newtr);
var trs = document.getElementsByTagName("tr");
for (var i = 0; i < trs.length; i++)
if (trs[i].innerHTML.indexOf("f_comment") != -1)
break;
i += 2;
if (i >= trs.length)
trs[0].parentNode.appendChild(newtr);
else
trs[0].parentNode.insertBefore(newtr, trs[i]);
document.getElementById("moneyover").checked = PGu_getValue("moneyOver", false);
// Click-Handler hinzufügen
document.getElementById("moneyover").addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue("moneyOver", this.checked);
}, false);
document.getElementById("moreThan").value = PGu_getValue("maxMoney", 0);
document.getElementById("moreThan").addEventListener("change", function(event) {
// aktuellen Wert speichern
if (this.value != "" && (isNaN(this.value) || Number(this.value) < 0))
alert ("Bitte nur eine Zahl >= 0 eingeben oder frei lassen");
else {
PGu_setValue("maxMoney", Number(this.value));
}
}, false);
document.getElementById("payIn").value = PGu_getValue("maxMoneyPayIn", 0);
document.getElementById("payIn").addEventListener("change", function(event) {
// aktuellen Wert speichern
if (this.value != "" && (isNaN(this.value) || Number(this.value) < 0))
alert ("Bitte nur eine Zahl >= 0 eingeben oder frei lassen");
else {
PGu_setValue("maxMoneyPayIn", Number(this.value));
}
}, false);
document.getElementById("minmoneychb").checked = PGu_getValue("minmoneychb", false);
// Click-Handler hinzufügen
document.getElementById("minmoneychb").addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue("minmoneychb", this.checked);
}, false);
document.getElementById("minMoney").value = PGu_getValue("minMoney", 0);
document.getElementById("minMoney").addEventListener("change", function(event) {
// aktuellen Wert speichern
if (this.value != "" && (isNaN(this.value) || Number(this.value) < 0))
alert ("Bitte nur eine Zahl >= 0 eingeben oder frei lassen");
else {
PGu_setValue("minMoney", Number(this.value));
}
}, false);
}
function insertCheckBox8() {
var trs = document.getElementsByClassName("item_list")[0].getElementsByTagName("tr");
var trnr = (TOWNEXTENSION == "VT"?3:1);
var tr1 = trs[trnr].cloneNode(true);
var tr2 = trs[trnr].cloneNode(true);
var inp1 = document.createElement("input");
inp1.id = "minmoney";
inp1.type = "text";
inp1.value = PGu_getValue("minMoney", 0);
inp1.size = "9";
var inp3 = document.createElement("input");
inp3.type = "button";
inp3.value = "übernehmen";
inp3.addEventListener("click", function(event) {
PGu_setValue("minMoney", document.getElementById("minmoney").value);
}, false);
if (TOWNEXTENSION == "VT") {
tr1.getElementsByTagName("td")[0].innerHTML = 'Mindestgeldbetrag:';
tr1.getElementsByTagName("td")[1].appendChild(inp1, tr1.getElementsByTagName("td")[1]);
tr1.getElementsByTagName("td")[1].appendChild(inp3, tr1.getElementsByTagName("td")[1]);
}
else {
tr1.getElementsByTagName("td")[1].innerHTML = 'Mindestgeldbetrag:';
tr1.getElementsByTagName("span")[0].parentNode.removeChild(tr1.getElementsByTagName("span")[0]);
tr1.getElementsByTagName("td")[2].appendChild(inp1, tr1.getElementsByTagName("td")[1]);
tr1.getElementsByTagName("td")[2].appendChild(inp3, tr1.getElementsByTagName("td")[1]);
}
trs[trnr].parentNode.appendChild(tr1, trs[trnr]);
var inp2 = document.createElement("input");
inp2.id = "minprice";
inp2.type = "text";
inp2.value = "0," + ("0" + PGu_getValue("bottleprice", 0)).substr(-2);
inp2.size = "5";
var inp4 = document.createElement("input");
inp4.type = "button";
inp4.value = "übernehmen";
inp4.addEventListener("click", function(event) {
if (document.getElementById("minprice").value.substr(0,2) != "0,")
alert ("Wert unzulässig!");
else
PGu_setValue("bottleprice", Number(document.getElementById("minprice").value.substr(2)));
}, false);
if (TOWNEXTENSION == "VT") {
tr2.getElementsByTagName("td")[0].innerHTML = 'Mindestverkaufspreis Flaschen:';
tr2.getElementsByTagName("td")[1].appendChild(inp2, tr2.getElementsByTagName("td")[1]);
tr2.getElementsByTagName("td")[1].appendChild(inp4, tr2.getElementsByTagName("td")[1]);
}
else {
tr2.getElementsByTagName("td")[1].innerHTML = 'Mindestverkaufspreis Flaschen:';
tr2.getElementsByTagName("span")[0].parentNode.removeChild(tr2.getElementsByTagName("span")[0]);
tr2.getElementsByTagName("td")[2].appendChild(inp2, tr2.getElementsByTagName("td")[2]);
tr2.getElementsByTagName("td")[2].appendChild(inp4, tr2.getElementsByTagName("td")[2]);
}
trs[trnr].parentNode.appendChild(tr2, trs[trnr+1]);
if (TOWNEXTENSION == "VT") {
var tr3 = trs[trnr].cloneNode(true);
var inp6 = document.createElement("input");
inp6.id = "maxfill";
inp6.type = "text";
inp6.value = PGu_getValue("maxfillbottle", 90);
inp6.size = "5";
var inp8 = document.createElement("input");
inp8.type = "button";
inp8.value = "übernehmen";
inp8.addEventListener("click", function(event) {
if (isNaN(document.getElementById("maxfill").value) ||
Number(document.getElementById("maxfill").value) < 1 ||
Number(document.getElementById("maxfill").value) > 100)
alert ("Wert unzulässig!");
else
PGu_setValue("maxfillbottle", Number(document.getElementById("maxfill").value));
}, false);
tr3.getElementsByTagName("td")[0].innerHTML = 'Maximaler Flaschenfüllgrad:';
tr3.getElementsByTagName("td")[1].appendChild(inp6, tr3.getElementsByTagName("td")[1]);
tr3.getElementsByTagName("td")[1].appendChild(inp8, tr3.getElementsByTagName("td")[1]);
trs[trnr].parentNode.appendChild(tr3, trs[trnr+1]);
}
}
function insertCheckBox9() {
function makeSelection (allplunder, div, pos, upgr) {
function getPlunderSpez (plist, val) {
if (val == 0)
return "0;";
for (var i = 0; i < plist.length; i++)
if (plist[i][2] == val)
return val + ";" + plist[i][0];
return "0;";
}
var option = '<option value="0"> </option> ';
for (var i = 0; i < allplunder.length; i++)
option += '<option value="' + allplunder[i][2] + '">' + allplunder[i][0] + '</option> ';
var wap = (PGu_getValue(upgr+"ActivePlunder", 0) + ";").split(";")[0];
var wip = (PGu_getValue(upgr+"InactivePlunder", 0) + ";").split(";")[0];
var text = '<br><form name="' + upgr + 'Plunder" id="' + upgr + 'Plunder">Plunder wenn aktiv:<br><select id="pid' + upgr + 'Act" name="pid' + upgr + 'Act"> ' + option + ' </select><br>Plunder wenn inaktiv:<br><select id="pid' + upgr + 'Inact" name="pid' + upgr + 'Inact"> ' + option + ' </select> </form>';
div.innerHTML = div.innerHTML.substr(0, pos) + text + div.innerHTML.substr(pos);
document.getElementById("pid" + upgr + "Act").value = wap;
document.getElementById("pid" + upgr + "Inact").value = wip;
// Click-Handler hinzufügen
document.getElementById("pid"+upgr + "Act").addEventListener("change", function(event) {
// neuen Wert speichern
PGu_setValue(upgr+"ActivePlunder", getPlunderSpez(allplunder, this.value));
}, false);
document.getElementById("pid"+upgr + "Inact").addEventListener("change", function(event) {
// neuen Wert speichern
PGu_setValue(upgr+"InactivePlunder", getPlunderSpez(allplunder, this.value));
}, false);
}
if (TOWNEXTENSION != "HH" && TOWNEXTENSION != "B" && TOWNEXTENSION != "MU" &&
TOWNEXTENSION != "HR" && TOWNEXTENSION != "K" && TOWNEXTENSION != "SY" &&
TOWNEXTENSION != "ML" && TOWNEXTENSION != "VT")
return;
var tr = document.getElementsByTagName("table")[0].getElementsByTagName("tr")[2];
var allplunder = new Array();
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/plunder/ajax/?c=1', onload:function(responseDetails) {
var content = responseDetails.responseText;
var trs = content.split("<tr ");
for (var i = 1; i < trs.length; i++) {
var plname = trs[i].split(">x ")[0].split("</strong")[0].split(">").pop().trim();
var plAnz = trs[i].split(">x ")[1].split("<")[0].trim();
var pid = trs[i].split('pm_')[1].split("'")[0].trim();
for (var j = 0; j < allplunder.length; j++)
if (allplunder[j][0] >= plname)
break;
allplunder.splice(j, 0, new Array(plname, plAnz, pid));
}
var divs = tr.getElementsByTagName("div");
var div = divs[divs.length-1];
var pos = div.innerHTML.indexOf("<br clear");
if (pos <= 0)
return;
makeSelection (allplunder, div, pos, "WiWu");
div = divs[divs.length-2];
pos = div.innerHTML.indexOf("<br clear");
if (pos <= 0)
return;
makeSelection (allplunder, div, pos, "Wut");
}});
}
function insertCheckBox10() {
if (TOWNEXTENSION != "HH" && TOWNEXTENSION != "B" && TOWNEXTENSION != "MU" &&
TOWNEXTENSION != "HR" && TOWNEXTENSION != "K" && TOWNEXTENSION != "SY" &&
TOWNEXTENSION != "ML" && TOWNEXTENSION != "VT")
return;
var div = document.getElementsByClassName("pet_tab_help")[0];
var newtd = document.createElement("td");
newtd.setAttribute('style', 'padding-top: 10px');
newtd.innerHTML = '<input name="icecubeChb" id="icecubeChb" type="checkbox"><span style="vertical-align: bottom"> Eiswürfelspiel automatisch spielen</span>';
div.appendChild(newtd, div);
document.getElementById("icecubeChb").checked = PGu_getValue("icecubeauto", false);
// Click-Handler hinzufügen
document.getElementById("icecubeChb").addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue("icecubeauto", this.checked);
}, false);
for (var i = 1; i <= 6; i++) {
var newtd = document.createElement("td");
newtd.setAttribute('style', 'padding-top: 10px');
newtd.innerHTML = ' <input name="icecubeChb'+i+'" id="icecubeChb'+i+'" type="checkbox"><span style="vertical-align: bottom"> '+i+(i==6?' automatisch behalten':'')+'</span>';
div.appendChild(newtd, div);
document.getElementById("icecubeChb"+i).checked = PGu_getValue("icecubekeep"+i, i==6);
// Click-Handler hinzufügen
document.getElementById("icecubeChb"+i).addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue("icecubekeep"+this.id.substr(-1), this.checked);
}, false);
}
var newbr = document.createElement("br");
div.appendChild(newbr, div);
var newtd2 = document.createElement("td");
newtd2.innerHTML = '<input name="FruitChb" id="FruitChb" type="checkbox"><span style="vertical-align: bottom"> Freche Früchtchen automatisch spielen </span><input name="FruitKKChb" id="FruitKKChb" type="checkbox"><span style="vertical-align: bottom"> angefangene Treffer mit Kronkorken beenden</span>';
div.appendChild(newtd2, div);
document.getElementById("FruitChb").checked = PGu_getValue("livegameauto", false);
// Click-Handler hinzufügen
document.getElementById("FruitChb").addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue("livegameauto", this.checked);
}, false);
document.getElementById("FruitKKChb").checked = PGu_getValue("livegameKK", false);
// Click-Handler hinzufügen
document.getElementById("FruitKKChb").addEventListener("click", function(event) {
// Klickstatus speichern
PGu_setValue("livegameKK", this.checked);
if (this.checked)
PGu_setValue("livegame_date", "xx");
}, false);
}
function insertCheckBox11() {
if (TOWNEXTENSION != "HH" && TOWNEXTENSION != "B" && TOWNEXTENSION != "MU" &&
TOWNEXTENSION != "HR" && TOWNEXTENSION != "K" && TOWNEXTENSION != "SY" &&
TOWNEXTENSION != "ML" && TOWNEXTENSION != "VT")
return;
var div = document.getElementsByClassName("counters")[0];
var newspan = document.createElement("span");
newspan.innerHTML = '<input type="submit" value="gefundener Plunder" style="font-size:18px; background-color:darkgreen; position:relative; top:-37px" id="junkfound">';
div.insertBefore(newspan, div.firstChild);
var center = div.getElementsByTagName("center");
for (i = 0; i < center.length; i++)
center[i].style.top = (33 + i*29 - Math.floor(i/2)) + "px";
// Click-Handler hinzufügen
document.getElementById("junkfound").addEventListener("click", function(event) {
var junk = PGu_getValue("junkfound", "");
if (junk == "")
junk = "Nichts gefunden:";
else {
junkArr = junk.split(";");
junk = "Gefunden:\n\n";
for (var i = 0; i < junkArr.length; i++) {
if (junkArr[i] != "") {
var arr = junkArr[i].split(":");
for (var j = 1; j < arr.length; j++) {
if (arr[j].match(/^\d/))
break;
else {
arr.splice(j-1, 2, arr[j-1] + ":" + arr[j]);
j--;
}
}
junk += arr.pop() + " x " + arr[0];
if (arr.length > 1) {
arr.splice(0, 1);
junk += " (" + arr.join(" + ") + ")";
}
junk += "\n";
}
else
junk += "---------------------------\n";
}
}
alert(junk);
}, false);
}
// ***********************************************************************************************
// ***********************************************************************************************
// check for enemy game and play it
// ***********************************************************************************************
// ***********************************************************************************************
function CheckEnemygame () {
if (!document.getElementById("enemy_info"))
return;
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/enemies/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var pos = content.indexOf('id="fight_button');
if (pos != -1) {
if (content.substr(pos, 100).indexOf('counter(') == -1)
setTimeout(Enemyattack, 1500);
return;
}
pos = content.indexOf('hp_bar_blue');
if (pos == -1) {
return;
}
else {
var poscnt = content.indexOf('counter(', pos);
if (poscnt != -1) {
var cnt = parseInt(content.substr(poscnt+8).split(")")[0].split(',')[0]);
if (cnt > 0)
setTimeout(enemyreload, cnt*1000, "CheckEnemygame");
}
}
}
});
}
// ***********************************************************************************************
// ***********************************************************************************************
// buy luck
// ***********************************************************************************************
// ***********************************************************************************************
function LoseKaufen (content, anzLose) {
if (anzLose <= 0) {
reload("LoseKaufen");
return;
}
var pos = content.indexOf('name="preis_cent"');
if (pos < 0)
return;
var anz = (anzLose > 10?10:anzLose);
var preis = (Number(content.substr(content.substr(0, pos).lastIndexOf("<input")).split('value="')[1].split('"')[0]) * anz).toString();
pos = content.indexOf('name="submitForm"');
if (pos < 0)
return;
var val = content.substr(content.substr(0, pos).lastIndexOf("<input")).split('value="').pop().split('"')[0];
preis = preis.substr(0, preis.length-2) + "." + preis.substr(-2);
HttpPost(content, 1, new Array("menge", anz, "submitForm", val.replace("1.00", preis)),
function() { LoseKaufen(content, anzLose - anz) });
}
// ***********************************************************************************************
// ***********************************************************************************************
// start a mission
// ***********************************************************************************************
// ***********************************************************************************************
function StartMission (missionname, id, plist, losecont, nochlose)
{
GM_xmlhttpRequest({method: 'POST',
url: 'http://'+window.location.hostname+'/gang/missions/start/',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('mission_id='+id+'&cancel=false'),
onload: function(responseDetails) {
var to = (responseDetails.responseText.indexOf("aktuelle Mission erst abschl") != -1);
if (to)
setTimeout(reload, 30000, "StartMission1");
else {
var m_ownusername = document.getElementsByClassName('zleft profile-data')[0].getElementsByTagName("a")[0].getElementsByTagName("span")[0].innerHTML;
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/admin/log/', onload:function(responseDetails) {
var start = responseDetails.responseText.split(" wurde gestartet");
var missText = start[0].split("<td").pop().split('"')[1];
var user = start[0].substr(0, start[0].lastIndexOf("</td")).split(">").pop().trim();
if (user != m_ownusername) {
setTimeout(reload, 30000, "StartMission2");
return;
}
if (missionname == "kieztour" || missionname == "strassenkampf") {
GM_xmlhttpRequest({method: 'POST',
url: 'http://'+window.location.hostname+'/gang/admin/massmail/',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('f_subject=Mission ' + missText + ' gestartet&sel=Alle&f_text='+(losecont==""?"":losecont+"\n\nGruß "+user)),
onload: function(responseDetails) {
}
});
}
function plEnable (plist, i) {
if (i >= plist.length) {
if (missionname == "casino")
LoseKaufen(losecont, nochlose);
else
reload("plEnable");
return;
}
GM_xmlhttpRequest({method: 'POST',
url: 'http://'+window.location.hostname+'/gang/missions/plunder/enable/',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('pid='+plist[i]),
onload: function(responseDetails) {
plEnable(plist, i+1);
}
});
}
plEnable(plist, 0);
}
});
}
}
});
}
// ***********************************************************************************************
// ***********************************************************************************************
// handle a mission
// ***********************************************************************************************
// ***********************************************************************************************
function HandleMission (missionname, missionStart, missions)
{
var m = MissIndex(missionStart, missionname);
if (m < 1 || m >= missionStart.length)
return -1;
var missname = missionStart[m][0];
var pos = missions[m].indexOf(missname + '.png');
if (pos == -1)
return -1;
var mission = missions[m].substr(pos).split("</table>")[0];
pos = mission.indexOf("counter(");
var counter = 0;
if (pos != -1) {
counter = mission.substr(pos).split("counter(")[1].split(")")[0].trim();
if (counter != done)
counter = Number(counter)
if (counter > 0 && counter < 3600)
setTimeout(reload, (counter<3?3:counter) * 1000, "HandleMission1");
}
var plist = mission.split('show_city_list(');
var plnd = new Array();
for (var j = 1; j < plist.length; j++) {
var pid = plist[j].split(",")[0];
var pos = plist[j-1].lastIndexOf("icon_display");
if (pos == -1)
continue;
var plunder = plist[j-1].substr(pos).split("<span>")[1].split("</span>")[0].trim();
if (PGu_getValue(plunder+"Coll", false))
plnd.push(pid);
}
var cnt = 0;
for (var j = 0; j < plnd.length; j++) {
var pos = mission.indexOf('show_city_list('+plnd[j]+',');
if (pos == -1)
continue;
if (mission.substr(pos,40).indexOf('deactivate') == -1) {
cnt++;
GM_xmlhttpRequest({method: 'POST',
url: 'http://'+window.location.hostname+'/gang/missions/plunder/enable/',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('pid='+plnd[j]),
onload: function(responseDetails) {
reload("HandleMission2");
}
});
}
}
if (cnt > 0)
return 0;
var pos = mission.indexOf('job_notdone');
if (pos != -1) {
if (missionname == "kieztour")
PGu_setValue("KiezTourAct", 1);
if (missionname == "strassenkampf")
PGu_setValue("StrassenKampfAct", 1);
if (missionname == "casino" && mission.substr(pos).split("<br")[0].indexOf("Rubbellose") == -1)
return -1;
return pos;
}
if (missionname == "kieztour")
PGu_setValue("KiezTourAct", 0);
if (missionname == "strassenkampf")
PGu_setValue("StrassenKampfAct", 0);
if (missions[1].indexOf("return cancel_popup(") != -1)
return -1;
pos = mission.indexOf("mission_item_notready");
if (pos != -1) {
var amount = mission.substr(pos).split('class="amount">x')[1].split('</span')[0].trim();
var plunder = mission.substr(pos).split('class="amount">x')[0].split("<span>").pop().split('</span')[0].trim();
var muss = Number(amount.split("(")[0].trim());
var ist = Number(amount.split("(")[1].split(")")[0].trim());
if (muss < 1000 && !PGu_getValue(plunder+"Coll", false))
return -1;
if (muss >= 1000 && !PGu_getValue(plunder+"PayIn", false))
return -1;
if (ist < muss) {
gangpayin(plunder, muss - ist);
return 0;
}
}
if (mission.indexOf('start_mission(') != -1) {
var auto = PGu_getValue(missname+"Auto", false);
if (!auto)
return -1;
var mintime = -1;
for (var j = 1; j < missionStart.length; j++)
if (missname == missionStart[j][0])
continue;
else if (mintime == -1 || mintime > missionStart[j][1])
mintime = missionStart[j][1];
if (PGu_getValue(missname+"MissT", false) && PGu_getValue(missname+"Time", 0)*60 > mintime)
return -1;
var id = mission.split('start_mission(')[1].split(')')[0];
if (missionname == "casino") {
GM_xmlhttpRequest({method:"GET",
url: 'http://' + window.location.hostname + '/city/games/',
onload:function(responseDetails) {
var content = responseDetails.responseText.split('id="content"')[1];
var to = 0;
var nochlose = Number(content.split("Du kannst heute noch ").pop().split(" ")[0]);
if (nochlose == 0)
return;
var gesamt = Number(mission.match(/Kauft \d* Rubbel/)[0].split(" ")[1]);
if (gesamt < nochlose)
nochlose = gesamt;
StartMission (missionname, id, plnd, content, nochlose);
}
});
return -1;
}
if (missionname == "kieztour" || missionname == "strassenkampf") {
var zText = "";
if (missionname == "strassenkampf") {
var lis = mission.split("stage_area")[2].split("<li");
var spl = lis[1].split(/\d+ +Kämpfe/)[0].split("</div>")[1].trim().split(" ");
spl.splice(0,2);
zText = "Bitte alle bei Kämpfen nach " + spl.join(" ") + " ziehen.";
}
StartMission (missionname, id, plnd, zText, 0);
return 0;
}
if (missionname == "schrottplatz") {
var neededPlunder = new Array();
var pAnz = 0;
for (var i = 1; i < missions.length; i++) {
var lis = missions[i].split("stage_area")[1].split("<li>");
for (var j = 1; j < lis.length; j++) {
var beg = lis[j].split('"amount"');
if (beg.length > 1)
neededPlunder[pAnz++] = beg[0].split("<span>")[1].split("<")[0];
}
}
var gesamt = Number(missions[m].split(" Plunder verschrotten")[0].substr(-50).match(/[\d]+/g).pop().trim());
var pltab = 6;
if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" ||TOWNEXTENSION == "MU")
pltab = 1;
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
var content = responseDetails.responseText;
var trs = content.split("<tr ");
var plunderlist = PG_getValue("allplunder", "");
if (plunderlist == "")
plunderlist = new Array();
else
plunderlist = plunderlist.split(";");
for (var i = 1; i < trs.length; i++) {
var plname = trs[i].split(">x ")[0].split("</strong")[0].split(">").pop().trim();
if (plunderlist.indexOf(plname+":0") != -1 || plunderlist.indexOf(plname+":1") != -1)
continue;
var misspl = 0;
if (trs[i].indexOf('"pinfo2"') != -1)
if (trs[i].split('"pinfo2"')[1].indexOf("Missionsplunder") != -1)
misspl = 1;
plunderlist.push(plname+":"+misspl);
}
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/stuff/upgrades/', onload:function(responseDetails) {
var upgrstuff = responseDetails.responseText.split("<tr");
for (var j = 0; j < upgrstuff.length; j++) {
if (upgrstuff[j].indexOf("<td>Kosten") == -1)
continue;
var plnd = upgrstuff[j].split("<td").pop().split("<br");
for (var k = 0; k < plnd.length-1; k++) {
var pl = plnd[k].split(/\d+x /)[1].trim();
if (neededPlunder.indexOf(pl) == -1)
neededPlunder[pAnz++] = pl;
}
}
GM_xmlhttpRequest({method:"GET",
url: 'http://' + window.location.hostname + '/gang/stuff/',
onload:function(responseDetails) {
function TestMissionPlunder(msgs, akti) {
for (var i = akti; i < msgs.length; i++) {
var tds = msgs[i].split("<td ");
if (tds[4].split("<span")[1].split(">")[1].trim() != "0")
continue;
if (neededPlunder.indexOf(tds[2].split("<strong>")[1].split("<")[0]) != -1)
continue;
var plAnz = Number(tds[3].split("<span")[1].split(">")[1].trim());
var plnd = tds[2].split("<strong>")[1].split("<")[0];
var plInd = plunderlist.indexOf(plnd+":0");
if (plInd == -1)
plInd = plunderlist.indexOf(plnd+":1");
if (plInd != -1) {
plAnz = Math.floor(plAnz/(plunderlist[plInd].substr(-1) == "1"?60:1));
plAnzGes += plAnz;
}
else {
var trash = tds[6].split("trash_plunder('");
if (trash.length > 1) {
var pid = trash[1].split("'")[0].trim();
GM_xmlhttpRequest({method:"GET",
url: 'http://' + window.location.hostname + '/stock/plunder/craft/details/'+pid+'/',
onload:function(responseDetails) {
var pcont = responseDetails.responseText.split('class="plundertitle"')[1];
if (pcont.indexOf('"pinfo2"') != -1) {
var pinfo2 = pcont.split('"pinfo2"')[1];
var plname = pcont.split("</strong")[0].split(">").pop().trim();
if (pinfo2.indexOf("Missionsplunder") != -1)
plunderlist.push(plname+":1");
else
plunderlist.push(plname+":0");
}
TestMissionPlunder(msgs, i+1);
}
});
return;
}
}
}
if (i >= msgs.length) {
PG_setValue("allplunder", plunderlist.join(";"));
if (plAnzGes >= gesamt)
StartMission (missionname, id, plnd, "", 0);
}
}
var stuff = responseDetails.responseText;
var msgs = stuff.split('"msglist"');
var plAnzGes = 0;
TestMissionPlunder(msgs, 1);
}
});
}});
}});
return 0;
}
}
else if (mission.substr(pos).indexOf('return reward_popup(') != -1 || mission.substr(pos).indexOf('href="/gang/missions/reward/') != -1) {
var aktBoost = content.split("Aktueller Bandenboost");
if (!PGu_getValue(missname+"Rwd", false))
var abhol = false;
else if (aktBoost.length == 1 || aktBoost[1].indexOf("Kein Boost vorh") != -1)
var abhol = true;
else {
var boost = aktBoost[1].split('src="')[1].split('"')[0].split("/").pop().split(".")[0];
var abhol = PGu_getValue(boost+"Over", false);
}
if (abhol) {
window.location = 'http://'+window.location.hostname+'/gang/missions/reward/';
}
}
return -1;
}
// ***********************************************************************************************
// ***********************************************************************************************
// get time until start of mission
// ***********************************************************************************************
// ***********************************************************************************************
function getMissTime(missionname, content) {
var misstime = -1;
var missname = missionname;
var pos = content.indexOf(missionname+'.png');
if (pos == -1) {
if (missionname == "kieztour")
missname = "davinci_code";
else if (missionname == "strassenkampf")
missname = "schlacht_petersplatz";
else if (missionname == "schrottplatz")
missname = "kreuzzug";
pos = content.indexOf(missname+'.png');
}
if (pos > 0) {
misstime = 0;
var mission = content.substr(pos).split("</table>")[0];
pos = mission.indexOf("counter(");
if (pos != -1) {
var counter = mission.substr(pos).split("counter(")[1].split(")")[0].trim();
if (counter == done)
counter = "0";
misstime = Number(counter);
}
else if (!PGu_getValue(missname+"Auto", false) || mission.indexOf("mission_item_notready") != -1)
misstime = 999999999;
}
return misstime;
}
// ***********************************************************************************************
// ***********************************************************************************************
// find mission index
// ***********************************************************************************************
// ***********************************************************************************************
function MissIndex (missions, mission) {
for (var i = 1; i < missions.length; i++)
if (missions[i][0] == mission)
return i;
var missname = mission;
if (missname == "kieztour")
missname = "davinci_code";
else if (missname == "strassenkampf")
missname = "schlacht_petersplatz";
else if (missname == "schrottplatz")
missname = "kreuzzug";
for (var i = 1; i < missions.length; i++)
if (missions[i][0] == missname)
return i;
return -1;
}
// ***********************************************************************************************
// ***********************************************************************************************
// check for mission
// ***********************************************************************************************
// ***********************************************************************************************
function CheckMission () {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/missions/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var mission = content.split('class="gang_mission"')[1].split("</table>")[0];
if (mission.substr(pos).indexOf('return reward_popup(') != -1 || mission.substr(pos).indexOf('href="/gang/missions/reward/') != -1) {
var aktBoost = content.split("Aktueller Bandenboost");
var missname = mission.split("background-image")[1].split(")")[0].split("/").pop().split(".")[0];
if (!PGu_getValue(missname+"Rwd", false))
var abhol = false;
else if (aktBoost.length == 1 || aktBoost[1].indexOf("Kein Boost vorh") != -1)
var abhol = true;
else {
var boost = aktBoost[1].split('src="')[1].split('"')[0].split("/").pop().split(".")[0];
var abhol = PGu_getValue(boost+"Over", false);
}
if (abhol) {
window.location = 'http://'+window.location.hostname+'/gang/missions/reward/';
return;
}
}
pos = content.indexOf('boost_button');
if (pos != -1)
pos = content.substr(pos).indexOf('activate_boost(');
if (pos != -1) {
var aktBoost = content.split("Aktueller Bandenboost");
if (aktBoost.length == 1 || aktBoost[1].indexOf("Kein Boost vorh") != -1)
var Start = false;
else {
var boost = aktBoost[1].split('src="')[1].split('"')[0].split("/").pop().split(".")[0];
var Start = PGu_getValue(boost+"Start", false);
}
if (Start) {
HttpPost(content, "boost_form", new Array(), function() { reload("CheckMission1"); });
return;
}
}
var missions = content.split('class="gang_mission"');
var missionStart = new Array();
for (var i = 1; i < missions.length; i++) {
var mission = missions[i].split("background-image")[1].split(")")[0].split("/").pop().split(".")[0];
var missTime = getMissTime(mission, missions[i]);
missionStart[i] = new Array(mission, missTime);
if (!missionStart[0] || missTime < missionStart[0][1])
missionStart[0] = new Array(mission, missTime);
}
pos = HandleMission("casino", missionStart, missions);
if (pos > 0) {
var kauf = missions[1].substr(pos).split("<br")[1].split("</span")[0].split(">").pop().trim();
kauf = kauf.split("/");
var gekauft = Number(kauf[0].trim());
var gesamt = Number(kauf[1].trim());
if (gekauft == gesamt)
return;
var m_ownusername = document.getElementsByClassName('zleft profile-data')[0].getElementsByTagName("a")[0].getElementsByTagName("span")[0].innerHTML;
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/admin/log/', onload:function(responseDetails) {
var casino = responseDetails.responseText.split('Mission "Casino-Besuch" wurde gestartet');
var pos = casino[0].lastIndexOf("</td>");
var to = 0;
if (pos == -1)
to = 30;
if (casino[0].substr(0, pos).substr(-m_ownusername.length) != m_ownusername)
to = 30;
if (to > 0) {
var now = new Date().getTime();
var tdiff = now - Number(PGu_getValue("LastLoseKauf", "0"));
if (tdiff > 60000) {
PGu_setValue("LastLoseKauf", now+"");
tdiff = 0;
}
if (tdiff < to*1000) {
setTimeout(reload, to*1000 - tdiff, "CheckMission2");
return;
}
}
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/city/games/', onload:function(responseDetails) {
var content = responseDetails.responseText.split('id="content"')[1];
var nochlose = content.split("Du kannst heute noch ").pop().split(" ")[0];
if (nochlose == 0)
return;
if (gesamt - gekauft < nochlose)
nochlose = gesamt - gekauft;
if (nochlose > 100)
nochlose = 100;
LoseKaufen(content, nochlose);
}
});
}
});
return;
}
pos = HandleMission("schrottplatz", missionStart, missions);
if (pos > 0 && PGu_getValue(missionStart[0][0]+"Auto", false)) {
var neededPlunder = new Array();
var pAnz = 0;
for (var i = 1; i < missions.length; i++) {
var lis = missions[i].split("stage_area")[1].split("<li>");
for (var j = 1; j < lis.length; j++) {
var beg = lis[j].split('"amount"');
if (beg.length > 1) {
var plnd = beg[0].split("<span>")[1].split("<")[0].trim();
if (!PGu_getValue(plnd+"Schrott", false))
neededPlunder[pAnz++] = plnd;
}
}
}
var kauf = missions[1].substr(pos).split("<br")[1].split("</span")[0].split(">").pop().trim();
kauf = kauf.split("/");
var gekauft = Number(kauf[0].trim());
var gesamt = Number(kauf[1].trim());
if (gekauft == gesamt)
return;
var pltab = 6;
if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" ||TOWNEXTENSION == "MU")
pltab = 1;
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
var content = responseDetails.responseText;
var trs = content.split("<tr ");
var plunderlist = PG_getValue("allplunder", "");
if (plunderlist == "")
plunderlist = new Array();
else
plunderlist = plunderlist.split(";");
for (var i = 1; i < trs.length; i++) {
var plname = trs[i].split(">x ")[0].split("</strong")[0].split(">").pop().trim();
if (plunderlist.indexOf(plname+":0") != -1 || plunderlist.indexOf(plname+":1") != -1)
continue;
var misspl = 0;
if (trs[i].indexOf('"pinfo2"') != -1) {
var pinfo2 = trs[i].split('"pinfo2"')[1];
if (pinfo2.indexOf("Missionsplunder") != -1)
misspl = 1;
}
plunderlist.push(plname+":"+misspl);
}
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/stuff/upgrades/', onload:function(responseDetails) {
var upgrstuff = responseDetails.responseText.split("<tr");
for (var j = 0; j < upgrstuff.length; j++) {
if (upgrstuff[j].indexOf("<td>Kosten") == -1)
continue;
var plnd = upgrstuff[j].split("<td").pop().split("<br");
for (var k = 0; k < plnd.length-1; k++) {
var pl = plnd[k].split(/\d+x /)[1].trim();
if (neededPlunder.indexOf(pl) == -1)
neededPlunder[pAnz++] = pl;
}
}
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/stuff/', onload:function(responseDetails) {
function TestMissionPlunder(msgs, akti) {
for (var i = akti; i < msgs.length; i++) {
var tds = msgs[i].split("<td ");
if (tds[4].split("<span")[1].split(">")[1].trim() != "0")
continue;
var pltext = tds[6].split("trash_plunder(")[1].split(")")[0];
var pid = pltext.split("'")[1].trim();
if (neededPlunder.indexOf(pid) != -1)
continue;
var plnd = tds[2].split("<strong>")[1].split("<")[0];
var plAnz = Number(pltext.split(",")[1].trim());
var plInd = plunderlist.indexOf(plnd+":1");
var mpl = plInd != -1;
if (!mpl)
plInd = plunderlist.indexOf(plnd+":0");
if (plInd != -1) {
if (mpl && !mp && plAnz >= minMiss) {
leastAnz = plAnz;
leastpl = pltext;
mp = true;
} else if (mp && !mpl)
continue;
else if (!mpl && leastpl == "" || plAnz < leastAnz) {
leastAnz = plAnz;
leastpl = pltext;
}
}
else {
GM_xmlhttpRequest({method:"GET",
url: 'http://' + window.location.hostname + '/stock/plunder/craft/details/'+pid+'/',
onload:function(responseDetails) {
var pcont = responseDetails.responseText.split('class="plundertitle"')[1];
var plname = pcont.split("</strong")[0].split(">").pop().trim();
var mpl = 0;
if (pcont.indexOf('"pinfo2"') != -1)
if (pcont.split('"pinfo2"')[1].indexOf("Missionsplunder") != -1)
mpl = 1;
plunderlist.push(plname+":"+mpl);
if (mpl && !mp && plAnz >= minMiss) {
leastAnz = plAnz;
leastpl = pltext;
mp = true;
}
else if (mp && !mpl)
;
else if (!mpl && leastpl == "" || plAnz < leastAnz) {
leastAnz = plAnz;
leastpl = pltext;
}
TestMissionPlunder(msgs, i+1);
}
});
return;
}
}
if (i >= msgs.length) {
PG_setValue("allplunder", plunderlist.join(";"));
if (leastAnz > 0) {
var pid = leastpl.split(",")[0].trim();
if (gesamt - gekauft < leastAnz/(mp?60:1))
leastAnz = (gesamt - gekauft)*(mp?60:1);
else if (mp && minMiss != 0)
leastAnz = Math.floor(leastAnz / 60) * 60;
HttpPost(stuff, "stuff_trash_form", new Array("plunder_id", pid, "trash_amount", leastAnz), function() { reload("CheckMission3"); });
}
}
}
var stuff = responseDetails.responseText;
var msgs = stuff.split('"msglist"');
var leastpl = "";
var leastAnz = 0;
var mp = false;
var minMiss = PGu_getValue("trashAllMissPlund", false)?0:60;
TestMissionPlunder(msgs, 1);
}});
}});
}});
return;
}
pos = HandleMission("kieztour", missionStart, missions);
if (pos >= 0)
return;
pos = HandleMission("strassenkampf", missionStart, missions);
}
});
}
function getSeks(counter) {
if (counter == done)
return 0;
var cnt = counter.split(":");
var seks = 0;
for (var i = 0; i < cnt.length; i++)
seks = seks * 60 + Number(cnt[i]);
return seks;
}
function getvcounter () {
var vcounter = done;
if (document.getElementsByClassName("chest_counter").length == 0) {
var tbl = document.getElementsByTagName("table");
for (var i = tbl.length - 1; i > 0; i--)
if (tbl[i].className)
if (tbl[i].className == "cbox")
break;
var trs = tbl[i].getElementsByTagName("tr");
if (trs.length > 2) {
var span = trs[2].getElementsByTagName("span");
for (var i = 0; i < span.length; i++) {
if (span[i].id)
if (span[i].id.substr(0, 7) == "counter") {
vcounter = span[i].innerHTML;
if (vcounter.trim() == done0) // is the time 00:00 ?
vcounter = done;
break;
}
}
}
}
return getSeks(vcounter);
}
function submit(){
if(window.location.pathname.indexOf("/activities/") != -1 && window.location.pathname.indexOf("/crime/") == -1 && autoSubmit){
if (document.getElementsByClassName("chest_key_on").length > 0) {
var href = document.getElementsByClassName("chest_menu")[0].getElementsByClassName("chest_button")[0].href;
window.location.href = href;
}
if (getvcounter() != 0) {
var lastURL = PGu_getValue("AutoCollURL", "");
if (lastURL != "") {
PGu_setValue ("AutoCollURL", "");
window.location.replace( lastURL );
}
else {
PGu_setValue(nameTime, time);
PGu_setValue("AskedForCollect", 0);
checkInterval = window.setInterval(check,intervalTime);
}
return;
}
var lastCollectTime = PGu_getValue(nameLastCollectTime,0);
if (PGu_getValue("KiezTourAct", 0) == 1)
lastCollectTime = 0;
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", true, true);
var timeOptions = document.getElementsByName("time")[0];
if (!timeOptions)
refer();
if (lastCollectTime > 0) {
var options = timeOptions.innerHTML.split('value="');
if (options.length < lastCollectTime + 2)
lastCollectTime = 0;
else {
var minopt = Number(options[1].split('"')[0]);
var selopt = Number(options[lastCollectTime+1].split('"')[0]);
var nextTime = PGu_getValue("NextStartkieztour", -1);
if (nextTime >= 0 && nextTime + minopt*60 < selopt*60 && lastCollectTime > 0)
lastCollectTime = 0;
}
}
timeOptions.selectedIndex = lastCollectTime;
timeOptions.dispatchEvent(evt);
timeOptions.addEventListener( "change",
function(){ PGu_setValue(nameLastCollectTime, document.getElementsByName("time")[0].selectedIndex);
timeOptionsCaptcha.selectedIndex = timeOptions.selectedIndex; },
true );
var timeOptionsCaptcha = timeOptions.cloneNode(true);
timeOptionsCaptcha.selectedIndex = timeOptions.selectedIndex;
timeOptionsCaptcha.addEventListener( "change",
function(){ PGu_setValue(nameLastCollectTime, document.getElementsByName("time")[0].selectedIndex);
timeOptions.selectedIndex = timeOptionsCaptcha.selectedIndex;},
true);
/* var captchaHolder = document.getElementById("holder");
var infoText = captchaHolder.insertBefore(document.createElement('p'),captchaHolder.getElementsByTagName("span")[1]);
infoText.innerHTML = strTime;
infoText.appendChild(timeOptionsCaptcha);
infoText.style.margin = "0px";
infoText.style.marginTop = "8px";
captchaHolder.getElementsByTagName("span")[1].style.marginTop = "-8px";
captchaHolder.getElementsByTagName("span")[1].style.marginLeft = "-10px";
var cancelButton = captchaHolder.getElementsByClassName("cancel")[0];
cancelButton.style.margin = "0px";
cancelButton.style.marginLeft = "10px";
infoText.appendChild(cancelButton);*/
var crimePic = PGu_getValue("AutoCrimePic", "");
var crimeFkt = PGu_getValue("AutoCrimeFkt", 0);
var crimeTO = "";
if (PGu_getValue("AutoCrime", false) && crimePic != "" && crimeFkt > 0) {
var crimeNr = PGu_getValue("AutoCrimeNr", -1);
if (crimeNr > 0) {
crimeTO = " if (document.getElementById('SCCheckbox').checked) window.location = window.location.protocol + '//' + window.location.host + '/activities/crime/?start_crime=" + crimeNr + "'";
PGu_setValue("AutoCrimeFkt", crimeFkt - 1);
}
else if (crimeNr == 0) {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/activities/crime/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var buttons = content.split("plunder_crime/");
for (var i = 1; i < buttons.length; i++) {
var crimep = buttons[i].split('"')[0];
if (crimePic == crimep) {
crimeNr = buttons[i].split("start_crime(")[1].split(")")[0];
PGu_setValue("AutoCrimeNr", crimeNr);
reload("Submit1");
break;
}
}
}});
}
else {
PGu_setValue("AutoCrimePic", "");
PGu_setValue("AutoCrime", false);
setTimeout(reload, 1000, "Submit2");
}
}
if (crimeTO != "")
setTimeout("if (document.getElementById('SCCheckbox'))" + crimeTO + ";", 2000); // fails often if to fast
else
setTimeout("if (document.getElementById('BCCheckbox')) if (document.getElementById('BCCheckbox').checked) document.getElementsByName('Submit2')[0].click();", 3000); // fails often if to fast
}
else {
PGu_setValue(nameTime, time); //store time for each domain to prevent multiple run in same domain
checkInterval = window.setInterval(check,intervalTime);
}
}
function check(){
function setPetCollectDay(day, status) {
var val = PGu_getValue("AutoPetCollectDay", "0000000");
val = val.substr(0, day) + (status?"1":"0") + val.substr(day + 1);
PGu_setValue("AutoPetCollectDay", val);
PGu_setValue("AutoPetCollect", val != "0000000");
return;
}
if (window.location.pathname.indexOf("/pet/") != -1) {
if (document.getElementById("submit_sets") && !document.getElementById("Checkbox1")) {
var divs = document.getElementsByClassName("pet_tab_help");
var newdiv = divs[divs.length-1].cloneNode(true);
newdiv.innerHTML = "<h1>Automatisches Einlösen</h1><span>Hier kannst Du einstellen, wann Deine Gegenstände automatisch eingelöst werden sollen.</span><div> </div>";
var newtdMo = document.createElement("td");
newtdMo.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtdMo.innerHTML = '<input name="CheckboxMo" id="Checkbox1" type="checkbox"><span style="vertical-align: bottom"> Montag </span>';
newdiv.appendChild(newtdMo);
var newtdDi = document.createElement("td");
newtdDi.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtdDi.innerHTML = '<input name="CheckboxDi" id="Checkbox2" type="checkbox"><span style="vertical-align: bottom"> Dienstag </span>';
newdiv.appendChild(newtdDi);
var newtdMi = document.createElement("td");
newtdMi.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtdMi.innerHTML = '<input name="CheckboxMi" id="Checkbox3" type="checkbox"><span style="vertical-align: bottom"> Mittwoch </span>';
newdiv.appendChild(newtdMi);
var newtdDo = document.createElement("td");
newtdDo.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtdDo.innerHTML = '<input name="CheckboxDo" id="Checkbox4" type="checkbox"><span style="vertical-align: bottom"> Donnerstag </span>';
newdiv.appendChild(newtdDo);
var newtdFr = document.createElement("td");
newtdFr.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtdFr.innerHTML = '<input name="CheckboxFr" id="Checkbox5" type="checkbox"><span style="vertical-align: bottom"> Freitag </span>';
newdiv.appendChild(newtdFr);
var newtdSa = document.createElement("td");
newtdSa.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtdSa.innerHTML = '<input name="CheckboxSa" id="Checkbox6" type="checkbox"><span style="vertical-align: bottom"> Samstag </span>';
newdiv.appendChild(newtdSa);
var newtdSo = document.createElement("td");
newtdSo.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtdSo.innerHTML = '<input name="CheckboxSo" id="Checkbox0" type="checkbox"><span style="vertical-align: bottom"> Sonntag </span>';
newdiv.appendChild(newtdSo);
var newtdvon = document.createElement("td");
newtdvon.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtdvon.innerHTML = '<span style="vertical-align: top"> von </span><input name="vonZeit" id="vonZeit" type="text" style="width:15px;">';
newdiv.appendChild(newtdvon);
var newtdbis = document.createElement("td");
newtdbis.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
newtdbis.innerHTML = '<span style="vertical-align: top"> bis </span><input name="vonZeit" id="bisZeit" type="text" style="width:15px;"><span style="vertical-align: top"> Uhr </span>';
newdiv.appendChild(newtdbis);
divs[divs.length-1].parentNode.appendChild(newdiv);
// Status setzen und Click-Handler hinzufügen
for (var i = 0; i < 7; i++) {
document.getElementById("Checkbox"+i).checked = PGu_getValue("AutoPetCollectDay", "0000000").substr(i, 1) == "1";
document.getElementById("Checkbox"+i).addEventListener("click", function(event) {
setPetCollectDay(this.id.substr(-1), this.checked);
}, false);
}
document.getElementById("vonZeit").value = PGu_getValue("AutoPetCollectBegH", 11);
document.getElementById("vonZeit").addEventListener("change", function(event) {
var val = document.getElementById(this.id).value;
if (isNaN(val) || parseInt(val) < 0 || parseInt(val) > 23) {
alert("Bitte eine Zahl von 0 bis 23 eingeben");
document.getElementById(this.id).value = PGu_getValue("AutoCollectBegH", 11);
return false;
}
else
PGu_setValue("AutoPetCollectBegH", parseInt(val));
}, true);
document.getElementById("bisZeit").value = PGu_getValue("AutoPetCollectEndH", 12);
document.getElementById("bisZeit").addEventListener("change", function(event) {
var val = document.getElementById(this.id).value;
if (isNaN(val) || parseInt(val) < 0 || parseInt(val) > 23) {
alert("Bitte eine Zahl von 0 bis 23 eingeben");
document.getElementById(this.id).value = PGu_getValue("AutoCollectEndH", 12);
return false;
}
else
PGu_setValue("AutoPetCollectEndH", parseInt(val));
}, false);
}
}
if(PGu_getValue(nameTime) != time){ //script started somewhere else
clearInterval(checkInterval);
return 0;
}
var c=1;
var posci = document.getElementById("enemy_info")?0:-1;
if (posci != -1)
posci = document.getElementById("enemy_info").innerHTML.indexOf('enemy_counter_info');
if (posci != -1)
posci = document.getElementById("enemy_info").innerHTML.substr(posci+20,200).indexOf("counter");
if (posci != -1)
c=2;
var crime = false;
try{
fcounter = document.getElementById("counter"+c).innerHTML;
counter = document.getElementById("counter"+(c+1)).innerHTML;
crime = document.getElementById("counter"+(c+1)).parentNode.innerHTML.split("counter(")[1].split(")")[0].split('"')[1].indexOf("crime") != -1;
if (counter.trim() == done0) // is the time 00:00 ?
counter = done;
}
catch(err){
}
var promille = GetPromille(document);
if (fcounter == done && counter == done || PGu_getValue("AutoCrime", false) && PGu_getValue("AutoCrimeFkt", 0) > 0 && counter == done) {
if(window.location.pathname.indexOf("/activities/") != -1 && window.location.pathname.indexOf("/crime/") == -1){
if (document.getElementsByClassName("chest_key_on").length > 0) {
var href = document.getElementsByClassName("chest_menu")[0].getElementsByClassName("chest_button")[0].href;
window.location.href = href;
}
if (getvcounter() != 0)
return; // do nothing, if a crime is planned
clearInterval(checkInterval); // stop script
setTimeout(reload, 2000, "check1");
} else {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/activities/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var text = content.split("setupForm('/activities/bottle/'");
if (text.length > 1) {
text = text[1].split('>')[0].split(' ');
text = text[text.length-1];
}
if (text == "disabled") {
clearInterval(checkInterval); // stop script
checkInterval = window.setInterval(check,intervalTime*5);
}
/* deaktiviert !!
else if (PGu_getValue("AutoCollect", false)) {
var lastCollectTime = PGu_getValue(nameLastCollectTime, 0);
var timesplit = content.split('name="time"')[1].split("<option");
if (timesplit.length > lastCollectTime + 1)
var dauer = timesplit[lastCollectTime+1].split('value="')[1].split('"')[0];
else
var dauer = 10;
GM_xmlhttpRequest({method:'POST',
url: 'http://' + window.location.hostname + '/activities/bottle/',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('bottlecollect_pending=True'),
onload:function(responseDetails) {
var content = responseDetails.responseText;
GM_xmlhttpRequest({method:'POST',
url: 'http://' + window.location.hostname + '/activities/bottle/',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('sammeln='+dauer),
onload:function(responseDetails) {
var content = responseDetails.responseText;
var text = content.split("setupForm('/activities/bottle/'");
if (text.length > 1) {
text = text[1].split('>')[0].split(' ');
text = text[text.length-1];
}
if (text == "disabled") {
clearInterval(checkInterval); // stop script
checkInterval = window.setInterval(check,intervalTime*5);
}
}});
}});
} */
else {
clearInterval(checkInterval); // stop script
setTimeout(refer, 10000);
}
}});
}
}
else if (crime && getSeks(counter) < 60 && promille > 0) {
if (PGu_getValue("AutoCrimeURL", "") == "")
PGu_setValue ("AutoCrimeURL", location.toString());
if (location.toString().substr(-5) != "food/")
window.location.href = window.location.protocol + "//" + window.location.host + "/stock/foodstuffs/food/";
else {
var breads = 0;
var items = document.getElementsByClassName("item_list");
for (var i = items.length - 1; i >= 0; i--) {
breads = Number(items[i].getElementsByTagName("tr")[0].getElementsByTagName("td")[1].innerHTML.split(">")[1].split(" ")[0]);
var effect = -Number(document.getElementsByName("promille")[i].value)/100;
if (i > 0 && effect > promille)
continue;
var id = document.getElementsByName("id")[i].value;
if (i == 0)
var nrofbreads = Math.min(Math.ceil(promille/effect), breads);
else
var nrofbreads = Math.min(Math.floor(promille/effect), breads);
// **********************************************************************************
// *** GM_XMLHTTPREQUEST *** POSTEN der Essensnutzung
// **********************************************************************************
GM_xmlhttpRequest({method: 'POST',
url: 'http://' + window.location.hostname + '/stock/foodstuffs/use/',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('item=&promille=&id='+id+'&menge=' + nrofbreads),
onload: function(responseDetails) {
window.location.href = PGu_getValue("AutoCrimeURL", "");
PGu_setValue ("AutoCrimeURL", "");
}
});
break;
}
}
}
else if (PGu_getValue("RefreshInterval", 0) > 0)
setTimeout(reload, PGu_getValue("RefreshInterval", 0) * 60000, "check2");
}
function refer(){
var box = PGu_getValue("AutoCollect", false) || PGu_getValue("AutoCrime", false) && PGu_getValue("AutoCrimeFkt", 0) > 0;
if (box) { // check input field in Mails and SB
var f_text = document.getElementById("f_text");
if (f_text)
box = f_text.value == "";
}
if (!box && PGu_getValue("AskedForCollect", 0) < 3) {
box = window.confirm( msgDone1 + "\n" + msgDone2 );
PGu_setValue("AskedForCollect", PGu_getValue("AskedForCollect", 0) + 1);
}
if (box) {
PGu_setValue("AutoCollURL", location.toString());
window.location.href = window.location.protocol + "//" + window.location.host + "/activities/";
}
}
function reload(msg){
//alert("Reload-Message: " + msg);
if (oldVersion || !autoSubmit)
alert(msgDone1);
if (window.location.toString().indexOf("event") != -1)
window.location.href = window.location.toString();
else
window.location.href = window.location.protocol + "//" + window.location.host + "/activities/";
}
function enemyreload(){
var box = true;
// check input field in Mails and SB
var f_text = document.getElementById("f_text");
if (f_text)
box = f_text.value == "";
if (!box) {
box = window.confirm( msgAttackEnemy );
}
if (box) {
window.location.href = location.toString();
}
}
function Enemyattack(){
GM_xmlhttpRequest({
method:"POST",
url: 'http://' + window.location.host + '/enemies/start_fight/',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI(''),
onload:function(responseDetails) {
enemyreload();
}
});
}
function DoPetCollect() {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/pet/tab/collections/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var ptArray = new Array();
var uls = content.split("tabcontainer").pop().split('id="ul_');
for (var i = 1; i < uls.length; i++) {
var set = uls[i].split('">')[0];
var spans = uls[i].split("trade_in")[0].split("</span>");
var trade = uls[i].split("trade_in")[1].split("</div>")[0].split(">")[0].split("value=").pop();
var points = parseInt(trade.split(")")[0].split("(").pop());
var codeset = new Array();
var minanz = 99999;
for (var j = 0; j < spans.length - 1; j++) {
var code = spans[j].split("item_count_")[1].split('">')[0];
var anz = Number(spans[j].split(">").pop());
codeset.push(new Array(code, anz));
if (anz < minanz)
minanz = anz;
}
if (minanz == 0)
continue;
for (var j = 0; j < ptArray.length; j++)
if (ptArray[j][2] <= points)
break;
ptArray.splice(j, 0, new Array(set, codeset, points));
}
for (var i = 0; i < ptArray.length; i++) {
var rew = ptArray[i][0];
var special = "";
if (rew.substr(0,8) == "special_") {
special = "?special=true";
rew = rew.substr(8);
}
var minanz = 99999;
for (var j = 0; j < ptArray[i][1].length; j++) {
if (ptArray[i][1][j][1] < minanz)
minanz = ptArray[i][1][j][1];
}
if (minanz == 0)
continue;
for (var j = i; j < ptArray.length; j++)
for (var k = 0; k < ptArray[i][1].length; k++)
for (var kk = 0; kk < ptArray[j][1].length; kk++)
if (ptArray[i][1][k][0] == ptArray[j][1][kk][0]) {
ptArray[j][1][kk][1] -= minanz;
break;
}
GM_xmlhttpRequest({
method: 'GET', url: 'http://' + window.location.hostname + '/pet/get_collection_reward/'+rew+"/"+minanz+"/"+special,
onload: function(responseDetails) {
}
});
window.setTimeout("window.location.href = '" + location.toString() + "'", 2000);
return;
}
}});
return;
}
function sellBottles(menge, price, src)
{
function sell(menge, price, src) {
var content = src.split('id="content"')[1];
var pos = content.indexOf('id="max"');
if (pos < 0)
return;
var text = content.substr(0, pos + content.substr(pos).indexOf(">"));
var anz = Number(text.substr(text.lastIndexOf("<input")).split('value="').pop().split('"')[0].trim());
var bprice = price;
if (menge == 0 || bprice == 0) {
pos = text.indexOf('id="chkval"');
if (pos < 0)
return;
text = content.substr(0, pos + content.substr(pos).indexOf(">"));
bprice = Number(text.substr(text.lastIndexOf("<input")).split('value="').pop().split('"')[0].trim());
if (menge == 0)
menge = Math.ceil(price * 100 / bprice);
}
if (anz >= menge)
HttpPost(content, 1, new Array("chkval", bprice, "sum", menge), function() { reload("sellBottles") });
}
if (menge < 0)
return;
if (src == "")
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/bottle/', onload:function(responseDetails) {
sell (menge, price, responseDetails.responseText);
}});
else
sell (menge, price, src);
}
function checkGhostPages() {
var ghostPages = new Array('activities', 'activities/crime', 'city/medicine', 'city/stuff', 'city/supermarket',
'skills', 'stock/bottle', 'messages', 'itemsale', 'stock');
function testGhost(i) {
if (i >= ghostPages.length) {
PGu_setValue("ghostIndex", i);
return;
}
GM_xmlhttpRequest({
method: 'GET', url: 'http://' + window.location.hostname + '/' + ghostPages[i] + '/',
onload: function(responseDetails) {
var content = responseDetails.responseText;
var ghosts = content.split('class="ghost_container"').length;
if (ghosts > 1) {
PGu_setValue("ghostIndex", i + 1);
window.location.href = 'http://' + window.location.hostname + '/' + ghostPages[i] + '/';
}
else
testGhost(i+1);
}
});
return;
}
var today = new Date();
var tagesdatum = FormatDate(today);
var gi = PGu_getValue("ghostIndex", 0);
if (gi >= ghostPages.length) {
if (PGu_getValue("ghostTest", "") != tagesdatum && today.getTime() % 86400000 > 300000) {
gi = 0;
PGu_setValue("ghostTest", tagesdatum);
PGu_setValue("ghostTestNoon", "");
}
else if (PGu_getValue("ghostTestNoon", "") != tagesdatum && today.getHours() > 12) {
gi = 0;
PGu_setValue("ghostTestNoon", tagesdatum);
}
}
var ghosts = document.getElementsByClassName("ghost_container");
if (ghosts.length > 0) {
gi = 0;
PGu_setValue("ghostTest", tagesdatum);
PGu_setValue("ghostTestNoon", tagesdatum);
}
for (var i = 0; i < ghosts.length; i++)
setTimeout('document.getElementsByClassName("ghost_container")['+i+'].click();', 1000);
testGhost(gi);
}
function WashMe(id, cnt) {
// **********************************************************************************
// *** GM_XMLHTTPREQUEST *** POSTEN des Kommandos zum Waschen
// **********************************************************************************
GM_xmlhttpRequest({method: 'POST', url: 'http://' + window.location.hostname + '/city/washhouse/buy/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('id=' + id),
onload: function(responseDetails) {
if (cnt > 1)
WashMe(id, cnt-1);
else
reload("WashMe");
}
});
}
function CheckSalary() {
if (!PGu_getValue("getSalary", false))
return;
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/overview/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var fass = content.split("Fassungsverm")[1].match(/[\d.,]+/);
var maxmoney = Number(fass[0].replace(/[.,]/g,''));
var mon = content.split('class="icon money"')[1].split("</a>")[0];
var money = Number(mon.split(">").pop().match(/[\d,.]+/)[0].replace(/[.,]/g, ''));
var salary = Number(content.split(" jetzt einsacken")[0].match(/[\d,.]+/g).pop().replace(/[.,]/g, ''));
if (content.indexOf("Lohn abholen") != -1 || money + salary > maxmoney && money < 100000) {
if (money + salary < maxmoney || salary > maxmoney) {
var text = content.split("music_payout")[1];
var val = text.split('value="')[1].split('"')[0];
var name = text.split('name="')[1].split('"')[0];
GM_xmlhttpRequest({
method: 'POST', url: 'http://' + window.location.hostname + '/overview/music_payout/',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI(name+"="+val),
onload: function(responseDetails) {
}
});
}
return;
}
if (money == maxmoney)
return;
var pos = content.search(/Du hast heute \d* Spenden erhalten/);
if (pos <= 0)
return;
var spenden = content.substr(pos).match(/Du hast heute \d* Spenden erhalten[^\d]*\d*/);
if (spenden.length < 1)
return;
var rest = Number(spenden[0].split(" ").pop());
if (rest <= 0) {
var stuff = PGu_getValue("aktPlunder", "");
if (stuff != "") {
PGu_setValue("aktPlunder", "");
// **********************************************************************************
// *** GM_XMLHTTPREQUEST *** POSTEN des Plunderwechsels
// **********************************************************************************
GM_xmlhttpRequest({method: 'POST', url: 'http://' + window.location.hostname + '/stock/plunder/change/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('from_f=0&f_plunder=' + stuff),
onload: function(responseDetails) {
reload("CheckSalary1");
}
});
}
return;
}
var time = Number(content.split('class="icon fight')[1].split("counter(")[1].split(",")[0]);
if (time > 0 && time < 60)
return;
time = Number(content.split('class="icon rank')[1].split("counter(")[1].split(",")[0]);
if (time > 0 && time < 60)
return;
var got = Number(spenden[0].split(" ")[3]);
var link = content.substr(pos).split('value="')[1].split('"')[0];
var clean = content.match(/Sauberkeit:[^\d]*\d*/);
if (clean.length < 1)
return;
clean = Number(clean[0].split(">")[1]);
if (clean < 100) {
var id = 2;
var cnt = 1;
var cost = 25;
if (clean >= 20) {
id = 1;
cnt = Math.ceil((100 - clean) / 20);
cost = cnt * 6;
}
var money = GetMoney(document);
if (cost > money) {
var pid = PGu_getValue("sellPlunder1", "0");
if (pid != "0")
sellPlunder (pid, 1, "sellPlunder1");
else {
sellBottles(0, cost - money, "");
}
}
else
WashMe(id, cnt);
return;
}
pos = content.search("Angelegte Plunder");
if (pos <= 0)
return;
var table = content.substr(pos).split("<table")[1].split("</table>")[0];
var tabs = table.split("<tr")[2].split("<td");
var pltab = 3;
if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" || TOWNEXTENSION == "MU")
var pltab = 1;
var aktPlunder = tabs[pltab].split('src="')[1].split('"')[0];
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
var content = responseDetails.responseText;
var bonus = content.match(/ Einnahmen durch Spenden um \d*%/g);
var maxp = -1;
for (var i = 0; i < bonus.length; i++)
if (maxp < 0)
maxp = i;
else if (bonus[i] > bonus[maxp])
maxp = i;
var trs = content.split("<table")[1].split("</table")[0].split("<tr");
var zp = aktPlunder;
var aktstuff = -1;
for (var i = 1; i < trs.length && maxp >= 0; i++)
if (trs[i].indexOf(aktPlunder) != -1) {
aktstuff = trs[i].split("change_stuff('")[1].split("'")[0];
break;
}
var stuff = -1;
for (var i = 1; i < trs.length && maxp >= 0; i++)
if (trs[i].indexOf(bonus[maxp]) != -1) {
zp = trs[i].split('src="')[1].split('"')[0];
stuff = trs[i].split("change_stuff('")[1].split("'")[0];
break;
}
if (zp != aktPlunder) {
PGu_setValue("aktPlunder", aktstuff);
// **********************************************************************************
// *** GM_XMLHTTPREQUEST *** POSTEN des Plunderwechsels
// **********************************************************************************
GM_xmlhttpRequest({method: 'POST', url: 'http://' + window.location.hostname + '/stock/plunder/change/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('from_f=0&f_plunder=' + stuff),
onload: function(responseDetails) {
reload("CheckSalary2");
}
});
return;
}
GM_xmlhttpRequest({
method: 'POST',
url: 'http://pennerga.me/donate.php',
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('url='+link+'&Submit=Donate'),
onload: function(responseDetails) {
reload("CheckSalary3");
}
});
}
});
}
});
}
function CheckGhosts() {
var today = new Date();
var tagesdatum = FormatDate(today);
var ghosts = document.getElementsByClassName("ghost_container");
var to = 10;
if (ghosts.length > 0) {
to = 1;
if (PGu_getValue("ghostTest", "") != tagesdatum) {
PGu_setValue("ghostIndex", 0);
PGu_setValue("ghostTest", tagesdatum);
PGu_setValue("ghostTestNoon", tagesdatum);
}
}
for (var i = 0; i < ghosts.length; i++)
setTimeout('document.getElementsByClassName("ghost_container")['+i+'].click();', 1000);
setTimeout (checkGhostPages, to * 1000);
return;
}
function doBuy(id, anz) {
if (GetMoney(document) < 10) {
var id = PGu_getValue("sellPlunder1", "0");
if (id != "0")
sellPlunder(id, 1, "sellPlunder1");
return;
}
var food = "";
if (id == 2 || id == 3 || id == 4)
food = "food/";
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/city/supermarket/'+food, onload:function(responseDetails) {
var content = responseDetails.responseText.split('id="content"')[1];
var inputs = content.split("<input");
var fnum = 1;
var pos = inputs[0].length;
var menge = 0;
for (var i = 1; i < inputs.length; i++) {
if (inputs[i].indexOf('<form') != -1)
fnum++;
if (inputs[i].indexOf('name="id"') != -1) {
if (inputs[i].split('value="')[1].split('"')[0] == id) {
HttpPost(content, fnum, new Array("menge", anz), function() { reload("doBuy") });
break;
}
}
pos += inputs[i].length + 6;
}
}});
}
function doEatDrink(id, anz) {
var food = "";
if (id == 2 || id == 3 || id == 4)
food = "food/";
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/foodstuffs/'+food, onload:function(responseDetails) {
var content = responseDetails.responseText.split('id="content"')[1];
var inputs = content.split("<input");
var fnum = 1;
var pos = inputs[0].length;
var menge = 0;
for (var i = 1; i < inputs.length; i++) {
if (inputs[i].indexOf('<form') != -1)
fnum++;
if (inputs[i].indexOf('name="id"') != -1) {
if (inputs[i].split('value="')[1].split('"')[0] == id) {
var menge = content.substr(pos).split("<span>")[1].match(/\d+/)[0];
if (menge >= anz)
HttpPost(content, fnum, new Array("menge", anz), function() { reload("doEatDrink") });
break;
}
}
pos += inputs[i].length + 6;
}
if (menge < anz)
doBuy(id, anz - menge);
}});
}
function gangpayin(plunder, anz) {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/stuff/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var payin = content.split('Plunder einzahlen');
if (payin.length > 1) {
var form = payin[1].split("<form")[1].split('name="')[1].split('"')[0];
var select = payin[1].split("<select")[1].split("</select")[0];
var id = select.split('name="')[1].split('"')[0];
var options = select.replace(/ */g, " ").split("<option ");
for (var i = 1; i < options.length; i++) {
if (options[i].indexOf(plunder + " [x") != -1) {
var pid = options[i].split('value="')[1].split('"')[0];
var menge = Number(options[i].split(" [x")[1].split(']</option')[0].trim());
if (menge > anz)
menge = anz;
HttpPost(payin[1], form, new Array(id, pid, "f_count", menge), function() { reload("gangpayin"); });
break;
}
}
}
}});
}
function sellPlunder(pid, anz, varname) {
GM_xmlhttpRequest({method: 'GET', url: 'http://' + window.location.hostname + '/stock/plunder/', onload: function(responseDetails) {
var sell = responseDetails.responseText.split("Plunder verkaufen")[1];
HttpPost(sell, 1, new Array("plunderid", pid, "count", anz), function(responseDetails) {
if (varname != "") {
var antwort = responseDetails.responseText.split("<title")[1].split("</title")[0].split(">")[1];
if (antwort.indexOf("Server Error") != -1)
PGu_setValue(varname, "0");
}
reload("sellPlunder");
});
}});
}
function sellWeapon(id) {
GM_xmlhttpRequest({method: 'POST', url: 'http://' + window.location.hostname + '/stock/armoury/sell/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('id='+id),
onload: function(responseDetails) {
reload("sellWeapon");
}
});
}
function useWeapon() {
var selWeapon = PGu_getValue("selWeapon");
if (selWeapon == "")
reload("useWeapon1");
else {
GM_xmlhttpRequest({method: 'POST', url: 'http://' + window.location.hostname + '/stock/armoury/use/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('id=' + selWeapon),
onload: function(responseDetails) {
PGu_setValue("selWeapon", "");
reload("useWeapon2");
}
});
}
}
function buyWeapon(id) {
if (id == "0") {
useWeapon();
}
else {
GM_xmlhttpRequest({method: 'POST', url: 'http://' + window.location.hostname + '/city/weapon_store/buy/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('id='+id),
onload: function(responseDetails) {
useWeapon();
}
});
}
}
function moveTo(target, home, mode) {
if (home != "")
PGu_setValue("homeDist", home);
else
PGu_setValue("homeDist", "");
GM_xmlhttpRequest({method: 'POST', url: 'http://' + window.location.hostname + '/city/district/buy/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI("id="+target+"&SubmitForm="+(mode==""?"Einziehen":"Kaufen")),
onload: function(responseDetails) {
reload("moveTo");
}
});
}
function doDailyTask(t) {
var today = new Date();
var tagesdatum = FormatDate(today);
switch (t) {
// Jetzt eine PN an einen Freund versenden
case 0: var friend = PGu_getValue("friendid", "0");
if (friend == "0")
return;
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/friendlist/', onload:function(responseDetails) {
var content = responseDetails.responseText;
// Wenn die Seite abgerufen werden konnte (kein Seitenladefehler)
if (content.indexOf("<strong>Mein Penner</strong>") != -1) {
if (content.indexOf("/profil/id:"+friend+"/") == -1)
PGu_setValue("friendid", "0");
else {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/messages/write/', onload:function(responseDetails) {
var content = responseDetails.responseText.split('id="content"')[1];
HttpPost(content, 1, new Array("f_toname", "id:"+friend, "f_subject", "", "f_text", ""), function() { reload("doDailyTask0"); });
}});
}
}
}});
break;
// Ein Verbrechen/eine Sünde erfolgreich begehen
case 1: if (document.getElementById("options").innerHTML.indexOf("crime") != -1)
return false;
var time = document.getElementById("options").innerHTML.split("rank")[1].split("counter(")[1].split(",")[0];
if (time < 0) {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/activities/', onload:function(responseDetails) {
var actbottle = responseDetails.responseText.split('/activities/bottle/')[1].split("</form")[0];
var inputs = actbottle.split("<input ");
var data = "";
for (var j = 1; j < inputs.length; j++) {
var name = inputs[j].split('name="')[1].split('"')[0];
data += "&" + name + "=" + inputs[j].split('value="')[1].split('"')[0];
}
GM_xmlhttpRequest({method: 'POST', url: 'http://' + window.location.hostname + '/activities/bottle/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI(data.substr(1)),
onload: function(responseDetails) {
reload("doDailyTask1");
}
});
}});
return true;
}
else if (time == 0) {
GM_xmlhttpRequest({method: 'GET', url: 'http://' + window.location.hostname + '/activities/crime/?start_crime=1', headers: {'Content-type': 'application/x-www-form-urlencoded'},
onload: function(responseDetails) {
reload("doDailyTask1b");
}
});
return true;
}
return false;
break;
// Einen Kampf gewinnen
case 2: //alert(2);
break;
// Jetzt Lose kaufen
case 3: if (PGu_getValue("KeineLose", "") == tagesdatum)
return false;
var time = Math.ceil(today.getTime() / 1000 - today.getTimezoneOffset()*60) % 86400;
if (PGu_getValue("losemiss_wait", 0) > time && !PGu_getValue("LoseKaufSofort", false))
return false;
GM_xmlhttpRequest({method:"GET",
url: 'http://' + window.location.hostname + '/city/games/',
onload:function(responseDetails) {
var losecont = responseDetails.responseText.split('id="content"')[1];
var nochlose = Number(losecont.split("Du kannst heute noch ").pop().split(" ")[0]);
if (nochlose == 0)
PGu_setValue("KeineLose", tagesdatum);
else if (PGu_getValue("LoseKaufSofort", false))
LoseKaufen(losecont, 1);
else {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/missions/', onload:function(responseDetails) {
var missions = responseDetails.responseText.split('class="gang_mission"');
var losemiss = false;
for (var i = 1; i < missions.length; i++) {
var lis = missions[i].split("stage_area")[2];
if (lis.indexOf("Rubbellose") != -1) {
var counter = 0;
var pos2 = missions[i].indexOf("counter(");
if (pos2 != -1) {
counter = missions[i].substr(pos2).split("counter(")[1].split(")")[0].trim();
if (counter == done)
counter = "0";
counter = Number(counter);
}
losemiss = (time + counter < 83000);
if (losemiss)
PGu_setValue("losemiss_wait", (time+counter));
break;
}
}
if (!losemiss) {
PGu_setValue("losemiss_wait", 0);
var pos = losecont.indexOf('name="preis_cent"');
if (pos < 0)
return;
var val = Number(losecont.substr(losecont.substr(0, pos).lastIndexOf("<input")).split('value="')[1].split('"')[0]) / 100;
var money = GetMoney(document);
if (val > money) {
var pid = PGu_getValue("sellPlunder1", "0");
if (pid != "0")
sellPlunder (pid, 1, "sellPlunder1");
else
sellBottles(0, val - money, "");
}
else
LoseKaufen(losecont, 1);
return;
}
}});
}
}
});
return false;
break;
// Jetzt in der SB posten
case 4: GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/shoutbox_ajax/', onload:function(responseDetails) {
var chatadd = responseDetails.responseText;
var textid = chatadd.split("<textarea ")[1].split('name="')[1].split('"')[0];
HttpPost(chatadd, 1, new Array(textid, "Hallo zusammen!"), function() { reload("doDailyTask4"); });
}});
break;
// Jetzt im Supermarkt Getränke kaufen.
case 5: doBuy(1, 1);
break;
// Jetzt einen Begleiterkampf aktivieren
case 6: var money = Math.floor(GetMoney(document));
if (money == 0) {
var id = PGu_getValue("sellPlunder1", "0");
if (id != "0")
sellPlunder(id, 1, "sellPlunder1");
return (id != 0);
}
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/fight/pet/', onload:function(responseDetails) {
var fightpet = responseDetails.responseText.split('action="/fight/pet/')[1].split("</form")[0];
var inputs = fightpet.replace(/<select/g, "<input").replace(/'/g,'"').split("<input ");
var data = "";
for (var j = 1; j < inputs.length; j++) {
if (inputs[j].indexOf('name="') == -1)
continue;
var name = inputs[j].split('name="')[1].split('"')[0];
if (name == "einsatz") {
var val = inputs[j].split('value="')[1].split('"')[0];
if (val == 0)
val = 1;
}
else if (name == "ttl" || name == "verhalten" || name == "risiko") {
var options = inputs[j].split("<option ");
for (var k=1; k < options.length; k++) {
if (options[k].indexOf("selected") != -1) {
var val = options[k].split('value="')[1].split('"')[0];
break;
}
else if (k == 1)
var val = options[k].split('value="')[1].split('"')[0];
}
}
data += "&" + name + "=" + val;
}
GM_xmlhttpRequest({method: 'POST', url: 'http://' + window.location.hostname + '/fight/pet/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI(data.substr(1)),
onload: function(responseDetails) {
reload("doDailyTask6");
}
});
}});
return true;
break;
// Jetzt einmal 100% sauber werden
case 7: GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/overview/', onload:function(responseDetails) {
var content = responseDetails.responseText.split('id="content"')[1];
var clean = content.match(/Sauberkeit:[^\d]*\d*/);
if (clean.length < 1)
return;
clean = Number(clean[0].split(">")[1]);
if (clean < 100) {
var id = 2;
var cnt = 1;
var cost = 25;
if (clean >= 20) {
id = 1;
cnt = Math.ceil((100 - clean) / 20);
cost = cnt * 6;
}
var money = GetMoney(document);
if (cost > money) {
var pid = PGu_getValue("sellPlunder1", "0");
if (pid != "0")
sellPlunder (pid, 1, "sellPlunder1");
else
sellBottles(0, cost - money, "");
return;
}
WashMe(id, cnt);
}
else {
// Seife benutzen
var pltab = 4;
if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" ||TOWNEXTENSION == "MU")
pltab = 3;
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
var content = responseDetails.responseText;
var trs = content.split("<tr ");
var fnum = 1;
for (var i = 1; i < trs.length; i++) {
if (trs[i].indexOf('seife.png') != -1) {
var pid = trs[i].split('pm_')[1].split("'")[0].trim();
HttpPost(content, fnum, new Array("f_plunder", pid), function() { reload("doDailyTask7"); });
break;
}
fnum += trs[i].split("<form").length - 1;
}
}});
}
}});
break;
// Geld in deine Bandenkasse einzahlen
case 8: var money = Math.floor(GetMoney(document));
if (money == 0) {
var id = PGu_getValue("sellPlunder1", "0");
if (id != "0")
sellPlunder(id, 1, "sellPlunder1");
return;
}
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/credit/', onload:function(responseDetails) {
var content = responseDetails.responseText.split('id="content"')[1];
HttpPost(content, 1, new Array("f_money", money < 1000?1:1000, "f_comment", ""), function() { reload("doDailyTask8"); });
}});
break;
// Plunder in die Plunderbank deiner Bande einzahlen
case 9: GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/missions/', onload:function(responseDetails) {
var missions = responseDetails.responseText.split('class="gang_mission"');
var neededPlunder = new Array();
var pAnz = 0;
for (var i = 1; i < missions.length; i++) {
var lis = missions[i].split("stage_area")[1].split("<li>");
for (var j = 1; j < lis.length; j++) {
var beg = lis[j].split('"amount"');
if (beg.length > 1)
neededPlunder[pAnz++] = beg[0].split("<span>")[1].split("<")[0];
}
}
var pltab = 6;
if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" ||TOWNEXTENSION == "MU")
pltab = 1;
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
var content = responseDetails.responseText;
var trs = content.split("<tr ");
var misspl = new Array();
for (var i = 1; i < trs.length; i++) {
if (trs[i].indexOf('"pinfo2"') == -1)
continue;
var pinfo2 = trs[i].split('"pinfo2"')[1];
if (pinfo2.indexOf("Missionsplunder") != -1) {
var plname = trs[i].split(">x ")[0].split("</strong")[0].split(">").pop().trim();
var plAnz = trs[i].split(">x ")[1].split("<")[0].trim();
misspl.push(new Array(plname, Number(plAnz)));
}
}
var inpaid = false;
for (var i = 0; i < misspl.length; i++)
if (neededPlunder.indexOf(misspl[i][0]) == -1) {
gangpayin(misspl[i][0], misspl[i][1]);
inpaid = true;
break;
}
if (!inpaid && misspl.length > 0) {
gangpayin(misspl[0][0], misspl[0][1]%100!=0?misspl[0][1]%100:100);
}
}});
}});
break;
// Eine Begleiterweiterbildung starten
case 10: //alert(10);
break;
// Einen Plunder basteln
case 11: var indx = PGu_getValue("craftindex", 0);
if (indx < 0)
return -1;
var craftlist = PGu_getValue("craftlist", "").split(";");
var craftid = indx >= craftlist.length?"":craftlist[indx];
if (craftid == "") {
if (document.getElementById("options").innerHTML.indexOf("crime") != -1)
var time = 9999999999;
else
var time = Number(document.getElementById("options").innerHTML.split("rank")[1].split("counter(")[1].split(",")[0]);
PGu_setValue("craftindex", -1)
PGu_setValue("bottletime", time)
return -1;
}
PGu_setValue("craftindex", indx+1);
if (craftid == "0")
return -1;
GM_xmlhttpRequest({method: 'GET', url: 'http://' + window.location.hostname + '/stock/plunder/craft/details/'+craftid+"/", onload: function(responseDetails) {
var content = responseDetails.responseText;
if (content.indexOf("start_craft") != -1)
HttpPost(content, "craftform", new Array("plunder", craftid), function() { reload("doDailyTask11"); });
}});
break;
// Jetzt einen kleinen Snack essen
case 12: var promille = GetPromille(document);
if (promille >= 2.5 && promille < 2.9) {
PGu_setValue("eatDrink", -1);
doEatDrink(1, 1);
}
else if (promille < 0.8)
doEatDrink(2, 1);
else {
PGu_setValue("eatDrink", 1);
doEatDrink(2, 1);
}
break;
// Promillepegel über 2‰
case 13: var promille = GetPromille(document);
if (promille >= 2.8) {
PGu_setValue("eatDrink", 1);
doEatDrink(2, 1);
}
else if (promille > 2.0)
doEatDrink(2, 1);
else {
var drinks = Math.ceil((2.05 - promille) / 0.35);
if (drinks < 1)
drinks = 1;
if (promille < 0.8)
var eats = Math.ceil((promille + drinks*0.35 - 0.75) / 0.35);
else
var eats = drinks;
PGu_setValue("eatDrink", -eats);
doEatDrink(1, drinks);
}
break;
// Einmal Flaschensammeln starten
case 14: if (document.getElementById("options").innerHTML.indexOf("crime") != -1)
return false;
var time = document.getElementById("options").innerHTML.split("/fight/")[1].split("counter(")[1].split(",")[0];
if (time > 0)
return false;
time = document.getElementById("options").innerHTML.split("rank")[1].split("counter(")[1].split(",")[0];
if (time > 0)
return false;
if (window.location.pathname.substr(-12) != "/activities/") {
reload("doDailyTask14b");
}
else {
if (time == 0) {
var lastCollectTime = PGu_getValue(nameLastCollectTime,0);
if (PGu_getValue("KiezTourAct", 0) == 1 || !PGu_getValue("AutoCollect", false))
lastCollectTime = 0;
var timeOptions = document.getElementsByName("time")[0];
timeOptions.selectedIndex = lastCollectTime;
if (!PGu_getValue("AutoCollect", false))
PGu_setValue("BottleCollectAbort", true);
}
document.getElementsByName('Submit2')[0].click();
}
break;
// Jetzt Flaschen verkaufen
case 15: sellBottles(1, 0, "");
break;
// Jetzt Plunder verkaufen
case 16: var pid = PGu_getValue("sellPlunder", "0");
if (pid == "0")
return false;
sellPlunder (pid, 1, "sellPlunder");
break;
// Jetzt den Stadtteil/das Gebiet wechseln.
case 17: GM_xmlhttpRequest({method: 'GET', url: 'http://' + window.location.hostname + '/city/district/', onload: function(responseDetails) {
var districts = responseDetails.responseText.split("/city/district/buy/");
var inDist = "";
var toDist = "";
var kauf = new Array();
for (var i = 1; i < districts.length; i++) {
if (districts[i].indexOf('name="id') != -1) {
var inputs = districts[i].split("</tr")[0].split("<input ");
var id = "";
for (var j = 1; j < inputs.length; j++) {
var name = inputs[j].split('name="')[1].split('"')[0];
var val = inputs[j].split('value="')[1].split('"')[0];
if (name == "id")
id = val;
else if (name == "submitForm") {
if (val == "Bewohnt")
inDist = id;
else if (val == "Einziehen")
toDist = id;
else if (inputs[1].indexOf('title="Preis"') != -1) {
var preis = inputs[1].split('title="Preis"')[1].split(">")[1].split("<")[0].match(/[\d.,]+/)[0].replace(/[.,]/g,"");
if (Number(preis) == 0)
kauf.push(id);
}
}
}
if (inDist != "" && toDist != "")
break;
}
}
var modus = "";
if (toDist == "" && kauf.length > 0) {
toDist = kauf[0];
modus = "x";
}
if (toDist != "")
moveTo(toDist, inDist, modus);
}});
break;
// Jetzt eine Waffe verkaufen.
case 18: GM_xmlhttpRequest({method: 'GET', url: 'http://' + window.location.hostname + '/stock/armoury/', onload: function(responseDetails) {
var sell = responseDetails.responseText.split("/armoury/sell/");
var selWeapon = "";
var found = false;
for (var i = 1; i < sell.length; i++) {
if (sell[i].indexOf('name="id') != -1) {
var id = sell[i].split("value=");
if (id.length > 1) {
var weaponid = id[1].split('"')[1];
if (sell[i-1].split("<input ").pop().indexOf("disabled") != -1)
selWeapon = weaponid;
if (id[1].split('"')[1] == "1")
found = true;
if (found && selWeapon != "")
break;
}
}
}
if (found)
sellWeapon("1");
else {
if (GetMoney(document) < 2) {
var pid = PGu_getValue("sellPlunder1", "0");
if (pid != "0")
sellPlunder (pid, 1, "sellPlunder1");
}
else {
PGu_setValue("selWeapon", selWeapon);
buyWeapon("1");
}
}
}
});
break;
// Jetzt einem anderen Penner spenden.
case 19: if (PGu_getValue("donationdate", "") == tagesdatum || PGu_getValue("donationlink", "") == "")
return false;
PGu_setValue("donationdate", tagesdatum);
GM_xmlhttpRequest({method: 'GET', url: PGu_getValue("donationlink", ""), onload: function(responseDetails) {
reload("doDailyTask19");
}});
break;
// Jetzt Zahnstocher/Distel/Weihrauch kaufen.
case 20: GM_xmlhttpRequest({method: 'GET', url: 'http://' + window.location.hostname + '/stock/armoury/', onload: function(responseDetails) {
var sell = responseDetails.responseText.split("/armoury/sell/");
var selWeapon = "";
var found = false;
for (var i = 1; i < sell.length; i++) {
if (sell[i].indexOf('name="id') != -1) {
var id = sell[i].split("value=");
if (id.length > 1) {
var weaponid = id[1].split('"')[1];
if (sell[i-1].split("<input ").pop().indexOf("disabled") != -1)
selWeapon = weaponid;
if (id[1].split('"')[1] == "1")
found = true;
if (found && selWeapon != "")
break;
}
}
}
if (PGu_getValue("selWeapon", "") == "")
PGu_setValue("selWeapon", selWeapon);
if (!found) {
if (GetMoney(document) < 2) {
var pid = PGu_getValue("sellPlunder1", "0");
if (pid == "0")
return;
sellPlunder (pid, 1, "sellPlunder1");
}
else
buyWeapon("1");
}
else
sellWeapon("1");
}
});
break;
// Tierische Weihnachten
// Einkaufen in letzter Sekunde
default: return false;
break;
}
return true;
}
function CheckDaily() {
if (!PGu_getValue("autoDaily", false))
return false;
if (TOWNEXTENSION != "HH" && TOWNEXTENSION != "B" && TOWNEXTENSION != "MU" &&
TOWNEXTENSION != "HR" && TOWNEXTENSION != "K" && TOWNEXTENSION != "SY" &&
TOWNEXTENSION != "ML" && TOWNEXTENSION != "VT")
return false;
if (PGu_getValue("BottleCollectAbort", false)) {
if (document.getElementById("options").innerHTML.indexOf("crime") != -1)
return;
var time = Number(document.getElementById("options").innerHTML.split("rank")[1].split("counter(")[1].split(",")[0]);
if (time == 0) {
PGu_setValue("BottleCollectAbort", false);
return;
}
if(window.location.pathname.indexOf("/activities/") == -1)
reload("CheckDaily");
else
document.getElementsByName('Submit2')[0].click();
}
if (PGu_getValue("homeDist", "") != "") {
moveTo(PGu_getValue("homeDist"), "", "");
return true;
}
if (PGu_getValue("craftindex", 0) < 0) {
if (document.getElementById("options").innerHTML.indexOf("crime") != -1) {
var time = PGu_getValue("bottletime", 0) + 1;
if (time > 9999999999)
time = 0;
}
else
var time = Number(document.getElementById("options").innerHTML.split("rank")[1].split("counter(")[1].split(",")[0]);
if (time > PGu_getValue("bottletime", 0)) {
PGu_setValue("craftindex", 0); // Flaschen wurden gesammelt, Plunder basteln wieder testen
PGu_setValue("bottletime", 0);
}
}
var today = new Date();
var tagesdatum = FormatDate(today);
if (PGu_getValue("dailyTaskDone", "xxx") == tagesdatum) {
var selWeapon = PGu_getValue("selWeapon", "");
if (selWeapon != "")
buyWeapon(selWeapon == "1"?selWeapon:"0");
return;
}
var taskTexts = new Array();
taskTexts[0] = 'Jetzt eine PN an einen Freund versenden';
if (TOWNEXTENSION == 'VT')
taskTexts[1] = 'Eine Sünde erfolgreich begehen';
else
taskTexts[1] = 'Ein Verbrechen erfolgreich begehen';
taskTexts[2] = 'Einen Kampf gewinnen';
taskTexts[3] = 'Jetzt Lose kaufen';
taskTexts[4] = 'Jetzt in der SB posten';
taskTexts[5] = 'Jetzt im Supermarkt Getränke kaufen.';
taskTexts[6] = 'Jetzt einen Begleiterkampf aktivieren';
taskTexts[7] = 'Jetzt einmal 100% sauber werden';
taskTexts[8] = 'Geld in deine Bandenkasse einzahlen';
taskTexts[9] = 'Plunder in die Plunderbank deiner Bande einzahlen';
taskTexts[10] = 'Eine Begleiterweiterbildung starten';
taskTexts[11] = 'Einen Plunder basteln';
taskTexts[12] = 'Jetzt einen kleinen Snack essen';
taskTexts[13] = 'Promillepegel über 2‰';
taskTexts[14] = 'Einmal Flaschensammeln starten';
taskTexts[15] = 'Jetzt Flaschen verkaufen';
taskTexts[16] = 'Jetzt Plunder verkaufen';
taskTexts[17] = 'Jetzt den Stadtteil wechseln.';
if (TOWNEXTENSION == 'SY' || TOWNEXTENSION == 'ML' || TOWNEXTENSION == 'VT')
taskTexts[17] = 'Jetzt das Gebiet wechseln.';
else
taskTexts[17] = 'Jetzt den Stadtteil wechseln.';
taskTexts[18] = 'Jetzt eine Waffe verkaufen.';
taskTexts[19] = 'Jetzt einem anderen Penner spenden.';
if (TOWNEXTENSION == 'SY' || TOWNEXTENSION == 'ML')
taskTexts[20] = 'Jetzt Distel kaufen.';
else if (TOWNEXTENSION == 'VT')
taskTexts[20] = 'Jetzt Weihrauch kaufen.';
else
taskTexts[20] = 'Jetzt Zahnstocher kaufen.';
taskTexts[21] = 'Tierische Weihnachten';
taskTexts[22] = 'Einkaufen in letzter Sekunde';
GM_xmlhttpRequest({method: 'GET', url: 'http://' + window.location.hostname + '/daily/', onload: function(responseDetails) {
var content = responseDetails.responseText;
// Wenn die Seite abgerufen werden konnte (kein Seitenladefehler)
if (content.indexOf("<strong>Mein Penner</strong>") != -1) {
var task = content.split('min-height:40px;">')[1];
if (task.indexOf("<strong>") != -1) {
task = task.split('<strong>')[1].split('</strong>')[0];
for (var t = 0; t < taskTexts.length; t++)
if (taskTexts[t] == task) {
doDailyTask(t);
break;
}
}
else {
PGu_setValue("dailyTaskDone", tagesdatum);
PGu_setValue("losemiss_wait", 0);
PGu_setValue("craftindex", 0);
if (PGu_getValue("AutoCrimePicMerk", "") != "") {
PGu_setValue("AutoCrimePic", PGu_getValue("AutoCrimePicMerk", ""));
PGu_setValue("AutoCrimePicMerk", "");
}
}
}
}});
return;
}
function HttpPost(src, fname, vals, fkt) {
if (isNaN(fname)) {
var pos = src.indexOf('name="'+fname);
if (pos == -1)
pos = src.indexOf('id="'+fname);
if (pos == -1)
return;
pos = src.substr(0, pos).lastIndexOf("<form");
}
else {
var fnum = Number(fname);
var pos2 = 0;
for (var i = 1; i <= fnum; i++) {
var pos = src.substr(pos2).indexOf("<form");
if (pos == -1)
return;
pos += pos2;
pos2 = pos + 5;
}
}
var form = src.substr(pos).split("</form")[0];
var addr = form.split('action="')[1].split('"')[0];
if (addr == "")
addr = "/" + src.substr(pos).split("setupForm('/")[1].split("'")[0];
if (addr.substr(0,1) == "/")
addr = 'http://'+window.location.hostname + addr;
var inputs = form.split("<input");
var data = "";
for (var i = 1; i < inputs.length; i++) {
var name = inputs[i].split('name="');
if (name.length > 1)
name = name[1].split('"')[0];
else
continue;
var value = "";
for (var j = 0; j < vals.length; j+=2)
if (vals[j] == name)
break;
if (j < vals.length) {
value = vals[j+1];
vals.splice(j, 2);
}
else {
value = inputs[i].split('value="');
if (value.length > 1)
value = value[1].split('"')[0];
else {
continue;
}
}
data += "&" + name + "=" + value;
}
var predata = "";
for (var j = 0; j < vals.length; j+=2)
predata += "&" + vals[j] + "=" + vals[j+1];
data = predata + data;
GM_xmlhttpRequest({method: 'POST',
url: addr,
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI(data.substr(1)),
onload: function(responseDetails) {
fkt(responseDetails);
}
});
}
// Die eigentliche Funktion
function doTheAction () {
if (document.getElementsByClassName('zleft profile-data').length > 0)
oldVersion = 0;
/*-*/
var host = window.location.host;
if (host.substr(0,4) == "www.")
host = host.substr(4);
if (host.substr(0,7) == "change.")
host = host.substr(7);
if (GM_getValue(host + "_autologin", "xxx") == "xxx") {
GM_setValue(host + "_autologin", GM_getValue("www." + host + "_autologin", false));
GM_setValue(host + "_username", GM_getValue("www." + host + "_username", ""));
GM_setValue(host + "_password", GM_getValue("www." + host + "_password", ""));
GM_deleteValue("www." + host + "_autologin");
GM_deleteValue("www." + host + "_username");
GM_deleteValue("www." + host + "_password");
GM_deleteValue("change." + host + "_autologin");
GM_deleteValue("change." + host + "_username");
GM_deleteValue("change." + host + "_password");
}
var login = document.getElementById("loginform");
if (login) {
login.addEventListener('submit', function(event) {
var input = document.getElementById("loginform").getElementsByTagName("input");
for (var i = 0; i < input.length; i++) {
if (input[i].name == "username" || input[i].name == "password")
GM_setValue(host + "_" + input[i].name, input[i].value);
}
return true;
}, false);
}
var myprof = document.getElementById("my-profile");
if (!myprof) {
function doLogin() {
var login = document.getElementById("loginform");
var input = login.getElementsByTagName("input");
var i = input.length - 1;
if (GM_getValue(host + "_username", "") != "" && GM_getValue(host + "_password", "") != "") {
document.getElementById("login_username").value = GM_getValue(host + "_username", "");
document.getElementById("password").value = GM_getValue(host + "_password", "");
input[i].click();
}
else if (document.getElementById("login_username").value != "" &&
document.getElementById("password").value != "") {
input[i].click();
}
}
var user = document.getElementById("login_username");
if (user) {
var chb = document.createElement("input");
chb.type="checkbox";
chb.id="autologin";
chb.title="Auto-Login";
user.parentNode.appendChild(chb, user);
document.getElementById("autologin").checked = GM_getValue(host + "_autologin", false);
// Click-Handler hinzufügen
document.getElementById("autologin").addEventListener("click", function(event) {
// Klickstatus speichern
GM_setValue(host + "_autologin", this.checked);
}, false);
}
if (GM_getValue(host + "_autologin", false))
window.setTimeout(doLogin, 10000);
return;
}
else if (myprof.getElementsByTagName("form").length > 0) {
var input = myprof.getElementsByTagName("input");
if (input.length > 0) {
myprof.getElementsByTagName("form")[0].addEventListener('mouseup', function(event) {
GM_setValue(host + "_autologin", false);
}, false);
}
}
var mobBut = document.getElementById("mobile_button");
if (mobBut)
if (mobBut.innerHTML == "Logout") {
mobBut.getElementsByTagName("form")[0].addEventListener('mouseup', function(event) {
GM_setValue(host + "_autologin", false);
}, false);
}
// ***********************************************************************************************
// ***********************************************************************************************
// -------- Start of program--------------
// ***********************************************************************************************
// ***********************************************************************************************
PGu_setValue("RefreshInterval", 10);
// Wenn in Berlin gespielt wird
m_ownuserid = getOwnUserID();
if (language == "bl_DE") {
TOWNEXTENSION = 'B';
// Wenn in München gespielt wird
} else if (language == "mu_DE") {
TOWNEXTENSION = 'MU';
// Wenn in Köln gespielt wird
} else if (language == "kl_DE") {
TOWNEXTENSION = 'K';
// Wenn in Hamburg gespielt wird
} else if (language == "de_DE") {
TOWNEXTENSION = 'HH';
// Wenn in Hamburg reloaded gespielt wird
} else if (language == "hr_DE") {
TOWNEXTENSION = 'HR';
// Wenn in Operation Pennersturm gespielt wird
} else if (language == "s6_DE") {
TOWNEXTENSION = 'OP';
// Wenn in Sylt gespielt wird
} else if (language == "sy_DE") {
TOWNEXTENSION = 'SY';
// Wenn in Malle gespielt wird
} else if (language == "ml_DE") {
TOWNEXTENSION = 'ML';
// Wenn im Vatikan gespielt wird
} else if (language == "vt_DE") {
TOWNEXTENSION = 'VT';
PGu_setValue("RefreshInterval", 5);
}
else if (language == "us_EN") {
TOWNEXTENSION = 'NY';
}
else if (language == "kr_PL") {
TOWNEXTENSION = 'KR';
}
else if (language == "pl_PL" || language == "wr_PL") {
TOWNEXTENSION = 'WA';
}
else if (language == "ma_FR") {
TOWNEXTENSION = 'MS';
}
else if (language == "fr_FR" || language == "cr_FR") {
TOWNEXTENSION = 'PA';
}
else if (language == "ba_ES") {
TOWNEXTENSION = 'BA';
}
else if (language == "es_ES" || language == "er_ES") {
TOWNEXTENSION = 'MD';
}
else if (language == "sp_BR") {
TOWNEXTENSION = 'SP';
}
else if (language == "pt_BR") {
TOWNEXTENSION = 'RJ';
}
else if (language == "ru_RU") {
TOWNEXTENSION = 'MO';
}
else if (language == "en_EN") {
TOWNEXTENSION = 'LO';
}
if (PGu_getValue("minMoney", 0) > 0 && PGu_getValue("bottleprice", 0) > 0) {
var price = Number(document.getElementsByClassName("icon bottle")[0].innerHTML.split(">")[1].match(/\d+/));
if (price >= PGu_getValue("bottleprice", 0)) {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/overview/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var fass = content.split("Fassungsverm")[1].match(/[\d.,]+/);
var maxmoney = Number(fass[0].replace(/[.,]/g,''));
var mon = content.split('class="icon money"')[1].split("</a>")[0];
var money = Number(mon.split(">").pop().match(/[\d,.]+/)[0].replace(/[.,]/g, ''));
if (money < maxmoney && money/100 < PGu_getValue("minMoney", 0))
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/bottle/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var maxmenge = Math.floor((Math.min(PGu_getValue("minMoney", 0)*100, maxmoney)-money)/price) + 1;
var menge = Math.min(maxmenge, Number(content.split('id="max"')[1].split('value="')[1].split('"')[0]));
sellBottles(menge, price, content);
}});
}});
}
}
if (PGu_getValue("moneyOver", false) && PGu_getValue("maxMoney", -1) > 0 && PGu_getValue("maxMoneyPayIn", -1) > 0) {
var minMoney = 0;
if (PGu_getValue("minmoneychb", false))
minMoney = PGu_getValue("minMoney", 0);
var maxMoney = PGu_getValue("maxMoney", -1);
var payIn = PGu_getValue("maxMoneyPayIn", -1);
var money = GetMoney(document);
if (money > maxMoney && money - payIn >= minMoney) {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/credit/', onload:function(responseDetails) {
HttpPost(responseDetails.responseText, "form1", new Array("f_money", payIn, "f_comment", ""),
function(responseDetails) {
var money2 = responseDetails.responseText.split('id="options"')[1].split("</a")[0].split(">").pop().match(/[.,\d]+/)[0].replace(/[.,]/g,"") / 100;
if (money2 != money)
reload ("gangPayIn");
});
}});
}
}
var maxfill = PGu_getValue("maxfillbottle", 90);
if (maxfill > 0 && TOWNEXTENSION == "VT") {
var price = Number(document.getElementsByClassName("icon bottle")[0].innerHTML.split(">")[1].match(/\d+/));
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/activities/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var fass = content.split("Fassungsverm")[1].match(/[\d.,]+/);
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/stock/bottle/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var p = content.indexOf('id="hp_bar_blue"');
var p2 = content.lastIndexOf("<span", p);
var p3 = content.indexOf("</span", p);
var text = content.substring(p2, p3+10).split("</span>");
var bottles = text[0].split("</strong>")[0].split("<strong>").pop().split(" ")[0];
if (bottles > fass * maxfill / 100) {
var menge = Math.floor(bottles - fass * maxfill / 100);
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/overview/', onload:function(responseDetails) {
var contover = responseDetails.responseText;
var fass = contover.split("Fassungsverm")[1].match(/[\d.,]+/);
var maxmoney = Number(fass[0].replace(/[.,]/g,''));
var mon = contover.split('class="icon money"')[1].split("</a>")[0];
var money = Number(mon.split(">").pop().match(/[\d,.]+/)[0].replace(/[.,]/g, ''));
menge = Math.min(menge, Math.floor((maxmoney - money) / price));
sellBottles(menge, price, content);
}});
}
}});
}});
}
var c=1;
var posci = document.getElementById("enemy_info")?0:-1;
if (posci != -1)
posci = document.getElementById("enemy_info").innerHTML.indexOf('enemy_counter_info');
if (posci != -1)
posci = document.getElementById("enemy_info").innerHTML.substr(posci+20,200).indexOf("counter");
if (posci != -1)
c=2;
try{
fcounter = document.getElementById("counter"+c).innerHTML;
counter = document.getElementById("counter"+(c+1)).innerHTML;
if (counter.trim() == done0) // is the time 00:00 ?
counter = done;
}
catch(err){
}
// alert(PGu_getValue("minigame_value"));
CheckForUpdate();
CheckMinigame();
if (counter != done || !autoSubmit || !PGu_getValue("AutoCollect", false) && !(PGu_getValue("AutoCrime", false) && PGu_getValue("AutoCrimeFkt", 0) > 0))
CheckNewMinigame();
CheckEnemygame();
CheckMission();
var eatDrink = PGu_getValue("eatDrink", 0);
if (eatDrink != 0) {
PGu_setValue("eatDrink", 0);
doEatDrink(eatDrink<0?2:1, eatDrink<0?-eatDrink:eatDrink);
}
CheckDaily();
CheckSalary();
CheckGhosts();
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/city/plundershop/', onload:function(responseDetails) {
}});
if (PGu_getValue(nameLastCollectTime, -1) == -1) {
var keys = GM_listValues();
for (var i = 0; i < keys.length; i++) {
var val = keys[i];
if (val.indexOf("-") != -1 || val.indexOf("pennersturm") != -1)
GM_deleteValue(val);
}
PGu_setValue(nameLastCollectTime, 0);
}
var now = new Date();
var day = now.getDay();
var hour = now.getHours();
if (PGu_getValue("AutoPetCollect", false)) {
var cDay = PGu_getValue("AutoPetCollectDay", "0000000");
var cBeg = PGu_getValue("AutoPetCollectBegH", 0);
var cEnd = PGu_getValue("AutoPetCollectEndH", 0);
if (cDay.substr(day, 1) == "1" &&
((cBeg < cEnd && hour >= cBeg && hour <= cEnd) ||
(cBeg >= cEnd && (hour >= cBeg || hour < cEnd))))
DoPetCollect();
}
if(window.location.pathname.indexOf("/activities/crime/") != -1){
var buttons = document.getElementsByClassName("button_area");
for (var i = 0; i < buttons.length; i++)
insertCheckBox3(buttons[i], i);
}
else if(window.location.pathname.indexOf("/activities/") != -1){
var timeOptions = document.getElementsByName("time")[0];
timeOptions.selectedIndex = PGu_getValue(nameLastCollectTime,0);
insertCheckBox();
insertCheckBox2();
}
else if(window.location.pathname.indexOf("/overview/") != -1){
insertCheckBox4();
}
else if(window.location.pathname.substr(-7) == "/daily/"){
insertCheckBox5();
}
else if(window.location.pathname.substr(-10) == "/missions/"){
insertCheckBox6();
}
else if(window.location.pathname.substr(-13) == "/gang/credit/"){
insertCheckBox7();
}
else if(window.location.pathname.substr(-14) == "/stock/bottle/"){
insertCheckBox8();
}
else if(window.location.pathname.substr(-15) == "/gang/upgrades/"){
insertCheckBox9();
}
else if(window.location.pathname.substr(-16) == "/event/summer15/"){
insertCheckBox10();
}
else if(window.location.pathname.substr(-13) == "/livegame/bb/" && PGu_getValue("junkfound", "") != ""){
insertCheckBox11();
}
var wap = (PGu_getValue("WutActivePlunder", 0) + ";").split(";");
var wip = (PGu_getValue("WutInactivePlunder", 0) + ";").split(";");
var wwap = (PGu_getValue("WiWuActivePlunder", 0) + ";").split(";");
var wwip = (PGu_getValue("WiWuInactivePlunder", 0) + ";").split(";");
if (wap[0] + wip[0] + wwap[0] + wwip[0] > 0 && PGu_getValue("aktPlunder", "") == "" && GetPromille(document) < 0.8) {
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/overview/', onload:function(responseDetails) {
var content = responseDetails.responseText;
pos = content.search("Angelegte Plunder");
if (pos <= 0)
return;
var table = content.substr(pos).split("<table")[1].split("</table>")[0];
var tabs = table.split("<tr")[2].split("<td");
var plname = tabs[1].split("</div")[0].split(">").pop();
GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.hostname + '/gang/upgrades/', onload:function(responseDetails) {
var content = responseDetails.responseText;
var divs = content.split("<table")[1].split("</table")[0].split("<tr ")[2].split("<div");
var aktion = divs[divs.length-1].split('type="submit"')[1].split('value="')[1].split('"')[0];
if (aktion == "Upgrade")
return;
if (aktion == "Wechsel") {
aktion = divs[divs.length-2].split('type="submit"')[1].split('value="')[1].split('"')[0];
var upgr = "Wut";
}
else
var upgr = "WiWu";
if (aktion == "Aktiv")
aktion = "Active";
else
aktion = "Inactive";
var plnd = (PGu_getValue(upgr + aktion + "Plunder", 0) + ";").split(";");
if (plname == plnd[1] || plnd[0] == 0)
return;
// **********************************************************************************
// *** GM_XMLHTTPREQUEST *** POSTEN des Plunderwechsels
// **********************************************************************************
GM_xmlhttpRequest({method: 'POST', url: 'http://' + window.location.hostname + '/stock/plunder/change/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: encodeURI('from_f=0&f_plunder=' + plnd[0]),
onload: function(responseDetails) {
reload("PlunderChange");
}
});
}});
}});
}
if (fcounter == done && counter == done || PGu_getValue("AutoCrime", false) && PGu_getValue("AutoCrimeFkt", 0) > 0 && counter == done)
submit();
else {
var lastURL = PGu_getValue("AutoCollURL", "");
if (lastURL != "") {
PGu_setValue ("AutoCollURL", "");
window.location.replace( lastURL );
}
else {
PGu_setValue(nameTime, time);
PGu_setValue("AskedForCollect", 0);
checkInterval = window.setInterval(check,intervalTime);
}
}
}