// ==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.8.3 Probleme mit Spielen, Spenden und Bandenfinanzen behoben // @downloadURL none // ==/UserScript== // @version 2.8.2 weitere Korrektur nach PG-Update; Probleme mit Spielen und Spenden behoben // @version 2.8.1 Anpassungen ans neue Profil-Design // @version 2.7.4 "Freche Früchtchen": Korrekturen und Liste mit gefundenen Gegenständen // @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 118 2015-08-11 20:35:47Z 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 myprof = document.getElementById("my-profile-new"); if (!myprof) myprof = document.getElementById("my-profile"); var ownuserid = myprof.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) { if (value == "") GM_deleteValue(TOWNEXTENSION + varname); else 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); } // Loeschen 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('').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) } } function findCocktail(content) { var cocktails = new Array(25, new Array(1658, 1658, 1660, 1660, 1661, 1663, 1663, 1663), 26, new Array(1658, 1658, 1660, 1660, 1661, 1665, 1665, 1673), 30, new Array(1658, 1659, 1659, 1665, 1665, 1673, 1673, 1673), 31, new Array(1658, 1660, 1660, 1663, 1663, 1664, 1664, 1673), 24, new Array(1660, 1661, 1661, 1664, 1665, 1673, 1673), 28, new Array(1658, 1658, 1658, 1661, 1665, 1665, 1673), 29, new Array(1658, 1659, 1659, 1661, 1661, 1666, 1666, 1666), 27, new Array(1666, 1666, 1663, 1663, 1664, 1673, 1673) ); var fruits = new Array(); var fruitsplit = content.split('id="count_'); for (var i = 1; i < fruitsplit.length; i++) { var f = fruitsplit[i].split('"')[0].trim(); var anz = Number(fruitsplit[i].split(">")[1].split("<")[0].trim()); fruits[f] = anz; } var mixable = new Array(); for (var c = 0; c < cocktails.length; c++) { var cocktail = cocktails[c++]; var ingred = cocktails[c]; var needed = new Array(); for (ci = 0; ci < ingred.length; ci++) { if (isNaN(needed[ingred[ci]])) needed[ingred[ci]] = 1; else needed[ingred[ci]]++; if (fruits[ingred[ci]] < needed[ingred[ci]]) break; } if (ci < ingred.length) continue; mixable[0] = cocktail; mixable[1] = cocktails[c]; break; } return mixable; } // *********************************************************************************************** // *********************************************************************************************** // check for new minigame // *********************************************************************************************** // *********************************************************************************************** function CheckNewMinigame() { var today = new Date(); var tagesdatum = FormatDate(today); if (PGu_getValue("gameActive", "0") != "0") if ((today.getTime() - Number(PGu_getValue("gameActive", "0")))/1000 > 180) PGu_setValue("gameActive", "0"); 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"); } } var waitTime = Number(PGu_getValue("GameWait", "0")); var time = new Date(waitTime*1000); var now = today.getTime() / 1000; if (FormatDate(time) != tagesdatum) PGu_setValue("GameWait", String(now + 30)); else if (now < waitTime) { window.setTimeout(CheckNewMinigame, 8000); return; } //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("livegame_noon", tagesdatum); } if (content.indexOf("javascript:display_show(") == -1) { PGu_setValue("dispshow_date", tagesdatum); if (today.getHours() > 12) PGu_setValue("dispshow_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"'); var free = 0; var free2 = 0; if (content.length > 1) content = content[1]; if (content.indexOf('id="gameshell"') != -1) { content = content.split('class="counters"')[1]; free = content.split('id="counter_free"')[1].split("<")[0].split(">")[1]; free2 = content.split('id="counter"')[1].split("<")[0].split(">")[1]; } if (free == "0" && free2 == "0") PGu_setValue("livegame_date", tagesdatum); }}); } if (content.indexOf("javascript:display_show(") != -1) { function testGames(games, g) { for ( ; g < games.length; g++) { var game = games[g].split("'")[0]; if (game == "shop") continue; var para = games[g].split("'")[1].split(")")[0]; if (PGu_getValue(game+"auto", false) && PGu_getValue(game+"date", "xx") != tagesdatum) { var addr = content.split("function display_show(")[1].split('url = "')[para==""?1:2].split(';')[0].replace(/" *\+ *to_show *\+ *"/, game).replace('"', ''); GM_xmlhttpRequest({method:"GET", url: 'http://' + window.location.host + addr, onload:function(responseDetails) { var content = responseDetails.responseText; if (game == "icecube") { var div = content.split('class="button_container"')[1].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(" |