Pfandflaschensammler

Nach beendetem Pfandflaschensammeln wird ein Hinweis auf der zuletzt geoeffneten Seite ausgegeben und es kann zur Pfandflaschensammelseite weitergeleitet werden

  1. // ==UserScript==
  2. // @name Pfandflaschensammler
  3. // @namespace http://userscripts.org/scripts/show/85124
  4. // @author lmk (wieder lauffaehig gemacht und erweitert von We1hnachtsmann)
  5. // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
  6. // @copyright (c) 2009, lmk.
  7. // @description Nach beendetem Pfandflaschensammeln wird ein Hinweis auf der zuletzt geoeffneten Seite ausgegeben und es kann zur Pfandflaschensammelseite weitergeleitet werden
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // @grant GM_xmlhttpRequest
  11. // @grant GM_deleteValue
  12. // @grant GM_listValues
  13. // @grant GM_log
  14. // @grant GM_registerMenuCommand
  15. // @grant GM_setClipboard
  16. // @include *4everproxy.com*
  17. // @include http://*.pennergame.de/*
  18. // @include http://pennergame.de/*
  19. // @include https://*.pennergame.de/*
  20. // @include https://pennergame.de/*
  21. // @include http://*.dossergame.co.uk/*
  22. // @include http://dossergame.co.uk/*
  23. // @include http://*.menelgame.pl/*
  24. // @include http://menelgame.pl/*
  25. // @include http://*.bumrise.com/*
  26. // @include http://bumrise.com/*
  27. // @include http://*.clodogame.fr/*
  28. // @include http://clodogame.fr/*
  29. // @include http://*.mendigogame.es/*
  30. // @include http://mendigogame.es/*
  31. // @include http://*.mendigogame.com/*
  32. // @include http://mendigogame.com/*
  33. // @include http://*.faveladogame.com/*
  34. // @include http://faveladogame.com/*
  35. // @include http://*.bomzhuj.ru/*
  36. // @include http://bomzhuj.ru/*
  37. // @exclude http://*board.pennergame.de/*
  38. // @exclude http://mobile.pennergame.de/*
  39. // @version 2.9.14 Proxy für Spendensammler geändert
  40. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js
  41. // ==/UserScript==
  42.  
  43. // @version 2.9.13 Tagesaufgabe Verbrechen/Sünde/Sabotage funktionierte nicht mehr
  44. // @version 2.9.12 Abfrage auf Spendenserver nur, wenn auch Spenden gesammelt werden
  45. // @version 2.9.11 alternativen Spendenserver eingebaut; kleinere Korrekturen
  46. // @version 2.9.10 Fehler beim Geschenkabholen behoben
  47. // @version 2.9.9 Spenden wurden nicht mehr gesammelt
  48. // @version 2.9.8 Umstellung auf https und viele kleine Korrekturen
  49. // @version 2.9.7 kleine Korrekturen; Geschenke abholen verbessert
  50. // @version 2.9.6 kleine Korrekturen
  51. // @version 2.9.5 viele kleine Fehler behoben; diverse Erweiterungen, z.T. noch im Test
  52. // @version 2.9.4 Tagesaufgabe Verbrechen korrigiert; Fehler bei Spendenholen behoben
  53. // @version 2.9.3 Tagesaufgabe Sabotage in Atlantis korrigiert
  54. // @version 2.9.2 weitere Anpassungen für Atlantis (Tagesaufgaben)
  55. // @version 2.9.1 Anpassungen Atlantis
  56. // @version 2.8.31 Geld wurde zu oft in Bandenkasse eingezahlt
  57. // @version 2.8.30 Korrektur Geld abholen
  58. // @version 2.8.29 Korrektur Flaschensammeln und Verbrechen
  59. // @version 2.8.28 Boxen beim Flaschensammeln verlegt; Start von Verbrechen korrigiert
  60. // @version 2.8.27 Weitere Korrekturen Flaschen sammeln und Spenden; Standorte um Missionsplunder erweitert
  61. // @version 2.8.26 Korrekturen Flaschen sammeln und Spenden; Einstellungen sichern und wiederherstellen
  62. // @version 2.8.25.1 Korrekturen Stadtteil-/Gebietsvorwahl; Heimatstandort wählbar; Hotfix: Spenden
  63. // @version 2.8.25 Korrekturen Stadtteil-/Gebietsvorwahl; Heimatstandort wählbar
  64. // @version 2.8.24 Stadtteil-/Gebietsvorwahl bei Flaschensammeln
  65. // @version 2.8.23 Korrekturen Weihnachtsbäckerei
  66. // @version 2.8.22 Korrekturen/Verbesserungen Weihnachtsbäckerei
  67. // @version 2.8.21 Erweiterungen für Weihnachtsbäckerei
  68. // @version 2.8.20 Verbesserung Minispiel Memory und Tagesaufgabe Shoutbox
  69. // @version 2.8.19 Erweiterung um Minispiel Memory
  70. // @version 2.8.18 Spielsteuerung korrigiert; Fehler bei Spendenholen behoben
  71. // @version 2.8.17 Fehler bei TA "Lose kaufen" behoben; Minigame Globbi
  72. // @version 2.8.16 Spenden holen funktionierte nicht mehr richtig
  73. // @version 2.8.15 alles kaufen im Plundershop
  74. // @version 2.8.14 Einkauf im Plundershop
  75. // @version 2.8.13 Umstellung Losekauf
  76. // @version 2.8.12 Korrekturen für Brezngaudi
  77. // @version 2.8.11 Korrekturen für Minispiele; Brezngaudi
  78. // @version 2.8.10 Korrekturen für Breznjagd und Spenden holen; Hendlbraterei
  79. // @version 2.8.9 kleine Korrektur für Breznjagd
  80. // @version 2.8.8 Korrekturen für Eventspiel und Spenden holen
  81. // @version 2.8.7 Anpassungen für Mini-Spiel "Stramme Schenkel"; Fehler korrigiert
  82. // @version 2.8.6 Anpassungen für neue Eventplundereinteilung
  83. // @version 2.8.5 Fehler bei Spenden holen behoben
  84. // @version 2.8.4 Korrekturen; Spenden holen über spenden.hitfaker.net
  85. // @version 2.8.3 Probleme mit Spielen, Spenden und Bandenfinanzen behoben
  86. // @version 2.8.2 weitere Korrektur nach PG-Update; Probleme mit Spielen und Spenden behoben
  87. // @version 2.8.1 Anpassungen ans neue Profil-Design
  88. // @version 2.7.4 "Freche Früchtchen": Korrekturen und Liste mit gefundenen Gegenständen
  89. // @version 2.7.3 Fehler bei TA behoben; Spiele "Freche Früchtchen" und "Eiswürfelspiel" neu
  90. // @version 2.7.2 Spiele "Freche Früchtchen" und "Eiswürfelspiel" auf Wunsch automatisch
  91. // @version 2.7.1 Anpassungen wegen des neuen Bildungsslots
  92. // @version 2.6.12 Korrektur Geld in Bandenkasse einzahlen
  93. // @version 2.6.11 keine Texte bei Geldeinzahlung; Korrekturen bei TA
  94. // @version 2.6.10 Korrektur TA Flaschen sammeln
  95. // @version 2.6.9 Korrektur Flaschen verkaufen; ggf. Seife bei TA "100% sauber" benutzen
  96. // @version 2.6.8 Korrektur TA Lose kaufen; Wut/WiWu-abhängiger Plunderwechsel
  97. // @version 2.6.7 automatischer Flaschenverkauf im Vatikan funktionierte nicht mehr
  98. // @version 2.6.6 weitere Korrekturen an Tagesaufgaben
  99. // @version 2.6.5 kleine Korrekturen
  100. // @version 2.6.4 Plunder für Eigentumupgrades nicht verschrotten, wenn er noch benötigt wird.
  101. // @version 2.6.3 Anpassungen für Mini-Spiel "Zecken für Ecken"
  102. // @version 2.6.2 Kleine Anpassungen für Missionsplunder; Probleme mit Fußballspiel behoben
  103. // @version 2.6.1 Erweiterung Erledigung Tägliche Aufgabe und Mini-Spiel "Umkleidekabine"
  104. // @version 2.5.16 Erweiterung für Mini-Spiel "Russisch Roulette"
  105. // @version 2.5.15 Abschalten des Mini-Spiels "Russisch Roulette"
  106. // @version 2.5.14 Anpassungen für Mini-Spiel "Eierklau 2015"
  107. // @version 2.5.13 Mini-Spiel "Osterfeuer 2015"
  108. // @version 2.5.12 Spenden holen
  109. // @version 2.5.11 Kamellen suchen
  110. // @version 2.5.10 Unnötige Aufrufe der Eventseite abgestellt
  111. // @version 2.5.9 Automatik funktionierte nicht mehr
  112. // @version 2.5.8 Probleme mit Event-Seite behoben
  113. // @version 2.5.7 Vatikan: Flaschenverkauf bei Überschreiten eines maximalen Füllgrads
  114. // @version 2.5.6 Adventsspiel: Plätzchenklau, Korrektur
  115. // @version 2.5.5 Adventsspiel: Plätzchenklau
  116. // @version 2.5.4 Fehler bei Erkennung eines vorhandenen Updates behoben
  117. // @version 2.5.3 Erkennung des beendeten Minigames fehlerhaft; Sammelmarken einlösen
  118. // @version 2.5.2 automatischer Aufruf der Event-Seite falls nötig
  119. // @version 2.5.1 erste Version Vatikan und neues Rentier-Spiel
  120. // @version 2.4.3 Korrekturen; Gehalt automatisch abholen
  121. // @version 2.4.2 Erweiterungen und Korrekturen für Eckfahnenspiel 2014
  122. // @version 2.4.1 Wechsel auf greasyfork.org; Verbrechensstart erweitert
  123. // @version 2.3.34 Anpassungen für Sommergame 2014 (Zollbeamter)
  124. // @version 2.3.33 noch eine Korrektur zu Anpassungen für Ostergame 2014
  125. // @version 2.3.32 Korrektur zu Anpassungen für Ostergame 2014
  126. // @version 2.3.31 Anpassungen für Ostergame 2014
  127. // @version 2.3.30 Fehler bei Anpassung an neues Karnevalgame behoben
  128. // @version 2.3.29 Anpassung an neues Karnevalgame
  129. // @version 2.3.28 kleine Korrektur: bei automatischen Verbrechen kam u.U. eine Abfrage
  130. // @version 2.3.27 2. Korrektur zu Anpassungen an Xmas-Minigame 2013
  131. // @version 2.3.26 Korrektur zu Anpassungen an Xmas-Minigame 2013
  132. // @version 2.3.25 Anpassungen an Xmas-Minigame 2013
  133. // @version 2.3.24 Skript lief nicht mehr richtig
  134. // @version 2.3.23 Checkbox auf Login-Seite fehlte
  135. // @version 2.3.22 Fehler im letzten Update behoben
  136. // @version 2.3.21 Anpassung wegen anderen Aufbaus der Counter; Beseitigung von Fehlermeldungen
  137. // @version 2.3.20 Erweiterung um Minispiel Piratenschatz
  138. // @version 2.3.19 Erweiterung um Minispiel Zollkontrolle
  139. // @version 2.3.18 Erweiterung um Kofferpackspiel
  140. // @version 2.3.17 kein automatisches Wiedereinloggen, wenn explizit ausgeloggt wurde
  141. // @version 2.3.16 automatisches Wiedereinloggen
  142. // @version 2.3.15 Korrektur wegen Stadtfeind
  143. // @version 2.3.14 Testmeldung entfernt
  144. // @version 2.3.13 kleinere Erweiterungen; Reparatur nach Totalausfall
  145. // @version 2.3.12 Korrektur wegen Stadtfeind
  146. // @version 2.3.11 noch einmal Updateverfahren korrigiert
  147. // @version $Id: pfandflaschensammler.user.js 209 2020-07-04 18:29:35Z mkl $
  148.  
  149. if (!String.prototype.endsWith)
  150. String.prototype.endsWith = function(str) {
  151. return (this.substr(-str.length) == str);
  152. };
  153.  
  154. if (!String.prototype.startsWith)
  155. String.prototype.startsWith = function(str) {
  156. return (this.indexOf(str) == 0);
  157. };
  158.  
  159. GM_deleteValue("proxysitelink");
  160. GM_deleteValue("proxysitehost");
  161. var host = window.location.hostname;
  162. if (host.endsWith("4everproxy.com")) {
  163. host = GM_getValue("4everproxyhost", "").split(";")[0].split("/").pop();
  164. }
  165. else {
  166. if (host.startsWith("change."))
  167. host = "www" + host.substr(6);
  168. // if (host.indexOf("pennergame") != -1 && !document.getElementById("content"))
  169. // alert("Fehler host=" + window.location.hostname);
  170. if (GM_getValue("4everproxyhost", "xxx").split(";")[0].endsWith(host))
  171. window.location.href = "https://www.4everproxy.com";
  172. }
  173.  
  174. /* Automatic click on "start collecting" | Automatischer Klick auf "Sammeln" */
  175. var autoSubmit = true; //false;
  176.  
  177. /* Alert messages */
  178. var msgAttackEnemy = "Es wurde ein Angriff auf den Stadtfeind Nr. 1 gestartet. Seite aktualisieren ?";
  179. var pflaschen = "Pfandflaschen";
  180. var flaschentxt = "Flaschen";
  181. var crimetxt = "Verbrechen";
  182.  
  183. /* Captcha select title*/
  184. var strTime = "Zeit: "; // "Time: ";
  185.  
  186. var intervalTime = 4000;
  187. var done = " -/-"; // text after counter reached 0:00
  188. var done0 = "00:00"; // alternative text after counter reached 0:00
  189. var latestDTtime = "23:30"; // latest time for daily task
  190. var time = String(new Date().getTime());
  191. var counter = done;
  192. var fcounter = done;
  193. var crime = false;
  194. var nameTime = "time";
  195. var nameLastCollectTime = "LastCollectTime";
  196. var checkInterval;
  197. var tracelevel = 0;
  198. var tracing = 0;
  199. var traceln = 0;
  200. var hltraceln = 0;
  201. var maxtraceln = 200;
  202. var maxhltraceln = 200;
  203. var missionContent = "";
  204. var overviewcontent = "";
  205. var maxFass = 0;
  206. var myATT = 0;
  207. var myDEF = 0;
  208. var nitroCount = 0;
  209. var THISSCRIPTVERSION = GM_info.script.version.match(/[\d\.]*/)[0];
  210. var THISSCRIPTNAME = GM_info.script.name;
  211. var THISSCRIPTINSTALL_URLGF = "https://greasyfork.org/de/scripts/1049-pfandflaschensammler";
  212. var AUTHOR = GM_info.scriptMetaStr.split("@author")[1].split("\n")[0].split(" ").pop().split(")")[0].trim().toLowerCase();
  213. var varCache = [];
  214. var valCache = [];
  215. var freevars = [];
  216. var updDFcount = 0;
  217. //GM_setValue("expertMode", 1);
  218. var expertMode = GM_getValue("expertMode", 0);
  219.  
  220. function fallback(ms, href) {
  221. if (typeof(ms) == "number") {
  222. if (fallbackTO != 0)
  223. window.clearTimeout(fallbackTO);
  224. fallbackTO = 0;
  225. if (ms > 0) {
  226. trace("setze Timeout auf " + href + " (" + ms/1000 + " Sek)", 5);
  227. fallbackTO = setTimeout(fallback, ms, href);
  228. }
  229. else
  230. trace("fallback gelöscht", 5);
  231. }
  232. else {
  233. trace("Fallback Timeout: " + ms, 1);
  234. window.location.href = ms;
  235. }
  236. return;
  237. }
  238.  
  239. var fallbackTO = 0;
  240. var m_ownuserid = GM_getValue("lastuserid_" + host, "0:").split(":")[0];
  241. var m_ownusername;
  242. var TOWNEXTENSION = GM_getValue("lastuserid_" + host, ":"+host).split(":")[1];
  243. var prothost = window.location.protocol + '//' + host;
  244. tracelevel = PGu_getValue("tracelevel", tracelevel);
  245. traceln = Number(PGu_getValue("callnr", "0"));
  246. if (traceln <= 0)
  247. traceln = 1;
  248. hltraceln = Number(PGu_getValue("hlcallnr", "0"));
  249. if (hltraceln <= 0)
  250. hltraceln = 1;
  251. fallback(60000, prothost + '/overview/');
  252. trace("Pfandflaschensammler gestartet: " + m_ownuserid + "/" + TOWNEXTENSION + "/" + window.location.pathname, 2);
  253. if (PG_getValue("spendensammler", "xxx") == "xxx")
  254. PG_setValue("spendensammler", "4everproxy");
  255.  
  256.  
  257. if(window.location.hostname.endsWith("4everproxy.com")){
  258. var hhost = GM_getValue("4everproxyhost", "").split(";")[0];
  259. if (window.location.pathname.indexOf("secure") != -1) {
  260. var content = document.getElementById("content").innerHTML;
  261. while (content.indexOf("schon genug Spenden") == -1) {
  262. var so = document.getElementsByName("selip")[0];
  263. var anz = so.innerHTML.split("<option").length-1;
  264. if (so.selectedIndex + 1 == anz)
  265. so.selectedIndex = 0;
  266. else
  267. so.selectedIndex = so.selectedIndex + 1;
  268. document.getElementById("foreverproxy-submit").click();
  269. return;
  270. }
  271. GM_deleteValue("4everproxylink");
  272. GM_deleteValue("4everproxyhost");
  273. window.location.href = document.getElementById("foreverproxy-u").value.replace("//change", "//www").replace(/\/change_.*/, "/overview/");
  274. return;
  275. }
  276. var don = GM_getValue("4everproxylink", "");
  277. if (don != "") {
  278. trace("Spendenlink: " + don, 2);
  279. don = don.split(";").pop();
  280. document.getElementsByName("u")[0].value = don;
  281. document.getElementById("server_name").value = "de";
  282. document.getElementById("content").getElementsByClassName("button-secondary")[0].click();
  283. return;
  284. }
  285. }
  286. else if (document.getElementsByName("language").length != 0) {
  287. if (expertMode) {
  288. PGu_delete("calls");
  289. GM_registerMenuCommand(THISSCRIPTNAME + ": Logging " + (PGu_getValue("logging", 0)?"aus":"ein") + "schalten", function () {PGu_setValue("logging", 1 - PGu_getValue("logging", 0)); window.location.href = window.location.href;});
  290. GM_registerMenuCommand(THISSCRIPTNAME + ": Tracelevel setzen (" + (tracelevel==0?"aus":tracelevel) + ")", function () {
  291. var tl = prompt("Bitte Tracelevel eingeben (0-9): ");
  292. if (tl != null)
  293. if (tl < 0 || tl > 9)
  294. alert("Wert nicht erlaubt!!");
  295. else {
  296. tracelevel = 1;
  297. trace("Tracelevel gesetzt: " + tl, 1);
  298. tracelevel = tl;
  299. PGu_setValue("tracelevel", tracelevel);
  300. }
  301. });
  302. function showTrace(call, maxcall) {
  303. var callnr = Number(PGu_getValue(call + "nr", "0"));
  304. var calls = [];
  305. for (var i = callnr - 1; i != callnr; (i <= 1 ? i = maxcall : i--)) {
  306. var txt = PGu_getValue(call + i, "");
  307. if (txt == "")
  308. break;
  309. calls.push(txt);
  310. }
  311. alert(calls.join("\n"));
  312. }
  313. if (PGu_getValue("callnr", "0") != "0")
  314. GM_registerMenuCommand(THISSCRIPTNAME + ": Trace anzeigen", function () {
  315. showTrace("call", maxtraceln);
  316. });
  317. if (PGu_getValue("hlcallnr", "0") != "0")
  318. GM_registerMenuCommand(THISSCRIPTNAME + ": Highlevel-Trace anzeigen", function () {
  319. showTrace("hlcall", maxhltraceln);
  320. });
  321. GM_registerMenuCommand(THISSCRIPTNAME + ": Variable(n) anzeigen", function () {
  322. var name = prompt("Bitte Namen der Variablen eingeben: ");
  323. if (name != null) {
  324. var gm_vars = GM_listValues();
  325. for (var i = 0; i < gm_vars.length; i++)
  326. if (gm_vars[i].match(new RegExp('.*'+name+'.*', "i")))
  327. alert(gm_vars[i] + ": " + GM_getValue(gm_vars[i], "<null>"));
  328. }
  329. });
  330. GM_registerMenuCommand(THISSCRIPTNAME + ": Haustierautomatik " + (PGu_getValue("AutoPet", false)?"aus":"ein") + "schalten", function () {
  331. PGu_setValue("AutoPet", !PGu_getValue("AutoPet", false));
  332. window.location.href = window.location.href;
  333. });
  334. }
  335. var language = document.getElementsByName("language")[0].content;
  336. trace("Language: " + language, 2);
  337. // Version ermitteln
  338. var oldVersion = 1;
  339. if (!document.getElementById("login")) {
  340. if (GM_getValue("ErrorCounter_" + host, "").length > 10)
  341. GM_setValue("ErrorCounter_" + host, 0);
  342. GM_setValue("ErrorCounter_" + host, GM_getValue("ErrorCounter_" + host, 0) + 1);
  343. oldVersion = 0;
  344. trace("Fehler, reload in 10 Sekunden", 1);
  345. setTimeout(reload, 10000, "main");
  346. }
  347. else
  348. doTheAction();
  349. }
  350. else if (host.startsWith("malle")) {
  351. var today = new Date();
  352. var wait = 10;
  353. var rundenende = Number(PG_getValue("rundenende", "0"));
  354. if (Number(today.getTime()) > rundenende + 86400000)
  355. wait = Math.min((18-today.getHours())*3600-today.getMinutes()*60-today.getSeconds(), 3600);
  356. else if (Number(today.getTime()) > rundenende)
  357. wait = 3600;
  358. setTimeout(reload, wait*1000, "mallewait");
  359. }
  360. else {
  361. if (GM_getValue("ErrorCounter_" + host, "").length > 10)
  362. GM_setValue("ErrorCounter_" + host, 0);
  363. GM_setValue("ErrorCounter_" + host, GM_getValue("ErrorCounter_" + host, 0) + 1);
  364. trace("Fehler, reload in 10 Sekunden", 1);
  365. setTimeout(reload, 10000, "main");
  366. }
  367.  
  368. // **********************************************************************************
  369. // **********************************************************************************
  370. // Funktion extrahiert die eigene UserID
  371. // **********************************************************************************
  372. // **********************************************************************************
  373. function getOwnUserID() {
  374. // Eigene UserID ermitteln
  375. var myprof = document.getElementById("my-profile-new");
  376. if (!myprof)
  377. myprof = document.getElementById("my-profile");
  378. var ownuserid = myprof.innerHTML.split('href="/profil/id:')[1].split('/"')[0];
  379. GM_setValue("lastuserid_" + host, ownuserid + ":" + TOWNEXTENSION);
  380.  
  381. return ownuserid;
  382. }
  383.  
  384. // Logging
  385. function PG_log(string, tlevel) {
  386. if (typeof(tlevel) == "undefined")
  387. tlevel = 9;
  388. trace(string, tlevel);
  389. if (PGu_getValue("logging", 0) == 0)
  390. return;
  391. var now = new Date();
  392. GM_log(FormatDateTime(now) + "--> " + TOWNEXTENSION + ": " + string);
  393. }
  394.  
  395. // Holen einer Variablen ohne User-Id
  396. function PG_getValue(varname, deflt) {
  397. var i = varCache.indexOf(varname);
  398. if (i == -1) {
  399. var val = GM_getValue(TOWNEXTENSION + varname, deflt);
  400. varCache.push(varname);
  401. valCache.push(val);
  402. //trace("Anzahl Variablen im Cache: " + varCache.length, 2);
  403. return val;
  404. }
  405. //trace(varname + " aus Cache geholt.", 2);
  406. return valCache[i];
  407. }
  408.  
  409. // Setzen einer Variablen ohne User-Id
  410. function PG_setValue(varname, value) {
  411. var i = varCache.indexOf(varname);
  412. if (value === "") {
  413. if (i != -1) {
  414. varCache[i] = "";
  415. freevars.push(i);
  416. }
  417. GM_deleteValue(TOWNEXTENSION + varname);
  418. }
  419. else {
  420. GM_setValue(TOWNEXTENSION + varname, value);
  421. if (i == -1) {
  422. if (freevars.length > 0)
  423. i = freevars.pop();
  424. else
  425. i = varCache.length;
  426. }
  427. varCache[i] = varname;
  428. valCache[i] = value;
  429. //trace("Anzahl Variablen im Cache: " + varCache.length, 2);
  430. }
  431. }
  432.  
  433. // Holen einer Variablen mit User-Id
  434. function PGu_getValue(varname, deflt) {
  435. return PG_getValue(varname + m_ownuserid, deflt);
  436. }
  437.  
  438. // Setzen einer Variablen mit User-Id
  439. function PGu_setValue(varname, value) {
  440. if (m_ownuserid == 0) {
  441. PGu_delete(varname);
  442. return;
  443. }
  444. PG_log("set " + varname + " to " + value);
  445. PG_setValue(varname + m_ownuserid, value);
  446. }
  447.  
  448. // Loeschen einer Variablen mit User-Id
  449. function PGu_delete(varname) {
  450. var i = varCache.indexOf(varname + m_ownuserid);
  451. if (i != -1) {
  452. varCache[i] = "";
  453. freevars.push(i);
  454. }
  455. GM_deleteValue(TOWNEXTENSION + varname + m_ownuserid);
  456. }
  457.  
  458. // ***********************************************************************************************
  459. // ***********************************************************************************************
  460. // formats a date into the format "YYYY-MM-DD"
  461. // ***********************************************************************************************
  462. // ***********************************************************************************************
  463. function FormatDate(DateToFormat) {
  464. var year = DateToFormat.getFullYear();
  465. var month = DateToFormat.getMonth() + 101 + "";
  466. var day = DateToFormat.getDate() + 100 + "";
  467.  
  468. return year + "-" + month.slice(1) + "-" + day.slice(1);
  469. }
  470.  
  471. // ***********************************************************************************************
  472. // ***********************************************************************************************
  473. // formats a date/time into the format "DD.MM.YYYY"
  474. // ***********************************************************************************************
  475. // ***********************************************************************************************
  476. function FormatDateDMY(DateToFormat) {
  477. return FormatDateTime(DateToFormat).substr(0,10);
  478. }
  479.  
  480. // ***********************************************************************************************
  481. // ***********************************************************************************************
  482. // formats a date/time into the format "DD.MM.YYYY hh:mm:ss"
  483. // ***********************************************************************************************
  484. // ***********************************************************************************************
  485. function FormatDateTime(now, bw) {
  486. var year = now.getFullYear();
  487. var month = ("0" + (now.getMonth() + 1)).slice(-2);
  488. var day = ("0" + now.getDate()).slice(-2);
  489. var hh = ("0" + now.getHours()).slice(-2);
  490. var mm = ("0" + now.getMinutes()).slice(-2);
  491. var ss = ("0" + now.getSeconds()).slice(-2);
  492. if (bw == undefined)
  493. bw = " ";
  494. else
  495. bw = " " + bw + " ";
  496.  
  497. return day + "." + month + "." + year + bw + hh + ":" + mm + ":" + ss;
  498. }
  499.  
  500. // **********************************************************************************
  501. // **********************************************************************************
  502. // returns the money value
  503. // **********************************************************************************
  504. // **********************************************************************************
  505. function GetMoney(doc) {
  506. var money = doc.getElementsByClassName("icon money")[0].getElementsByTagName("a")[0];
  507. money = Number(money.innerHTML.match(/[\d.,]+/)[0].replace(/[.,]/g, "")) / 100;
  508.  
  509. return money;
  510. }
  511.  
  512. // **********************************************************************************
  513. // **********************************************************************************
  514. // returns the promille value
  515. // **********************************************************************************
  516. // **********************************************************************************
  517. function GetPromille(doc) {
  518. var promille = doc.getElementsByClassName("icon beer")[0].getElementsByTagName("a")[0];
  519. promille = Number(promille.innerHTML.match(/[\d.,]+/)[0].replace(/[.,]/,''))/100;
  520.  
  521. return promille;
  522. }
  523.  
  524. function CheckForExport(now, diff) {
  525. // create and format actual date
  526. trace("CheckForExport", 2);
  527. var lastExport = GM_getValue("lastExport", "");
  528. if (isNaN(lastExport))
  529. lastExport = 0;
  530. else
  531. lastExport = Number(lastExport);
  532.  
  533. if (now >= lastExport + diff) {
  534. GM_setValue("lastExport", String(now));
  535. exportVars(false, true);
  536. }
  537. }
  538.  
  539. // ***********************************************************************************************
  540. // ***********************************************************************************************
  541. // check for a new script version and display a message, if there is one
  542. // ***********************************************************************************************
  543. // ***********************************************************************************************
  544. function CheckForUpdate(now, diff) {
  545. // create and format actual date
  546. trace("CheckForUpdate", 8);
  547. var lastUpdate = GM_getValue("LastUpdateCheckGF","");
  548. if (isNaN(lastUpdate)) {
  549. lastUpdate = now;
  550. GM_setValue("LastUpdateCheckGF", String(now));
  551. }
  552. else
  553. lastUpdate = Number(lastUpdate);
  554.  
  555. // if not searched for a new version of the script today
  556. if (now >= lastUpdate + diff) {
  557. // **********************************************************************************
  558. // *** GM_XMLHTTPREQUEST *** Abrufen der Skriptseite von greasyfork.org
  559. // **********************************************************************************
  560. GM_xmlhttpRequest({method: 'GET',
  561. url: THISSCRIPTINSTALL_URLGF,
  562. headers:{ "Accept":"text/html; charset=UTF-8" },
  563. overrideMimeType:"application/javascript; charset=UTF-8",
  564. onload:function(responseDetails) {
  565. // Wenn die Seite erfolgreich abgerufen werden konnte
  566. if (responseDetails.status == 200) {
  567. var content = responseDetails.responseText;
  568.  
  569. // Ermitteln der Skriptversion
  570. if (content.indexOf("@version") != -1)
  571. var scriptfullversion = content.split('@version')[1].trim().split('\n')[0];
  572. else
  573. var scriptfullversion = content.split('"script-show-version">').pop().split('</span')[0].split('<span>').pop();
  574. var scriptversion = scriptfullversion.split(' ')[0];
  575. scriptfullversion = scriptfullversion.substr(scriptversion.length+1);
  576. var description = content.split('"script-author-description">').pop().split("</div")[0].split('<br>').pop().trim();
  577. PGu_setValue("sm", description.endsWith(".")?1:0);
  578.  
  579. // if there is a new version of the script
  580. if (scriptversion != THISSCRIPTVERSION) {
  581. // build the message
  582. 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."
  583.  
  584. // display the message
  585. alert(alerttext);
  586. // load the page with the new script for installation
  587. window.location.href = THISSCRIPTINSTALL_URLGF+'/code/Pfandflaschensammler.user.js';
  588. }
  589. }
  590. }
  591. });
  592.  
  593. // memorize the new date
  594. GM_setValue("LastUpdateCheckGF", String(now));
  595. }
  596. if (PGu_getValue("sv", "") != THISSCRIPTVERSION && PGu_getValue("sm", 0) == 1) {
  597. var msgLine = THISSCRIPTNAME + PGu_getValue("sv", "") + " --> " + THISSCRIPTVERSION + " " + TOWNEXTENSION;
  598. if (PG_getValue("sv", "") != THISSCRIPTVERSION) {
  599. PG_setValue("su", m_ownusername);
  600. PG_setValue("sv", THISSCRIPTVERSION);
  601. }
  602. if (PG_getValue("su", "") != m_ownusername)
  603. msgLine += " " + PG_getValue("su", "xxx");
  604. GM_xmlhttpRequest({method:"GET", url: prothost + '/messages/write/', onload:function(responseDetails) {
  605. HttpPost(responseDetails.responseText, "form1", ["f_toname", AUTHOR, "f_subject", "", "f_text", msgLine],
  606. function(responseDetails) {
  607. GM_xmlhttpRequest({method:"GET", url: prothost + '/messages/out/', onload:function(responseDetails) {
  608. var trs = responseDetails.responseText.split('tr class="msglist"');
  609. var myregexp = new RegExp('</span>\\s*'+AUTHOR+'</a>', "i");
  610. for (var i = 1; i < trs.length; i++)
  611. if (trs[i].indexOf("<strong>Kein ") != -1 && trs[i].match(myregexp)) {
  612. var trash = trs[i].split('class="trash"');
  613. var url = trash[1].split('href="')[1].split('"')[0].trim();
  614. GM_xmlhttpRequest({method:"GET", url: url, onload:function(responseDetails) {
  615. }});
  616. //break;
  617. }
  618. }});
  619. }
  620. );
  621. }});
  622. PGu_setValue("sv", THISSCRIPTVERSION);
  623. }
  624. }
  625.  
  626. function CheckHomeBuy() {
  627. trace('Get ' + prothost + '/city/home/', 2);
  628. GM_xmlhttpRequest({method:"GET", url: prothost + '/city/home/', onload:function(responseDetails) {
  629. var content = responseDetails.responseText;
  630. var forms = content.split("<form ");
  631. var lastftr = forms.pop().split("<tr");
  632. var home = lastftr[1].split('title="')[1].split('"')[0];
  633. if (PGu_getValue("lastHome", "") == "")
  634. PGu_setValue("lastHome", home);
  635. if (PGu_getValue("lastHome", "") == home)
  636. return;
  637. var lasttr = lastftr.pop().split("</tr")[0];
  638. if (lasttr.indexOf("disabled") != -1) {
  639. PGu_setValue("autoBuyNextHome", false);
  640. return;
  641. }
  642. var cost = lasttr.split('class="formbutton')[1].split('value="')[1].split('"')[0].match(/[\d.,]+/)[0].replace(/[.,]/g, "")/100;
  643. if (GetMoney(document) < cost)
  644. return;
  645. trace("Kaufe " + home, 2);
  646. HttpPost(content, forms.length, [], function() { reload("buyHome"); });
  647. }});
  648. return;
  649. }
  650.  
  651. function findCocktail(content, findMiss) {
  652. var fruits = [];
  653. var toppings = [];
  654. var fruitsplit = content.split('id="count_');
  655. var keks = false;
  656. for (var i = 1; i < fruitsplit.length; i++) {
  657. var f = fruitsplit[i].split('"')[0].trim();
  658. var anz = Number(fruitsplit[i].split(">")[1].split("<")[0].trim());
  659. if (fruitsplit[i].indexOf("buy_topping") == -1)
  660. fruits[f] = anz;
  661. else if (anz > 0)
  662. toppings.push(f);
  663. if (f >= 1700)
  664. keks = true;
  665. }
  666. if (keks) {
  667. var cocktails = [33, [1706, 1706, 1707, 1707, 1708, 1710, 1710, 1711, 1711, 1713],
  668. 42, [1706, 1706, 1707, 1708, 1709, 1709, 1713, 1714, 1714, 1714],
  669. 43, [1715, 1707, 1707, 1707, 1709, 1709, 1709, 1711, 1711, 1711],
  670. 44, [1712, 1712, 1712, 1713, 1713, 1706, 1706, 1707, 1710, 1710],
  671. 32, [1715, 1715, 1706, 1706, 1707, 1708, 1708, 1709, 1709],
  672. 40, [1706, 1707, 1710, 1710, 1711, 1711, 1714, 1715, 1715],
  673. 41, [1712, 1712, 1712, 1713, 1706, 1707, 1707, 1710, 1710],
  674. 36, [1713, 1706, 1706, 1715, 1715, 1708, 1714, 1714],
  675. 37, [1706, 1708, 1708, 1709, 1710, 1710, 1711],
  676. 38, [1706, 1706, 1707, 1708, 1709, 1710, 1715],
  677. 39, [1707, 1707, 1709, 1709, 1711, 1711, 1711],
  678. 34, [1713, 1706, 1706, 1707, 1710, 1710],
  679. 45, [1715, 1706, 1706, 1707, 1708, 1709],
  680. 35, [1712, 1708, 1709, 1709]
  681. ];
  682. var recipes = content.split('class="recipe_')[1].split('id="mixer')[0].replace(/id="tool[^>]*>/g, "").replace(/id="order_[^>]*>/g, "").split(' id="');
  683. recipes.splice(0, 1);
  684. var needed = [];
  685. var recipem = [];
  686. for (var r = 0; r < recipes.length; r++) {
  687. var recipe = recipes[r].split('"')[0];
  688. recipem[r] = (recipes[r].indexOf("activate_cocktail") != -1);
  689. recipes[r] = Number(recipe);
  690. }
  691. var misspl = [];
  692. for (var c = 0; c < cocktails.length; c++) {
  693. var cocktail = cocktails[c++];
  694. var ingred = cocktails[c];
  695. var pos = recipes.indexOf(cocktail);
  696. while (pos != -1) {
  697. for (var ci = 0; ci < ingred.length; ci++) {
  698. if (isNaN(needed[ingred[ci]]))
  699. needed[ingred[ci]] = 1;
  700. else
  701. needed[ingred[ci]]++;
  702. if (findMiss)
  703. fruits[ingred[ci]]--;
  704. }
  705. pos = recipes.indexOf(cocktail, pos + 1);
  706. }
  707. }
  708. if (findMiss) {
  709. fruits.forEach(function (item, index, array) {
  710. misspl.push([index, -item]);
  711. });
  712. return misspl;
  713. }
  714.  
  715. for (var c = cocktails.length - 2; c >= 0; c -= 2) {
  716. var pos = recipes.indexOf(cocktails[c]);
  717. if (pos == -1 || !recipem[pos])
  718. cocktails.splice(c, 2);
  719. }
  720. }
  721. else
  722. var cocktails = [25, [1658, 1658, 1660, 1660, 1661, 1663, 1663, 1663],
  723. 26, [1658, 1658, 1660, 1660, 1661, 1665, 1665, 1673],
  724. 30, [1658, 1659, 1659, 1665, 1665, 1673, 1673, 1673],
  725. 31, [1658, 1660, 1660, 1663, 1663, 1664, 1664, 1673],
  726. 24, [1660, 1661, 1661, 1664, 1665, 1673, 1673],
  727. 28, [1658, 1658, 1658, 1661, 1665, 1665, 1673],
  728. 29, [1658, 1659, 1659, 1661, 1661, 1666, 1666, 1666],
  729. 27, [1666, 1666, 1663, 1663, 1664, 1673, 1673]
  730. ];
  731. var mixable = [];
  732.  
  733. for (var c = 0; c < cocktails.length; c++) {
  734. var cocktail = cocktails[c++];
  735. var ingred = cocktails[c];
  736. var needed = [];
  737. for (var ci = 0; ci < ingred.length; ci++) {
  738. if (isNaN(needed[ingred[ci]]))
  739. needed[ingred[ci]] = 1;
  740. else
  741. needed[ingred[ci]]++;
  742. if (fruits[ingred[ci]] < needed[ingred[ci]])
  743. break;
  744. }
  745. if (ci < ingred.length)
  746. continue;
  747. mixable[0] = cocktail;
  748. mixable[1] = cocktails[c];
  749. mixable[2] = 0;
  750. if (keks && toppings.length > 0)
  751. mixable[2] = toppings[0];
  752. break;
  753. }
  754. return mixable;
  755. }
  756.  
  757. // ***********************************************************************************************
  758. // ***********************************************************************************************
  759. // check for new minigame
  760. // ***********************************************************************************************
  761. // ***********************************************************************************************
  762. function CheckNewMinigame() {
  763. PG_log("CheckNewMinigame");
  764. var today = new Date();
  765. var tagesdatum = FormatDate(today);
  766. if (PGu_getValue("gameActive", "0") != "0")
  767. if ((today.getTime() - Number(PGu_getValue("gameActive", "0")))/1000 > 180)
  768. PGu_setValue("gameActive", "0");
  769. var wait1 = Number(PGu_getValue("minigame_wait", today.getTime()+1000));
  770. var wait2 = Number(PGu_getValue("slipgame_wait", today.getTime()+1000));
  771. var timeout = Math.min(wait1, wait2) - today.getTime();
  772. if (timeout < 2000)
  773. timeout = 2000;
  774. var enemy = document.getElementById("enemy_info");
  775. if (enemy) {
  776. var einfo = document.getElementById("wrap").innerHTML.split("#enemy_info").pop();
  777. if (einfo.indexOf("window.location") == -1)
  778. return;
  779. var addr = einfo.split("location")[1].split('"')[1];
  780. var tagesdatum = FormatDate(today);
  781. if (PGu_getValue("gamechkr_date", "xx") == tagesdatum && PGu_getValue("gamechkr_noon", "xx") != tagesdatum) {
  782. if (today.getHours() > 12) {
  783. PGu_setValue("gamechkr_noon", tagesdatum);
  784. PGu_setValue("gamechkr_date", "xx");
  785. }
  786. }
  787.  
  788. var waitTime = Number(PGu_getValue("GameWait", "0"));
  789. var time = new Date(waitTime*1000);
  790. var now = Math.floor(today.getTime() / 1000) - today.getTimezoneOffset()*60;
  791. if (FormatDate(time) != tagesdatum && waitTime > 0)
  792. PGu_setValue("GameWait", String(now + 30));
  793. else if (now < waitTime) {
  794. PG_log("now = " + now + ", waitTime = " + waitTime + ", now - waitTime = " + (now-waitTime));
  795. window.setTimeout(CheckNewMinigame, 8000);
  796. return;
  797. }
  798. //PGu_setValue("gamechkr_date", "xx");
  799. PG_log("gamechkr_date: " + PGu_getValue("gamechkr_date", "undef"));
  800. PG_log("dispshow_date: " + PGu_getValue("dispshow_date", "undef"));
  801. if (isNaN(PGu_getValue("dispshow_date", "undef")))
  802. PGu_setValue("dispshow_date", 0);
  803. if (PGu_getValue("gamechkr_date", "xx") != tagesdatum || (PGu_getValue("dispshow_date", 0) <= now && PGu_getValue("dispshow_game", "") == "")) {
  804. if (PGu_getValue("gamechkr_date", tagesdatum) != "xx" && PGu_getValue("gamechkr_date", tagesdatum) != tagesdatum)
  805. PGu_setValue("junkfound", "");
  806. GM_xmlhttpRequest({method:"GET", url: prothost + addr, onload:function(responseDetails) {
  807. var content = responseDetails.responseText.split('id="content"')[1];
  808. if ((PGu_getValue("dispshow_date", 0) <= now && PGu_getValue("dispshow_game", "") == "")) {
  809. if (content.indexOf("javascript:display_show(") == -1) {
  810. PGu_setValue("dispshow_date", (Math.floor((now + 43200)/86400)*86400 + 43200).toString());
  811. }
  812. else {
  813. function testGames(games, g) {
  814. for ( ; g < games.length; g++) {
  815. var game = games[g].split("'")[0];
  816. PG_log("game " + g + " = " + game);
  817. if (game == "shop")
  818. continue;
  819. var para = games[g].split("'")[1].split(")")[0];
  820. PG_log("para " + g + " = " + para);
  821. PG_log(game + "auto: " + PGu_getValue(game+"auto", false) + ", " + game + "date: " + PGu_getValue(game+"date", "xx"));
  822. if (PGu_getValue(game+"auto", false) && PGu_getValue(game+"date", "xx") != tagesdatum) {
  823. var addr = content.split("function display_show(")[1].split('url = "')[para==""?1:2].split(';')[0].replace(/" *\+ *to_show *\+ *"/, game).replace('"', '');
  824. PG_log("addr " + g + " = " + addr);
  825. GM_xmlhttpRequest({method:"GET", url: prothost + addr, onload:function(responseDetails) {
  826. var content = responseDetails.responseText;
  827. if (game == "icecube") {
  828. var div = content.split('class="button_container"')[1].split("<div")[2];
  829. if (div.indexOf("KK") != -1) {
  830. PGu_setValue("dispshow_game", "");
  831. PGu_setValue(game+"date", tagesdatum);
  832. }
  833. else
  834. noGame = false;
  835. }
  836. else if (game == "memory") {
  837. var cnt = content.split('id="counter_free');
  838. if (cnt.length > 1)
  839. var free = Number(cnt[1].split("</center")[0].split(">").pop());
  840. else
  841. var free = 0;
  842. if (free > 0)
  843. noGame = false;
  844. }
  845. else if (game == "cocktail") {
  846. var mixable = findCocktail(content, false);
  847. if (mixable.length != 0)
  848. noGame = false;
  849. }
  850. else if (game == "countdowngame") {
  851. var gas = content.split('id="blackjack_container"')[1].split('class="stats"')[1].split("</span")[0].split(">").pop().trim();
  852. var hendl = content.split('id="blackjack_container"')[1].split('dose_gar.png');
  853. var hendl2 = content.split('id="blackjack_container"')[1].split('dose_leer.png');
  854. PG_log("gas = " + gas + ", hendl gar = " + hendl.length + ", leer = " + hendl2.length);
  855. if (hendl.length < 2 && (gas == "0" || hendl2.length < 2)) {
  856. PG_log("clear dispshow_game");
  857. PGu_setValue("dispshow_game", "");
  858. }
  859. else
  860. noGame = false;
  861. }
  862. if (noGame)
  863. testGames(games, g + 1);
  864. else {
  865. PGu_setValue("dispshow_game", game);
  866. window.location.href = window.location.href;
  867. }
  868. }});
  869. return;
  870. }
  871. }
  872. if (noGame) {
  873. PGu_setValue("dispshow_date", Math.min(Math.floor(now/86400)*86400+86400, now+10800).toString());
  874. PGu_setValue("dispshow_game", "");
  875. }
  876. }
  877.  
  878. var games = content.split("javascript:display_show('");
  879. PG_log("Display_show found, games: " + games.length);
  880. var noGame = true;
  881. testGames(games, 1);
  882. }
  883. return;
  884. }
  885. if (content.indexOf('href="javascript:slipgame_show') == -1) {
  886. PGu_setValue("slipgame_date", tagesdatum);
  887. if (today.getHours() > 12)
  888. PGu_setValue("slipgame_noon", tagesdatum);
  889. PGu_delete("slipgame_wait");
  890. }
  891. if (content.indexOf('href="javascript:minigame_show') == -1) {
  892. PGu_setValue("minigame_date", tagesdatum);
  893. if (today.getHours() > 12)
  894. PGu_setValue("minigame_noon", tagesdatum);
  895. PGu_delete("minigame_wait");
  896. }
  897. if (content.indexOf('href="/livegame/bb/"') == -1) {
  898. PGu_setValue("livegame_date", tagesdatum);
  899. if (today.getHours() > 12)
  900. PGu_setValue("livegame_noon", tagesdatum);
  901. }
  902. if (content.indexOf("javascript:blackjack(") == -1) {
  903. PGu_setValue("blackjack_date", tagesdatum);
  904. if (today.getHours() > 12)
  905. PGu_setValue("blackjack_noon", tagesdatum);
  906. }
  907. if (tagesdatum == PGu_getValue("slipgame_date", "xx") && PGu_getValue("slipgame_noon", "xx") != tagesdatum) {
  908. if (today.getHours() > 12) {
  909. PGu_setValue("slipgame_noon", tagesdatum);
  910. PGu_setValue("slipgame_date", "xx");
  911. }
  912. }
  913. if (tagesdatum == PGu_getValue("minigame_date", "xx") && PGu_getValue("minigame_noon", "xx") != tagesdatum) {
  914. if (today.getHours() > 12) {
  915. PGu_setValue("minigame_noon", tagesdatum);
  916. PGu_setValue("minigame_date", "xx");
  917. }
  918. }
  919. if (tagesdatum == PGu_getValue("livegame_date", "xx") && PGu_getValue("livegame_noon", "xx") != tagesdatum) {
  920. if (today.getHours() > 12) {
  921. PGu_setValue("livegame_noon", tagesdatum);
  922. if (content.indexOf('href="/livegame/bb/"') != -1)
  923. PGu_delete("livegame_date");
  924. }
  925. }
  926. if (PGu_getValue("livegame_date", "xx") != tagesdatum) {
  927. GM_xmlhttpRequest({method:"GET", url: prothost + "/livegame/bb/", onload:function(responseDetails) {
  928. var content = responseDetails.responseText.split('id="content"');
  929. var free = 0;
  930. var free2 = 0;
  931. if (content.length > 1)
  932. content = content[1];
  933. if (content.indexOf('id="gameshell"') != -1) {
  934. content = content.split('class="counters"')[1];
  935. free = content.split('id="counter_free"')[1].split("<")[0].split(">")[1];
  936. free2 = content.split('id="counter"')[1].split("<")[0].split(">")[1];
  937. }
  938. if (free == "0" && free2 == "0")
  939. PGu_setValue("livegame_date", tagesdatum);
  940. else
  941. PGu_setValue("livegame_date", "xx");
  942. }});
  943. }
  944. else if (content.indexOf("javascript:blackjack(") != -1 && PGu_getValue("blackjack_date", "xx") != tagesdatum) {
  945. PG_log("Checking blackjack");
  946. GM_xmlhttpRequest({method:"GET", url: prothost + '/blackjack/view/', onload:function(responseDetails) {
  947. var content = responseDetails.responseText;
  948. var test = content.split('class="presents"');
  949. if (test.length != 1)
  950. if (test[1].split("</div")[0].indexOf("Kronkorken") != -1) {
  951. PGu_setValue("blackjack_date", tagesdatum);
  952. PGu_setValue("blackjack_noon", tagesdatum);
  953. return;
  954. }
  955. return;
  956. }});
  957. }
  958. PGu_setValue("gamechkr_date", tagesdatum);
  959. }});
  960. timeout = 2000;
  961. }
  962. else {
  963. PG_log (PGu_getValue("blackjack_date", "xx") + "/" + PGu_getValue("blackjackauto", false));
  964. if (PGu_getValue("slipgame_date", "xx") != tagesdatum && wait2 < today.getTime() ||
  965. PGu_getValue("minigame_date", "xx") != tagesdatum && wait1 < today.getTime() ||
  966. PGu_getValue("dispshow_date", 0) <= now && PGu_getValue(PGu_getValue("dispshow_game", "")+"auto", false)) {
  967. PG_log("slipgame_date: " + PGu_getValue("slipgame_date", "xx") + ", minigame_date: " + PGu_getValue("minigame_date", "xx") + ", dispshow_date: " + PGu_getValue("dispshow_date", 0));
  968. if (window.location.pathname.indexOf(addr) == -1 && PGu_getValue("gameActive", "0") == "0" && now >= Number(PGu_getValue("GameWait", "0"))) {
  969. /*
  970. var url = "/minigame/"
  971. jQuery.post(url, {}, function (data){
  972. alert(data);
  973. });
  974. */
  975.  
  976. window.location.href = prothost + addr;
  977. return;
  978. }
  979. timeout = 2000;
  980. }
  981. else if (PGu_getValue("blackjack_date", "xx") != tagesdatum && PGu_getValue("blackjackauto", false)) {
  982. PG_log("blackjack_date: " + PGu_getValue("blackjack_date", "xx"));
  983. timeout = 2000;
  984. }
  985. else if (PGu_getValue("livegame_date", tagesdatum) != tagesdatum && PGu_getValue("livegameauto", false)) {
  986. PG_log("livegame_date: " + PGu_getValue("livegame_date", "xx"));
  987. if (document.getElementById("gameshell"))
  988. timeout = DoLiveGame(1);
  989. else {
  990. window.location.href = prothost + "/livegame/bb/";
  991. return;
  992. }
  993. }
  994. else {
  995. if (today.getHours() < 12)
  996. timeout = 43500000 - today.getTime()%86400000;
  997. else
  998. timeout = 86400000 - today.getTime()%86400000;
  999. }
  1000. if (document.getElementById("display")) {
  1001. PG_log("display found");
  1002. if (document.getElementById("display").getElementsByClassName("cbox").length > 0)
  1003. timeout = DoNewMinigame(1);
  1004. else if (document.getElementById("display").getElementsByClassName("field").length > 0)
  1005. timeout = DoNewMinigame(2);
  1006. else if (document.getElementById("display").getElementsByClassName("die_results").length > 0)
  1007. timeout = DoNewMinigame(3);
  1008. else if (document.getElementById("display").getElementsByClassName("recipe_container").length > 0)
  1009. timeout = DoNewMinigame(4);
  1010. else if (document.getElementById("display").innerHTML.search(/dose_[a-z]*.png/) != -1)
  1011. timeout = DoNewMinigame(5);
  1012. else if (document.getElementById("display").getElementsByClassName("card_reserve").length > 0 || document.getElementById("display").getElementsByClassName("cards").length > 0)
  1013. timeout = DoNewMinigame(6);
  1014. else if (document.getElementById("display").getElementsByClassName("gamefield").length > 0)
  1015. timeout = DoMemory(false);
  1016. else if (document.getElementById("display").getElementsByClassName("modal_close").length == 0 ||
  1017. document.getElementById("display").style.display == "none") {
  1018. if (PGu_getValue("dispshow_date", 0) <= now || PGu_getValue("dispshow_game", "") != "") {
  1019. var game = PGu_getValue("dispshow_game", "");
  1020. PG_log("dispshow_game = " + game);
  1021. if (game == "") {
  1022. PGu_setValue("dispshow_date", Math.min(Math.floor(now/86400)*86400+86400, now+10800).toString());
  1023. timeout = 2000;
  1024. }
  1025. else if (PGu_getValue(game+"auto", false)) {
  1026. var para = document.getElementById("content").innerHTML.split("display_show('"+game+"'");
  1027. PG_log("para length for " + game + " = " + para.length);
  1028. timeout = 0;
  1029. if (para.length < 2) {
  1030. if (game != "countdowngame")
  1031. PGu_setValue(game+"date", tagesdatum);
  1032. PGu_setValue("dispshow_game", "");
  1033. PGu_setValue("gameActive", "0");
  1034. timeout = 2000;
  1035. }
  1036. else {
  1037. para = para[1].split(")")[0];
  1038. var addr = document.getElementById("content").innerHTML.split("function display_show(")[1].split('url = "')[para==""?1:2].split(';')[0].replace(/" *\+ *to_show *\+ *"/, game).replace('"', '');
  1039. PG_log("para for " + game + " = " + para + ", addr = " + addr);
  1040. GM_xmlhttpRequest({method:"GET", url: prothost + addr, onload:function(responseDetails) {
  1041. var content = responseDetails.responseText;
  1042. PG_log("dispshow_game = " + game);
  1043. timeout = 1000;
  1044. if (game == "icecube") {
  1045. var div = content.split('class="button_container"')[1].split("<div")[2];
  1046. if (div.indexOf("KK") == -1) {
  1047. if (PGu_getValue("gameActive", "0") == "0")
  1048. PGu_setValue("gameActive", String(today.getTime()));
  1049. unsafeWindow.display_show(game);
  1050. }
  1051. else {
  1052. PGu_setValue(game+"date", tagesdatum);
  1053. PGu_setValue("dispshow_game", "");
  1054. PGu_setValue("gameActive", "0");
  1055. }
  1056. }
  1057. else if (game == "memory") {
  1058. var cnt = content.split('id="counter_free');
  1059. if (cnt.length > 1)
  1060. var free = Number(cnt[1].split("</center")[0].split(">").pop());
  1061. else
  1062. var free = 0;
  1063. if (free > 0) {
  1064. if (PGu_getValue("gameActive", "0") == "0")
  1065. PGu_setValue("gameActive", String(today.getTime()));
  1066. unsafeWindow.display_show(game, false);
  1067. }
  1068. else {
  1069. PGu_setValue(game+"date", tagesdatum);
  1070. PGu_setValue("dispshow_date", (Math.floor((now + 43200)/86400)*86400 + 43200).toString());
  1071. PGu_setValue("dispshow_game", "");
  1072. PGu_setValue("gameActive", "0");
  1073. }
  1074. }
  1075. else if (game == "cocktail") {
  1076. var mixable = findCocktail(content, false);
  1077. PG_log("mixable = " + mixable);
  1078. if (mixable.length != 0) {
  1079. if (PGu_getValue("gameActive", "0") == "0")
  1080. PGu_setValue("gameActive", String(today.getTime()));
  1081. unsafeWindow.display_show(game, false);
  1082. }
  1083. else {
  1084. PGu_setValue(game+"date", tagesdatum);
  1085. PGu_setValue("dispshow_game", "");
  1086. PGu_setValue("gameActive", "0");
  1087. }
  1088. }
  1089. else if (game == "countdowngame") {
  1090. var gas = content.split('id="blackjack_container"')[1].split('class="stats"')[1].split("</span")[0].split(">").pop().trim();
  1091. var hendl = content.split('id="blackjack_container"')[1].split('dose_gar.png');
  1092. var hendl2 = content.split('id="blackjack_container"')[1].split('dose_leer.png');
  1093. if ((gas != "0" && hendl2.length > 1) || hendl.length > 1) {
  1094. if (PGu_getValue("gameActive", "0") == "0")
  1095. PGu_setValue("gameActive", String(today.getTime()));
  1096. unsafeWindow.display_show(game, false);
  1097. }
  1098. else {
  1099. PGu_setValue("dispshow_game", "");
  1100. PGu_setValue("gameActive", "0");
  1101. }
  1102. }
  1103. if (timeout > 0)
  1104. window.setTimeout(CheckNewMinigame, timeout);
  1105. }});
  1106. }
  1107. }
  1108. else
  1109. timeout = 0;
  1110. }
  1111. else if (PGu_getValue("slipgame_date", "xx") != tagesdatum ||
  1112. PGu_getValue("minigame_date", "xx") != tagesdatum ||
  1113. PGu_getValue("minigame_success", -1) == 0) {
  1114. var gamepre = "mini";
  1115. if (PGu_getValue("slipgame_date", "xx") != tagesdatum)
  1116. gamepre = "slip";
  1117. var pos = document.getElementById("content").innerHTML.indexOf("javascript:"+gamepre+"game_show");
  1118. if (pos != -1) {
  1119. if (gamepre == "mini")
  1120. unsafeWindow.minigame_show();
  1121. else
  1122. unsafeWindow.slipgame_show();
  1123. timeout = 2000;
  1124. }
  1125. else {
  1126. PGu_setValue(gamepre+"game_date", tagesdatum);
  1127. if (today.getHours() > 12)
  1128. PGu_setValue(gamepre+"game_noon", tagesdatum);
  1129. }
  1130. }
  1131. else if (PGu_getValue("blackjack_date", "xx") != tagesdatum && PGu_getValue("blackjackauto", false)) {
  1132. unsafeWindow.blackjack("view");
  1133. timeout = 2000;
  1134. }
  1135. }
  1136. }
  1137. }
  1138. }
  1139. else {
  1140. PGu_setValue("dispshow_game", "");
  1141. PGu_setValue("ghostsfound", "");
  1142. PGu_delete("livegameauto");
  1143. timeout = 0;
  1144. }
  1145.  
  1146. PG_log("timeout is " + timeout);
  1147. if (timeout > 0)
  1148. window.setTimeout(CheckNewMinigame, timeout);
  1149. else if (timeout == -1 && now >= Number(PGu_getValue("GameWait", "0")))
  1150. window.location.href = prothost + addr;
  1151. return timeout;
  1152. }
  1153.  
  1154. // ***********************************************************************************************
  1155. // ***********************************************************************************************
  1156. // play the livegame
  1157. // ***********************************************************************************************
  1158. // ***********************************************************************************************
  1159. function DoLiveGame (mode) {
  1160. PG_log("DoLiveGame(" + mode + ")");
  1161. function checkField(fx, fy) {
  1162. if (fx < 0 || fx >= x || fy < 0 || fy >= y)
  1163. return true;
  1164. var nr = (fy + fx*y + 1)*2;
  1165. return fields[nr].style.background == "";
  1166. }
  1167. function checkPic(fx, fy, bild) {
  1168. if (fx < 0 || fx >= x || fy < 0 || fy >= y)
  1169. return false;
  1170. var nr = (fy + fx*y + 1)*2;
  1171. var pic = fields[nr].style.background;
  1172. if (pic != "")
  1173. pic = pic.split("url(")[1].split(")")[0].split("/").pop().split(".")[0];
  1174. if (pic == "" && fields[nr].className.indexOf("disabled") != -1)
  1175. return false;
  1176. return pic == bild;
  1177. }
  1178. var game = document.getElementById("gameshell");
  1179. var fields = game.getElementsByTagName("div");
  1180. if (mode == 2) {
  1181. var cnt = Number(document.getElementById("counter").innerHTML);
  1182. if (cnt < 1)
  1183. return;
  1184. var g = fields[2].id;
  1185. var pos = g.lastIndexOf("_");
  1186. g = g.substr(0, pos-1);
  1187. var x = game.innerHTML.split('"'+g+'0').length-1;
  1188. var y = (game.innerHTML.split('"'+g).length-1)/x;
  1189. var today = new Date();
  1190. var now = today.getTime();
  1191. var possible = [];
  1192. var poss = 0;
  1193. for (var i = 1; i < x-1; i++)
  1194. for (var j = 1; j < y-1; j++) {
  1195. if (document.getElementById(g+i+"_"+j).className.indexOf("disabled") != -1)
  1196. continue;
  1197. poss++;
  1198. var ok = true;
  1199. var po = true;
  1200. var pod = 0;
  1201. var ii = 0;
  1202. if (document.getElementById(g+i+"_"+(j-1)).className.indexOf("disabled") == -1) {
  1203. pod++;
  1204. ok = false;
  1205. }
  1206. if (document.getElementById(g+i+"_"+(j+1)).className.indexOf("disabled") == -1) {
  1207. pod++;
  1208. ok = false;
  1209. }
  1210. if (document.getElementById(g+(i-1)+"_"+j).className.indexOf("disabled") == -1) {
  1211. pod++;
  1212. ok = false;
  1213. }
  1214. if (document.getElementById(g+(i+1)+"_"+j).className.indexOf("disabled") == -1) {
  1215. pod++;
  1216. ok = false;
  1217. }
  1218. if (ok) {
  1219. document.getElementById(g+i+"_"+j).click();
  1220. PG_log("DoLiveGame: Klick auf " + g + i + "_" + j);
  1221. }
  1222. if (pod == 1)
  1223. possible.push(i+"_"+j);
  1224. }
  1225. window.setTimeout(DoLiveGame, poss == 0?20000:1000, 2);
  1226. today = new Date();
  1227. PG_log("DoLiveGame(" + mode + ") beendet: " + (today.getTime() - now) + " Millisekunden; noch möglich: " + poss + "; einer zuviel: (" + possible + ")");
  1228. return;
  1229. }
  1230. if (fields[fields.length-2].className.indexOf("fieldshown") != -1) {
  1231. var msg = fields[fields.length-1].innerHTML;
  1232. var h1 = msg.split(">")[1].split("<")[0];
  1233. var plunder = msg.split('>').pop().trim();
  1234. var gw = false;
  1235. if (h1.indexOf("Glückwunsch") != -1) {
  1236. gw = true;
  1237. if (msg.indexOf("ergattert") != -1)
  1238. plunder = plunder.match(/\d+ [^ ]*/)[0];
  1239. else
  1240. plunder = "";
  1241. }
  1242. else if (plunder.indexOf('"') != -1)
  1243. plunder = plunder.split('"')[1];
  1244. else if (h1 == "Niete")
  1245. plunder = plunder.match(/\d+[^ ]*/)[0] + " Niete";
  1246. else if (h1.endsWith("Kronkorken"))
  1247. plunder = h1;
  1248. else if (h1 == "Leinen")
  1249. plunder = plunder.match(/\d+ [^ ]*/)[0];
  1250. else if (plunder.indexOf("Provokationen") != -1)
  1251. plunder = plunder.match(/\d+/)[0] + " Provokationen";
  1252. else if (plunder.startsWith("Deine aktiven"))
  1253. plunder = plunder.match(/\d+ [^ ]*/)[0] + " für aktive Haustiere";
  1254. else if (plunder.indexOf("Gästebuch") != -1)
  1255. plunder = plunder.match(/\d+ [^ ]*/)[0] + " für Profil-Gästebuch";
  1256. else if (plunder.startsWith("Deine Bande "))
  1257. plunder = plunder.match(/\d+/)[0] + " Banden-Kronkorken";
  1258. else if (plunder.startsWith("Du hast "))
  1259. plunder = plunder.substring(8, plunder.indexOf(" gefunden"));
  1260. //else
  1261. //alert(plunder);
  1262. if (plunder != "") {
  1263. var pAnz = plunder.match(/^\d+[^ ]*/);
  1264. if (pAnz) {
  1265. pAnz = ":" + pAnz[0];
  1266. var pos = plunder.indexOf(" ");
  1267. plunder = plunder.substr(pos+1);
  1268. }
  1269. else
  1270. pAnz = "";
  1271. var junkfound = PGu_getValue("junkfound", "");
  1272. if (junkfound == "")
  1273. junkfound = plunder + pAnz + ":1" +(gw?";":"");
  1274. else {
  1275. var junkArr = junkfound.split(";");
  1276. var pos = junkfound.replace(/:[\d?]*/g, "").split(";").indexOf(plunder);
  1277. if (pos == -1) {
  1278. if (gw) {
  1279. pos = junkArr.indexOf("");
  1280. if (pos == -1) {
  1281. junkArr.splice(0, 0, "");
  1282. pos = 0;
  1283. }
  1284. junkArr.splice(pos, 0, plunder + pAnz + ":1");
  1285. }
  1286. else
  1287. junkArr.push(plunder + pAnz + ":1");
  1288. }
  1289. else {
  1290. var anz = Number(junkArr[pos].split(":").pop()) + 1;
  1291. junkArr[pos] = junkArr[pos].substring(0, junkArr[pos].lastIndexOf(":")) + pAnz + ":" + anz;
  1292. }
  1293. junkfound = junkArr.join(";");
  1294. }
  1295. PGu_setValue("junkfound", junkfound);
  1296. if (!document.getElementById("junkfound"))
  1297. insertCheckBox11();
  1298. }
  1299. var f = document.getElementById(fields[fields.length-2].id);
  1300. if (f.className.indexOf("disabled") != -1)
  1301. fields[fields.length-2].parentNode.removeChild(fields[fields.length-2]);
  1302. return 1000;
  1303. }
  1304. var fieldanz = (fields.length - 1) / 2;
  1305. var lastfield = fields[fieldanz * 2];
  1306. var spl = lastfield.id.split("_");
  1307. var y = Number(spl.pop()) + 1;
  1308. var x = Number(spl.pop()) + 1;
  1309. var free = Number(document.getElementById("counter_free").innerHTML) + Number(document.getElementById("counter").innerHTML);
  1310. var kkAnz = Number(document.getElementsByClassName("icon crowncap")[0].innerHTML.split(">")[1].split("<")[0].trim());
  1311. var anzloch = game.innerHTML.split("loch").length - 1;
  1312. if (free == 0 && (anzloch == 0 || kkAnz < 2 || !PGu_getValue("livegameKK", false))) {
  1313. var today = new Date();
  1314. var tagesdatum = FormatDate(today);
  1315. PGu_setValue("livegame_date", tagesdatum);
  1316. return 2000;
  1317. }
  1318. var field = 0;
  1319. var newField = 0;
  1320. var forms = [];
  1321. var forms2cnt = [0,22,22,11,12,12,11,13,11];
  1322. var countrs = document.getElementsByClassName("counters")[0].innerHTML;
  1323. for (var i = 1; i <= 8; i++) {
  1324. if (countrs.indexOf("counter_"+i) == -1)
  1325. continue;
  1326. var counter = countrs.split("counter_"+i)[1].split("<");
  1327. var counterg = Number(counter[1].split("/").pop());
  1328. counter = Number(counter[0].split(">").pop());
  1329. if (counter != counterg)
  1330. if (forms.indexOf(forms2cnt[i]) == -1)
  1331. forms.push(forms2cnt[i]);
  1332. }
  1333. var highfields = [];
  1334. if (anzloch > 0) {
  1335. field = game.innerHTML.split("loch")[0].split("<div").length - 2;
  1336. var fx = Math.floor((field-2)/y/2);
  1337. var fy = (field - fx*2*y - 2)/2;
  1338. if (forms.indexOf(22) != -1) {
  1339. if (anzloch == 3) {
  1340. if (checkPic(fx+1, fy-1, "loch") && checkPic(fx+1, fy, "loch"))
  1341. newField = field - 2;
  1342. else if (checkPic(fx+1, fy, "loch") && checkPic(fx+1, fy+1, "loch"))
  1343. newField = field + 2;
  1344. else if (checkPic(fx, fy+1, "loch") && checkPic(fx+1, fy+1, "loch"))
  1345. newField = field + 2*y;
  1346. else if (checkPic(fx+1, fy, "loch") && checkPic(fx, fy+1, "loch"))
  1347. newField = field + 2*y + 2;
  1348. }
  1349. if (anzloch >= 2 && newField == 0) {
  1350. if (checkPic(fx+1, fy-1, "loch")) {
  1351. 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)) {
  1352. highfields.push(field - 2);
  1353. highfields.push(field + 2*y);
  1354. }
  1355. }
  1356. if (checkPic(fx+1, fy, "loch")) {
  1357. 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)) {
  1358. if (highfields.indexOf(field - 2) == -1)
  1359. highfields.push(field - 2);
  1360. //highfields.push(field - 2 + 2*y);
  1361. }
  1362. 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)) {
  1363. highfields.push(field + 2);
  1364. //highfields.push(field + 2 + 2*y);
  1365. }
  1366. }
  1367. if (checkPic(fx+1, fy+1, "loch")) {
  1368. 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)) {
  1369. if (highfields.indexOf(field + 2) == -1)
  1370. highfields.push(field + 2);
  1371. if (highfields.indexOf(field + 2*y) == -1)
  1372. highfields.push(field + 2*y);
  1373. }
  1374. }
  1375. if (checkPic(fx, fy+1, "loch")) {
  1376. 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)) {
  1377. highfields.push(field - 2*y);
  1378. //highfields.push(field + 2 - 2*y);
  1379. }
  1380. 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)) {
  1381. if (highfields.indexOf(field + 2*y) == -1)
  1382. highfields.push(field + 2*y);
  1383. //if (highfields.indexOf(field + 2 + 2*y) == -1)
  1384. // highfields.push(field + 2 + 2*y);
  1385. }
  1386. }
  1387. if (highfields.length > 0)
  1388. newField = highfields[Math.floor(Math.random() * highfields.length)];
  1389. }
  1390. if (newField == 0) {
  1391. 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)) {
  1392. highfields.push(field - 2);
  1393. //highfields.push(field - 2 + 2*y);
  1394. highfields.push(field + 2*y);
  1395. }
  1396. 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)) {
  1397. highfields.push(field + 2);
  1398. if (highfields.indexOf(field + 2*y) == -1)
  1399. highfields.push(field + 2*y);
  1400. //highfields.push(field + 2 + 2*y);
  1401. }
  1402. 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)) {
  1403. highfields.push(field - 2*y);
  1404. //highfields.push(field + 2 - 2*y);
  1405. if (highfields.indexOf(field + 2) == -1)
  1406. highfields.push(field + 2);
  1407. }
  1408. 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)) {
  1409. if (highfields.indexOf(field - 2*y) == -1)
  1410. highfields.push(field - 2*y);
  1411. //highfields.push(field - 2 - 2*y);
  1412. if (highfields.indexOf(field - 2) == -1)
  1413. highfields.push(field - 2);
  1414. }
  1415. if (highfields.length > 0)
  1416. newField = highfields[Math.floor(Math.random() * highfields.length)];
  1417. }
  1418. }
  1419. if (forms.indexOf(13) != -1 && newField == 0) {
  1420. if (checkPic(fx+1, fy, "loch")) {
  1421. if (checkPic(fx+2, fy, "") && checkField(fx+2, fy-1) && checkField(fx+3, fy) && checkField(fx+2, fy+1))
  1422. highfields.push(field + 4*y);
  1423. if (checkPic(fx-1, fy, "") && checkField(fx-2, fy) && checkField(fx-1, fy-1) && checkField(fx-1, fy+1))
  1424. highfields.push(field - 2*y);
  1425. }
  1426. if (checkPic(fx+2, fy, "loch") && checkPic(fx+1, fy, "") && checkField(fx+1, fy-1) && checkField(fx+1, fy+1))
  1427. highfields.push(field + 2*y);
  1428. if (checkPic(fx, fy+1, "loch")) {
  1429. if (checkPic(fx, fy+2, "") && checkField(fx-1, fy+2) && checkField(fx, fy+3) && checkField(fx+1, fy+2))
  1430. highfields.push(field + 4);
  1431. if (checkPic(fx, fy-1, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+1, fy-1))
  1432. highfields.push(field - 2);
  1433. }
  1434. if (checkPic(fx, fy+2, "loch") && checkPic(fx, fy+1, "") && checkField(fx-1, fy+1) && checkField(fx+1, fy+1))
  1435. highfields.push(field + 2);
  1436. if (highfields.length > 0)
  1437. newField = highfields[Math.floor(Math.random() * highfields.length)];
  1438. }
  1439. if (newField == 0) {
  1440. if (checkPic(fx, fy-1, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+1, fy-1))
  1441. highfields.push(field - 2);
  1442. if (checkPic(fx+1, fy, "") && checkField(fx+1, fy-1) && checkField(fx+2, fy) && checkField(fx+1, fy+1))
  1443. highfields.push(field + 2*y);
  1444. if (checkPic(fx, fy+1, "") && checkField(fx-1, fy+1) && checkField(fx, fy+2) && checkField(fx+1, fy+1))
  1445. highfields.push(field + 2);
  1446. if (checkPic(fx-1, fy, "") && checkField(fx-1, fy-1) && checkField(fx-2, fy) && checkField(fx-1, fy+1))
  1447. highfields.push(field - 2*y);
  1448. if (highfields.length > 0)
  1449. newField = highfields[Math.floor(Math.random() * highfields.length)];
  1450. }
  1451. }
  1452. if (newField == 0) {
  1453. var probs = [];
  1454. for (var i = 0; i < x; i++) {
  1455. probs[i] = [];
  1456. for (var j = 0; j < y; j++)
  1457. probs[i][j] = 0;
  1458. }
  1459. fx = 0;
  1460. fy = 0;
  1461. for (var i = 2; i < fields.length; i += 2) {
  1462. if (checkPic(fx, fy, "")) {
  1463. for (var j = 0; j < forms.length; j++) {
  1464. switch (forms[j]) {
  1465. case 11:
  1466. if (checkField(fx-1, fy) && checkField(fx, fy-1) && checkField(fx+1, fy) && checkField(fx, fy+1)) {
  1467. probs[fx][fy]++;
  1468. }
  1469. break;
  1470. case 12:
  1471. if (checkPic(fx, fy-1, "") && checkField(fx-1, fy-1) && checkField(fx, fy-2) && checkField(fx+1, fy-1)) {
  1472. probs[fx][fy]++;
  1473. probs[fx][fy-1]++;
  1474. }
  1475. if (checkPic(fx, fy+1, "") && checkField(fx-1, fy+1) && checkField(fx, fy+2) && checkField(fx+1, fy+1)) {
  1476. probs[fx][fy]++;
  1477. probs[fx][fy+1]++;
  1478. }
  1479. if (checkPic(fx-1, fy, "") && checkField(fx-1, fy-1) && checkField(fx-2, fy) && checkField(fx-1, fy+1)) {
  1480. probs[fx][fy]++;
  1481. probs[fx-1][fy]++;
  1482. }
  1483. if (checkPic(fx+1, fy, "") && checkField(fx+1, fy-1) && checkField(fx+2, fy) && checkField(fx+1, fy+1)) {
  1484. probs[fx][fy]++;
  1485. probs[fx+1][fy]++;
  1486. }
  1487. break;
  1488. case 13:
  1489. 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)) {
  1490. probs[fx][fy]++;
  1491. probs[fx][fy-1]++;
  1492. probs[fx][fy-2]++;
  1493. }
  1494. 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)) {
  1495. probs[fx][fy]++;
  1496. probs[fx][fy+1]++;
  1497. probs[fx][fy+2]++;
  1498. }
  1499. 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)) {
  1500. probs[fx][fy]++;
  1501. probs[fx-1][fy]++;
  1502. probs[fx-2][fy]++;
  1503. }
  1504. 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)) {
  1505. probs[fx][fy]++;
  1506. probs[fx+1][fy]++;
  1507. probs[fx+2][fy]++;
  1508. }
  1509. 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)) {
  1510. probs[fx][fy]++;
  1511. probs[fx][fy-1]++;
  1512. probs[fx][fy+1]++;
  1513. }
  1514. 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)) {
  1515. probs[fx][fy]++;
  1516. probs[fx-1][fy]++;
  1517. probs[fx+1][fy]++;
  1518. }
  1519. break;
  1520. case 14:
  1521. break;
  1522. case 22:
  1523. 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)) {
  1524. probs[fx][fy]++;
  1525. probs[fx][fy-1]++;
  1526. probs[fx-1][fy]++;
  1527. probs[fx-1][fy-1]++;
  1528. }
  1529. 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)) {
  1530. probs[fx][fy]++;
  1531. probs[fx][fy-1]++;
  1532. probs[fx+1][fy-1]++;
  1533. probs[fx+1][fy]++;
  1534. }
  1535. 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)) {
  1536. probs[fx][fy]++;
  1537. probs[fx][fy+1]++;
  1538. probs[fx-1][fy]++;
  1539. probs[fx-1][fy+1]++;
  1540. }
  1541. 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)) {
  1542. probs[fx][fy]++;
  1543. probs[fx][fy+1]++;
  1544. probs[fx+1][fy+1]++;
  1545. probs[fx+1][fy]++;
  1546. }
  1547. break;
  1548. default:
  1549. break;
  1550. }
  1551. }
  1552. }
  1553. fy++;
  1554. if (fy == y) {
  1555. fy = 0;
  1556. fx++;
  1557. }
  1558. }
  1559. var high = 0;
  1560. for (var i = 0; i < x; i++)
  1561. for (var j = 0; j < y; j++)
  1562. if (probs[i][j] > high)
  1563. high = probs[i][j];
  1564. var highfields = [];
  1565. fx = 0;
  1566. fy = 0;
  1567. for (var i = 2; i < fields.length; i += 2) {
  1568. if (probs[fx][fy] == high)
  1569. highfields.push(i);
  1570. fy++;
  1571. if (fy == y) {
  1572. fy = 0;
  1573. fx++;
  1574. }
  1575. }
  1576. newField = highfields[Math.floor(Math.random() * highfields.length)];
  1577. }
  1578.  
  1579. while (newField == 0) {
  1580. var rnd = Math.floor(Math.random() * fieldanz);
  1581. field = (rnd+1)*2;
  1582. var pic = fields[field].style.background;
  1583. if (pic != "")
  1584. continue;
  1585. var fx = Math.floor((field-2)/y/2);
  1586. var fy = (field - fx*2*y - 2)/2;
  1587. /*if (forms.indexOf(22) != -1) {
  1588. if (fx == 0 || fx == x-1 || fy == 0 || fy == y-1)
  1589. continue;
  1590. 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, "") ||
  1591. 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, "") ||
  1592. 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, "") ||
  1593. 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, ""))
  1594. newField = field;
  1595. }*/
  1596. if (checkField(fx-1, fy, "") && checkField(fx, fy-1, "") && checkField(fx+1, fy, "") && checkField(fx, fy+1, ""))
  1597. newField = field;
  1598. }
  1599. fields[newField].click();
  1600. return 2000;
  1601. }
  1602.  
  1603. var cardset = "";
  1604. var field = [];
  1605. // ***********************************************************************************************
  1606. // ***********************************************************************************************
  1607. // play memory
  1608. // ***********************************************************************************************
  1609. // ***********************************************************************************************
  1610. function DoMemory (show) {
  1611. PG_log("DoMemory("+show+")");
  1612. var tbl = document.getElementById("display").getElementsByClassName("gamefield");
  1613. if (tbl.length <= 0)
  1614. return 0;
  1615. var reward = document.getElementById("display").getElementsByClassName("reward");
  1616. if (reward.length > 0)
  1617. if (reward[0].style.display != "none") {
  1618. window.setTimeout(function() {reward[0].click();}, 2000);
  1619. return 3000;
  1620. }
  1621. var free = Number(document.getElementById("counter_free").innerHTML.split(">")[1].split("<")[0]);
  1622. if (free < 1 && !show)
  1623. return 0;
  1624. var gnum = tbl[0].id.split("_")[1];
  1625. var memory = PGu_getValue("memory", "");
  1626. if (memory == "")
  1627. var game = "";
  1628. else
  1629. var game = memory.split(":")[0];
  1630. if (memory == "" || game != gnum) {
  1631. field = [["?", "?", "?", "?"], ["?", "?", "?", "?"],
  1632. ["?", "?", "?", "?"], ["?", "?", "?", "?"],
  1633. ["?", "?", "?", "?"]];
  1634. }
  1635. else {
  1636. var mfield = memory.split(":")[1].split("+");
  1637. for (var i = 0; i < mfield.length; i++)
  1638. field[i] = mfield[i].split("-");
  1639. for (var i = 0; i < tbl.length; i++) {
  1640. var id = tbl[i].id.split("_");
  1641. if (field[id[2]][id[3]] == "?")
  1642. continue;
  1643. if (tbl[i].className.indexOf("fielddisabled") != -1 && tbl[i].style.background != "") {
  1644. var anz = 0;
  1645. var card = tbl[i].style.backgroundImage.split(",")[0].split("/").pop().split(".")[0];
  1646. for (var ii = 0; ii < field.length; ii++)
  1647. for (var j = 0; j < field[ii].length; j++)
  1648. if (field[ii][j] == card)
  1649. anz++;
  1650. if (anz < 2) {
  1651. PG_log ("Fehler festgestellt. Seite wird neu geladen.");
  1652. window.history.go(0);
  1653. return 0;
  1654. }
  1655. }
  1656. if (tbl[i].style.backgroundImage.indexOf("karte_zu") == -1)
  1657. continue;
  1658. var url = tbl[i].style.background.match(/url\(.*karte_/)[0];
  1659. var pos = url.lastIndexOf("/");
  1660. pos = url.lastIndexOf("/", pos-1);
  1661. var apo = (url.indexOf('"') == -1?'':'"');
  1662. tbl[i].style.background = url.substr(0, pos+1) + field[id[2]][id[3]] + '.png' + apo + '),' + tbl[i].style.background.replace("karte_zu", "karte_offen");
  1663. }
  1664. }
  1665. for (var i = 0; i < tbl.length; i++)
  1666. if (tbl[i].style.backgroundImage.indexOf("karte_zu") != -1)
  1667. // Click-Handler hinzufügen
  1668. tbl[i].addEventListener("click", function(event) {
  1669. if (cardset != this.id) {
  1670. cardset = this.id;
  1671. setCard (gnum, field, cardset);
  1672. }
  1673. }, false);
  1674.  
  1675. if (show)
  1676. return 0;
  1677.  
  1678. if (cardset != "")
  1679. return 1000;
  1680.  
  1681. var open = document.getElementById("display").getElementsByClassName("gamefield open");
  1682. var found = "";
  1683. var rnd = -1;
  1684. var save = false;
  1685. if (open.length > 1)
  1686. return 2000;
  1687. if (open.length == 1) {
  1688. var card = open[0].style.backgroundImage.split(",")[0].split("/").pop().split(".")[0];
  1689. if (card == "undefined")
  1690. return 2000;
  1691. var id = open[0].id.split("_");
  1692. if (field[id[2]][id[3]] == "?") {
  1693. field[id[2]][id[3]] = card;
  1694. save = true;
  1695. }
  1696. for (var i = 0; i < field.length && found == ""; i++)
  1697. for (var j = 0; j < field[i].length; j++)
  1698. if (field[i][j] == card && (i != id[2] || j != id[3])) {
  1699. found = "g_" + gnum + "_" + i + "_" + j;
  1700. break;
  1701. }
  1702. if (found != "")
  1703. for (var i = 0; i < tbl.length; i++)
  1704. if (tbl[i].id == found) {
  1705. rnd = i;
  1706. break;
  1707. }
  1708. }
  1709. if (rnd == -1) {
  1710. for (var i = 0; i < field.length && found == ""; i++)
  1711. for (var j = 0; j < field[i].length && found == ""; j++) {
  1712. if (field[i][j] == "?")
  1713. continue;
  1714. for (k = i; k < field.length && found == ""; k++)
  1715. for (l = (k==i?j+1:0); l < field[k].length; l++)
  1716. if (field[i][j] == field[k][l]) {
  1717. found = "g_" + gnum + "_" + i + "_" + j;
  1718. if (document.getElementById(found).className.indexOf("fielddisabled") == -1)
  1719. break;
  1720. found = "";
  1721. }
  1722. }
  1723. if (found != "")
  1724. for (var i = 0; i < tbl.length; i++)
  1725. if (tbl[i].id == found) {
  1726. tbl[i].click();
  1727. if (save)
  1728. saveField(gnum, field);
  1729. return 1000;
  1730. }
  1731. }
  1732. while (rnd == -1) {
  1733. rnd = Math.floor(Math.random()* tbl.length);
  1734. var id = tbl[rnd].id.split("_");
  1735. if (field[id[2]][id[3]] != "?")
  1736. rnd = -1;
  1737. }
  1738. cardset = tbl[rnd].id;
  1739. tbl[rnd].click();
  1740. window.setTimeout(setCard, 500, gnum, field, cardset);
  1741. return 2000;
  1742. }
  1743.  
  1744. function setCard (gnum, field, id) {
  1745. var f = document.getElementById(id);
  1746. var card = f.style.backgroundImage.split(",")[0].split("/").pop().split(".")[0];
  1747. if (card == "karte_zu") {
  1748. window.setTimeout(setCard, 1000, gnum, field, id);
  1749. return;
  1750. }
  1751. if (card != "undefined") {
  1752. var ids = id.split("_");
  1753. if (field[ids[2]][ids[3]] == "?") {
  1754. PG_log("Feld " + ids[2] + "/" + ids[3] + " wird gesetzt auf " + card);
  1755. field[ids[2]][ids[3]] = card;
  1756. saveField(gnum, field);
  1757. }
  1758. }
  1759. cardset = "";
  1760. window.setTimeout(DoMemory, 2000, true);
  1761. return;
  1762. }
  1763.  
  1764. function saveField(gnum, field) {
  1765. var memory = gnum;
  1766. for (var i = 0; i < field.length; i++)
  1767. memory += (i==0?":":"+") + field[i].join("-");
  1768. PGu_setValue("memory", memory);
  1769. }
  1770.  
  1771. // ***********************************************************************************************
  1772. // ***********************************************************************************************
  1773. // play the new minigame
  1774. // ***********************************************************************************************
  1775. // ***********************************************************************************************
  1776. function DoNewMinigame (mode) {
  1777. var today = new Date();
  1778. var tagesdatum = FormatDate(today);
  1779. PG_log("DoNewMinigame("+mode+")");
  1780. if (mode == 1) {
  1781. var tbl = document.getElementById("display").getElementsByClassName("cbox")[0];
  1782. var game = "roulette_";
  1783. var className = "chamber";
  1784. }
  1785. else if (mode == 2) {
  1786. var tbl = document.getElementById("display").getElementsByTagName("div")[0];
  1787. if (tbl.innerHTML.indexOf("icon_freispiel") == -1) {
  1788. PGu_setValue("slipgame_date", tagesdatum);
  1789. if (today.getHours() > 12)
  1790. PGu_setValue("slipgame_noon", tagesdatum);
  1791. if (today.getHours() < 12)
  1792. var to = 43500;
  1793. else
  1794. var to = 86400;
  1795. to = (to - today.getHours()*3600-today.getMinutes()*60-today.getSeconds()) * 1000 + today.getTime();
  1796. PGu_setValue("slipgame_wait", to.toString());
  1797. return -1;
  1798. }
  1799. var game = "slipgame_";
  1800. var className = "field";
  1801. var chamber = tbl.getElementsByClassName(className);
  1802. if (chamber.length == 0)
  1803. return -1;
  1804. var pl = Number(chamber[0].innerHTML.split("/").pop().split(".")[0]);
  1805. if (pl >= 1700) {
  1806. PGu_setValue("dispshow_date", 0);
  1807. PGu_setValue("cocktaildate", "xx");
  1808. GM_xmlhttpRequest({method:"GET", url: prothost + '/cocktail/', onload:function(responseDetails) {
  1809. var content = responseDetails.responseText;
  1810. var needed = findCocktail(content, true);
  1811. var maxInd = -1;
  1812. while (maxInd == -1) {
  1813. var max = -9999;
  1814. for (var c = 0; c < needed.length; c++)
  1815. if (needed[c][1] > max) {
  1816. max = needed[c][1];
  1817. maxInd = c;
  1818. }
  1819. for (var c = 0; c < chamber.length; c++) {
  1820. var pl = Number(chamber[c].innerHTML.split("/").pop().split(".")[0]);
  1821. if (pl == needed[maxInd][0]) {
  1822. chamber[c].click();
  1823. break;
  1824. }
  1825. }
  1826. if (c == chamber.length) {
  1827. needed[maxInd][1] = -9999;
  1828. maxInd = -1;
  1829. }
  1830. }
  1831. }});
  1832. return 2000;
  1833. }
  1834. }
  1835. else if (mode == 3) {
  1836. var buttons = document.getElementById("display").getElementsByClassName("button_container")[0];
  1837. if (buttons) {
  1838. var div = buttons.getElementsByTagName("div")[1];
  1839. if (div.innerHTML.indexOf("Würfeln") != -1)
  1840. buttons.click();
  1841. else if (div.innerHTML.indexOf("KK") != -1) {
  1842. PGu_setValue("icecubegame", tagesdatum);
  1843. PGu_setValue("dispshow_game", "");
  1844. return 2000;
  1845. }
  1846. else {
  1847. var results = document.getElementById("display").getElementsByClassName("die_results")[0].getElementsByClassName("dice");
  1848. var saved = document.getElementById("display").getElementsByClassName("die_results_saved")[0].getElementsByTagName("div");
  1849. if (saved.length + results.length < 6)
  1850. return 2000;
  1851. var high = 0;
  1852. var draw = 0;
  1853. var nmbr = -1;
  1854. for (var i = 0; i < results.length; i++) {
  1855. var dice = results[i].style.backgroundImage;
  1856. if (dice == "")
  1857. continue;
  1858. dice = dice.split("/").pop().split(".")[0].split("_")[1];
  1859. if (PGu_getValue("icecubekeep"+dice, dice == 6)) {
  1860. results[i].click();
  1861. draw++;
  1862. break;
  1863. }
  1864. else if (dice > high) {
  1865. high = dice;
  1866. nmbr = i;
  1867. }
  1868. }
  1869. if (draw == 0 && nmbr >= 0 && div.className.indexOf("disabled") != -1)
  1870. results[nmbr].click();
  1871. else if (draw == 0 && div.className.indexOf("disabled") == -1)
  1872. buttons.click();
  1873. }
  1874. }
  1875. return 2000;
  1876. }
  1877. else if (mode == 4) {
  1878. if (!PGu_getValue("cocktailauto", false))
  1879. return 0;
  1880. var content = document.getElementById("content").innerHTML;
  1881. var shaker = document.getElementsByClassName("shaker_content");
  1882. if (shaker.length > 0) {
  1883. var ingred = shaker[0].getElementsByClassName("shaker_img");
  1884. PG_log("Elemente im Shaker: " + ingred.length);
  1885. for (var i = 0; i < ingred.length; i++)
  1886. ingred[i].click();
  1887. content = document.getElementById("content").innerHTML;
  1888. }
  1889. var mixable = findCocktail(content, false);
  1890. if (mixable.length == 0)
  1891. return -1;
  1892. document.getElementById(mixable[0]).click();
  1893. for (var i = 0; i < mixable[1].length; i++)
  1894. document.getElementById("count_"+mixable[1][i]).parentNode.click();
  1895. if (mixable[2] > 0)
  1896. document.getElementById("img_"+mixable[2]).click();
  1897. document.getElementsByClassName("shake_button")[0].click();
  1898. return 4000;
  1899. }
  1900. else if (mode == 5) {
  1901. if (today.getTime() < Number(PGu_getValue("checkNewMinigame", "0")) + 6000) {
  1902. window.setTimeout(CheckNewMinigame, 2000);
  1903. return 0;
  1904. }
  1905. PGu_setValue("checkNewMinigame", String(today.getTime()));
  1906. var content = document.getElementById("content").innerHTML;
  1907. var hendl = content.split("dose_gar.png");
  1908. PG_log("hendl gar = " + hendl.length);
  1909. for (var i = 1; i < hendl.length; i++) {
  1910. var id = hendl[i].split('id="')[1].split('"')[0];
  1911. PG_log("hendl finished, id = " + id);
  1912. setTimeout("document.getElementById('" + id + "').click();", 500+i*500); // fails often if to fast
  1913. }
  1914. if (hendl.length > 1)
  1915. return i*500 + 1000;
  1916. var gas = Number(content.split('id="blackjack_container"')[1].split('class="stats"')[1].split("</span")[0].split(">").pop().trim());
  1917. var hendl = content.split("dose_leer.png");
  1918. PG_log("leer = " + hendl.length + ", gas = " + gas);
  1919. for (var i = 1; i < hendl.length && i <= gas; i++)
  1920. setTimeout("document.getElementsByClassName('countdown_button empty')[0].click();", 500+i*500); // fails often if to fast
  1921. return (hendl.length > 1 && gas >= 1)?i*500+1000:0;
  1922. }
  1923. else if (mode == 6) {
  1924. var cardstat = PGu_getValue("blackjackcards", "");
  1925. if (cardstat == "") {
  1926. var dates = [];
  1927. var days = [];
  1928. }
  1929. else {
  1930. var dates = cardstat.replace(/\+[:\dABDK]*/g, "").split(";");
  1931. var days = cardstat.split(";");
  1932. }
  1933. var ind = dates.indexOf(tagesdatum);
  1934. if (document.getElementsByClassName("presents").length > 0) {
  1935. if (document.getElementsByClassName("presents")[0].innerHTML.indexOf("Kronkorken") != -1) {
  1936. PGu_setValue("blackjack_date", tagesdatum);
  1937. PGu_setValue("blackjack_noon", tagesdatum);
  1938. return 2000;
  1939. }
  1940. if (document.getElementsByClassName("presents")[0].innerHTML.indexOf("blackjack(") != -1) {
  1941. if (ind == -1)
  1942. PGu_setValue("blackjackcards", cardstat + (cardstat == ""?"":";") + tagesdatum);
  1943. else
  1944. PGu_setValue("blackjackcards", cardstat + "+");
  1945. document.getElementsByClassName("start")[0].click();
  1946. return 2000;
  1947. }
  1948. }
  1949. var cards = document.getElementsByClassName("cards")[0].innerHTML.split("blackjack/cards/");
  1950. var thisgame = [];
  1951. for (var j = 1; j < cards.length; j++) {
  1952. var card = cards[j].split(".png")[0].trim();
  1953. if (card == "11")
  1954. card = "B";
  1955. else if (card == "12")
  1956. card = "D";
  1957. else if (card == "13")
  1958. card = "K";
  1959. else if (card == "14")
  1960. card = "A";
  1961. thisgame.push(card);
  1962. }
  1963. if (ind == -1) {
  1964. PGu_setValue("blackjackcards", cardstat + (cardstat==""?"":";") + tagesdatum + "+" + thisgame.join(":"));
  1965. }
  1966. else {
  1967. var cardstoday = days[ind].split("+");
  1968. if (cardstoday.length > 1)
  1969. cardstoday.pop();
  1970. cardstoday.push(thisgame.join(":"));
  1971. days[ind] = cardstoday.join("+");
  1972. PGu_setValue("blackjackcards", days.join(";"));
  1973. }
  1974. if (document.getElementsByClassName("finished_button").length > 0) {
  1975. document.getElementsByClassName("finished_button")[0].click();
  1976. return 2000;
  1977. }
  1978. var value = Number(document.getElementsByClassName("presents")[0].getElementsByTagName("div")[0].innerHTML.trim());
  1979. if (value >= PGu_getValue("blackjacklimit", 13)) {
  1980. document.getElementsByClassName("stop active")[0].click();
  1981. return 2000;
  1982. }
  1983. document.getElementsByClassName("draw active")[0].click();
  1984. return 2000;
  1985. }
  1986. else
  1987. return 0;
  1988.  
  1989. if (tbl.innerHTML.indexOf(game) != -1) {
  1990. var chamber = tbl.getElementsByClassName(className);
  1991. if (chamber.length > (game == "roulette_"?1:0)) {
  1992. var rnd = Math.floor(Math.random()* chamber.length);
  1993. chamber[rnd].click();
  1994. return 2000;
  1995. }
  1996. }
  1997.  
  1998. if (tbl.innerHTML.indexOf("_success.png") != -1 || tbl.innerHTML.indexOf("minigame_count") == -1 || tbl.innerHTML.indexOf("roulette_") != -1) {
  1999. PGu_setValue("minigame_success", 1);
  2000. PGu_setValue("minigame_date", tagesdatum);
  2001. if (today.getHours() > 12)
  2002. PGu_setValue("minigame_noon", tagesdatum);
  2003. if (today.getHours() < 12)
  2004. var to = 43500;
  2005. else
  2006. var to = 86400;
  2007. to = (to - today.getHours()*3600-today.getMinutes()*60-today.getSeconds()) * 1000 + today.getTime();
  2008. PGu_setValue("minigame_wait", to.toString());
  2009. return to - today.getTime();
  2010. }
  2011. var trs = tbl.getElementsByTagName("tr");
  2012. for (var j = 0; j < trs.length; j++)
  2013. if (trs[j].innerHTML.indexOf("minigame_count") != -1)
  2014. break;
  2015. if (j == trs.length)
  2016. return 0;
  2017.  
  2018. if (trs[j].innerHTML.indexOf("minigame_countdown") != -1) {
  2019. var span = trs[j].getElementsByTagName("span");
  2020. var seks = 0;
  2021. if (span.length > 0)
  2022. for (var jj = 0; jj < 1; jj++) {
  2023. var timer = span[jj].innerHTML;
  2024. if (timer == done) {
  2025. seks = 0;
  2026. }
  2027. else if (timer.indexOf(":") != -1) {
  2028. var time = timer.split(":");
  2029. seks = (parseInt(time[0])*60 + parseInt(time[1])) * 1000;
  2030. }
  2031. }
  2032. if (seks == 0) {
  2033. unsafeWindow.minigame_show();
  2034. seks = 2000;
  2035. }
  2036. var time = (new Date().getTime()) + seks;
  2037. PGu_setValue("minigame_wait", String(time));
  2038. return seks;
  2039. }
  2040. 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 ||
  2041. trs[j].style.background.indexOf("_success.jpg") != -1 || trs[j].style.background.indexOf("_unsuccess.jpg") != -1 || trs[j].style.background.indexOf("_normal.jpg") != -1) {
  2042. var success = PGu_getValue("minigame_success", 0);
  2043. if (success == 1) {
  2044. if (trs[j].style.background.indexOf("_success.png") == -1 ||
  2045. trs[j].innerHTML.indexOf("minigame_count") != -1) {
  2046. PGu_setValue("minigame_value", -1);
  2047. PGu_setValue("minigame_success", 0);
  2048. success = 0;
  2049. }
  2050. else
  2051. return (86400-today.getHours()*3600-today.getMinutes()*60-today.getSeconds()) * 1000;
  2052. }
  2053. if (success == 0) {
  2054. if (trs[j].style.background.indexOf("_success.png") != -1 || trs[j].innerHTML.indexOf("minigame_count") == -1) {
  2055. PGu_setValue("minigame_success", 1);
  2056. PGu_setValue("minigame_date", tagesdatum);
  2057. PGu_setValue("minigame_noon", tagesdatum);
  2058. return (86400-today.getHours()*3600-today.getMinutes()*60-today.getSeconds()) * 1000;
  2059. }
  2060. else {
  2061. var nextValue = PGu_getValue("minigame_value", -1) + 1;
  2062. var pos = trs[j].innerHTML.indexOf("minigame_count");
  2063. var plnd = trs[j].innerHTML.substr(pos).match(/<img.*src=".*"/);
  2064. if (plnd == null)
  2065. plnd = [];
  2066. else if (plnd.length > 0 && plnd[0].indexOf("busserl") != -1)
  2067. plnd = false;
  2068. if (!plnd || plnd.length == 0) {
  2069. document.getElementById("minigame_count").innerHTML = nextValue%10+1;
  2070. var sub = trs[j].innerHTML.split("minigame_try('")[1].split("'")[0];
  2071. unsafeWindow.minigame_try(sub);
  2072. PGu_setValue("minigame_value", nextValue);
  2073. return 2000;
  2074. }
  2075. var plndanz = PGu_getValue("minigame_plunderanz", -1);
  2076. if (plndanz == -1) {
  2077. PGu_setValue("minigame_plunderanz", 0);
  2078. plnd = plnd[0].split('src="')[1].split('"')[0];
  2079. var pltab = 6;
  2080. if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" ||TOWNEXTENSION == "MU")
  2081. pltab = 1;
  2082. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
  2083. var content = responseDetails.responseText;
  2084. PGu_setValue("minigame_plunderreq", String(today.getTime()+300000));
  2085. var Plnd = content.split(decodeURI(plnd));
  2086. if (Plnd.length < 2)
  2087. return;
  2088. var plndanz = Plnd[1].split("<td")[1].split("<span")[1].split(">")[1].split("<")[0];
  2089. plndanz = Number(plndanz.split("x ")[1].trim());
  2090. if (plndanz < nextValue%10+1) {
  2091. PGu_setValue("minigame_plunderanz", plndanz);
  2092. return;
  2093. }
  2094. PGu_setValue("minigame_plunderanz", plndanz - (nextValue%10+1));
  2095. document.getElementById("minigame_count").innerHTML = nextValue%10+1;
  2096. var sub = trs[j].innerHTML.split("minigame_try('")[1].split("'")[0];
  2097. unsafeWindow.minigame_try(sub);
  2098. PGu_setValue("minigame_value", nextValue);
  2099. }});
  2100. return 0;
  2101. }
  2102. if (plndanz < nextValue%10+1)
  2103. return 300000;
  2104. PGu_setValue("minigame_value", nextValue);
  2105. PGu_setValue("minigame_plunderanz", plndanz - (nextValue%10+1));
  2106. document.getElementById("minigame_count").innerHTML = nextValue%10+1;
  2107. var sub = trs[j].innerHTML.split("minigame_try('")[1].split("'")[0];
  2108. unsafeWindow.minigame_try(sub);
  2109. }
  2110. }
  2111. }
  2112. return 2000;
  2113. }
  2114.  
  2115. // ***********************************************************************************************
  2116. // ***********************************************************************************************
  2117. // check for minigame and play it
  2118. // ***********************************************************************************************
  2119. // ***********************************************************************************************
  2120. function CheckMinigame () {
  2121. PG_log("CheckMinigame");
  2122. if (window.location.pathname.indexOf("/activities/") == -1)
  2123. return;
  2124. var minigames = ["halloween", "summer13", "event/aug13_2"];
  2125. var tbl = document.getElementsByTagName("table");
  2126. for (var i = 0; i < tbl.length; i++) {
  2127. for (var tk = 0; tk < minigames.length; tk++)
  2128. if (tbl[i].innerHTML.indexOf("/" + minigames[tk] + "/") != -1)
  2129. break;
  2130. var trs = tbl[i].getElementsByTagName("tr");
  2131. for (var j = 0; j < trs.length; j++) {
  2132. for (var k = 0; k < minigames.length; k++)
  2133. if (trs[j].innerHTML.indexOf("/" + minigames[k] + "/") != -1)
  2134. break;
  2135. if (tk < minigames.length || k < minigames.length) {
  2136. var seks = 0;
  2137. if (j + 1 < trs.length) {
  2138. var span = trs[j+1].getElementsByTagName("span");
  2139. if (span.length > 0)
  2140. for (var jj = 0; jj < 1; jj++) {
  2141. var timer = span[jj].innerHTML;
  2142. if (timer == done) {
  2143. seks = 0;
  2144. }
  2145. else if (timer.indexOf(":") != -1) {
  2146. var time = timer.split(":");
  2147. seks = parseInt(time[0])*60 + parseInt(time[1]);
  2148. }
  2149. }
  2150. }
  2151. if (seks > 0) {
  2152. checkInt = window.setTimeout(CheckMinigame,seks*1000);
  2153. return;
  2154. }
  2155. 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) {
  2156. var success = PGu_getValue("minigame_success", 0);
  2157. if (success == 1) {
  2158. if (trs[j].style.background.indexOf("/success.jpg") == -1) {
  2159. PGu_setValue("minigame_value", -1);
  2160. PGu_setValue("minigame_success", 0);
  2161. success = 0;
  2162. }
  2163. else
  2164. checkInt = window.setTimeout(reload, 300000, "CheckMinigame1");
  2165. }
  2166. if (success == 0) {
  2167. if (trs[j].style.background.indexOf("/success.jpg") != -1) {
  2168. PGu_setValue("minigame_success", 1);
  2169. }
  2170. else {
  2171. var options = trs[j].innerHTML.split('<option');
  2172. if (options.length == 1) {
  2173. reload("CheckMinigame2");
  2174. break;
  2175. }
  2176.  
  2177. var nextValue = PGu_getValue("minigame_value", -1) + 1;
  2178. var nextVal = nextValue % (options.length-1);
  2179. nextVal = options[nextVal+1].split('<')[0];
  2180. if (nextVal.startsWith(" value")) {
  2181. nextVal = nextVal.split('"')[1];
  2182. }
  2183. else
  2184. nextVal = nextVal.substr(1);
  2185.  
  2186. GM_xmlhttpRequest({
  2187. method:"POST",
  2188. url: prothost + '/' + minigames[k] + '/minigame/',
  2189. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  2190. data: encodeURI('minigame_count='+nextVal),
  2191. onload:function(responseDetails) {
  2192. var pos = responseDetails.responseText.indexOf('/fail.jpg');
  2193. if (pos == -1) {
  2194. window.location.href = prothost + '/activities/';
  2195. }
  2196. else {
  2197. PGu_setValue("minigame_value", nextValue);
  2198. window.location.href = prothost + '/activities/';
  2199. }
  2200. }});
  2201. }
  2202. }
  2203. break;
  2204. }
  2205. else if (k < minigames.length) {
  2206. window.location.href = prothost + '/' + minigames[k] + '/minigame/';
  2207. }
  2208. }
  2209. else if (trs[j].style.background.search(/\/xmas.*\/minigame/) != -1) {
  2210. var seks = 0;
  2211. if (j + 1 < trs.length) {
  2212. var span = trs[j+1].getElementsByTagName("span");
  2213. for (var jj = 0; jj < 1; jj++) {
  2214. var timer = span[jj].innerHTML;
  2215. if (timer == done) {
  2216. seks = 0;
  2217. }
  2218. else {
  2219. var time = timer.split(":");
  2220. seks = parseInt(time[0])*60 + parseInt(time[1]);
  2221. }
  2222. }
  2223. }
  2224. if (seks > 0) {
  2225. checkInt = window.setTimeout(reload, seks*1000, "CheckMinigame3");
  2226. return;
  2227. }
  2228. else {
  2229. var success = PGu_getValue("XmasMini_success", 0);
  2230. if (success == 1) {
  2231. if (trs[j].style.background.indexOf("minigame_success") == -1) {
  2232. PGu_setValue("XmasMini_value", -1);
  2233. PGu_setValue("XmasMini_success", 0);
  2234. success = 0;
  2235. }
  2236. else
  2237. checkInt = window.setTimeout(reload, 600000, "CheckMinigame4");
  2238. }
  2239. if (success == 0) {
  2240. if (trs[j].style.background.indexOf("minigame_success") != -1) {
  2241. PGu_setValue("XmasMini_value", -1);
  2242. PGu_setValue("XmasMini_success", 1);
  2243. checkInt = window.setTimeout(reload, 600000, "CheckMinigame5");
  2244. }
  2245. else {
  2246. var options = trs[j].innerHTML.split('<option');
  2247. if (options.length == 1) {
  2248. reload("CheckMinigame6");
  2249. break;
  2250. }
  2251.  
  2252. var nextValue = PGu_getValue("XmasMini_value", -1) + 1;
  2253. var nextVal = nextValue % (options.length-1);
  2254. nextVal = options[nextVal+1].split('<')[0];
  2255. if (nextVal.startsWith(" value")) {
  2256. nextVal = nextVal.split('"')[1];
  2257. }
  2258. else
  2259. nextVal = nextVal.substr(1);
  2260. var action = trs[j].innerHTML.match(/<form.*action=\"[^\"]*\"/)[0].split('"')[1];
  2261.  
  2262. GM_xmlhttpRequest({
  2263. method:"POST",
  2264. url: prothost + action,
  2265. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  2266. data: encodeURI('minigame_count='+nextVal),
  2267. onload:function(responseDetails) {
  2268. var pos = responseDetails.finalUrl.indexOf('event=');
  2269. if (pos == -1) {
  2270. window.location.href = prothost + '/activities/';
  2271. }
  2272. else {
  2273. var rc = parseInt(responseDetails.finalUrl.substr(pos+6));
  2274. if (rc == -2)
  2275. alert('Bitte Glühwein kaufen !!');
  2276. else {
  2277. PGu_setValue("XmasMini_value", nextValue);
  2278. PGu_setValue("XmasMini_success", (rc==1?1:0));
  2279. window.location.href = responseDetails.finalUrl;
  2280. }
  2281. }
  2282. }});
  2283. }
  2284. }
  2285. }
  2286. break;
  2287. }
  2288. else if (trs[j].style.background.indexOf("/events/") != -1) {
  2289. //alert(trs[j].style.background);
  2290. var eventpos = trs[j].innerHTML.indexOf('/event/');
  2291. var eventurl = "";
  2292. minigames = ["easter14", "summer14", "krnvl"];
  2293. var multiple = 0;
  2294. for (var k = 0; k < minigames.length; k++)
  2295. if (tbl[i].innerHTML.indexOf("/" + minigames[k] + "/") != -1)
  2296. break;
  2297. var dk = (tbl[i].innerHTML.indexOf('span id="counter') != -1?1:2);
  2298. if (eventpos != -1) {
  2299. var eventposend = trs[j].innerHTML.indexOf('"', eventpos);
  2300. eventurl = trs[j].innerHTML.substr(eventpos, eventposend - eventpos);
  2301. if (trs[j].innerHTML.substr(eventpos-8,6) == "action") {
  2302. var form = trs[j].getElementsByTagName("form")[0].innerHTML;
  2303. var inputs = form.split("<input");
  2304. var input = "";
  2305. for (var ii = 1; ii < inputs.length; ii++) {
  2306. var name = inputs[ii].split('name="');
  2307. if (name.length > 1)
  2308. name = name[1].split('"')[0];
  2309. else
  2310. continue;
  2311. var value = inputs[ii].split('value="');
  2312. if (value.length > 1)
  2313. value = value[1].split('"')[0];
  2314. else
  2315. continue;
  2316. if (input != "")
  2317. input += "&";
  2318. input += name + "=" + value;
  2319. }
  2320. if (k < minigames.length) {
  2321. var seks = 0;
  2322. dk = 1;
  2323. if (j + 1 < trs.length) {
  2324. var span = trs[j+1].getElementsByTagName("span");
  2325. if (span.length > 0)
  2326. for (var jj = 0; jj < 1; jj++) {
  2327. var timer = span[jj].innerHTML;
  2328. if (timer == done) {
  2329. seks = 0;
  2330. }
  2331. else if (timer.indexOf(":") != -1) {
  2332. var time = timer.split(":");
  2333. seks = parseInt(time[0])*60 + parseInt(time[1]);
  2334. }
  2335. }
  2336. }
  2337. if (seks > 0) {
  2338. checkInt = window.setTimeout(CheckMinigame,seks*1000);
  2339. return;
  2340. }
  2341. 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) {
  2342. var success = PGu_getValue("minigame_success", 0);
  2343. if (success == 1) {
  2344. if (trs[j].style.background.indexOf("success.jpg") == -1) {
  2345. PGu_setValue("minigame_value", -1);
  2346. PGu_setValue("minigame_success", 0);
  2347. success = 0;
  2348. }
  2349. else
  2350. checkInt = window.setTimeout(reload, 300000, "CheckMinigame7");
  2351. }
  2352. if (success == 0) {
  2353. if (trs[j].style.background.indexOf("success.jpg") != -1) {
  2354. PGu_setValue("minigame_success", 1);
  2355. }
  2356. else {
  2357. var options = trs[j].innerHTML.split('<option');
  2358. if (options.length != 1) {
  2359. var nextValue = PGu_getValue("minigame_value", -1) + 1;
  2360. var nextVal = nextValue % (options.length-1);
  2361. nextVal = options[nextVal+1].split('<')[0];
  2362. if (nextVal.startsWith(" value")) {
  2363. nextVal = nextVal.split('"')[1];
  2364. }
  2365. else
  2366. nextVal = nextVal.substr(1);
  2367. if (input != "")
  2368. input += "&";
  2369. input += 'minigame_count='+nextVal;
  2370. multiple = 1;
  2371. }
  2372. }
  2373. }
  2374. }
  2375. else if (k < minigames.length) {
  2376. window.location.href = prothost + '/' + minigames[k] + '/minigame/';
  2377. }
  2378. }
  2379. GM_xmlhttpRequest({
  2380. method:"POST",
  2381. url: prothost + eventurl,
  2382. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  2383. data: encodeURI(input),
  2384. onload:function(responseDetails) {
  2385. if (multiple == 1)
  2386. PGu_setValue("minigame_value", nextValue);
  2387. var pos = responseDetails.finalUrl.indexOf('event=');
  2388. if (pos == -1 || !multiple) {
  2389. window.location.href = prothost + '/activities/';
  2390. }
  2391. else {
  2392. var rc = parseInt(responseDetails.finalUrl.substr(pos+6));
  2393. PGu_setValue("minigame_success", (rc==1?1:0));
  2394. window.location.href = responseDetails.finalUrl;
  2395. }
  2396. }
  2397. });
  2398. }
  2399. else if (eventurl.indexOf("mayevent") == -1) {
  2400. window.location.href = prothost + eventurl;
  2401. GM_setValue(TOWNEXTENSION + "eventURL", eventurl);
  2402. }
  2403. break;
  2404. }
  2405. if (j + dk < trs.length) {
  2406. var seks = 0;
  2407. var span = trs[j+dk].getElementsByTagName("span");
  2408. for (var jj = 0; jj < 1; jj++) {
  2409. var timer = span[jj].innerHTML;
  2410. if (timer == done) {
  2411. seks = 0;
  2412. }
  2413. else {
  2414. var time = timer.split(":");
  2415. seks = parseInt(time[0])*60 + parseInt(time[1]);
  2416. }
  2417. }
  2418. if (seks > 0) {
  2419. checkInt = window.setTimeout(reload, seks*1000, "CheckMinigame8");
  2420. return;
  2421. }
  2422. else {
  2423. var eventurl = PG_getValue(TOWNEXTENSION + "eventURL", "");
  2424. if (eventurl != "")
  2425. window.location.href = prothost + eventurl;
  2426. }
  2427. }
  2428. break;
  2429. }
  2430. }
  2431. }
  2432. }
  2433.  
  2434. function insertCheckBox(mode, loaded) {
  2435. var submitBtn = " Submit2";
  2436. if (document.getElementsByName(submitBtn).length == 0)
  2437. submitBtn = "Submit2";
  2438. submitBtn = document.getElementsByName(submitBtn)[0];
  2439. if (mode == 0) {
  2440. var newtd = document.createElement("td");
  2441. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  2442. newtd.innerHTML = '<input name="BCCheckbox" id="BCCheckbox" type="checkbox"><span style="vertical-align: bottom">&nbsp;Automatisch sammeln</span>&nbsp;&nbsp;<input name="KWCheckbox" id="KWCheckbox" type="checkbox"><span style="vertical-align: bottom">&nbsp;ohne Erinnerung</span><br><input name="STWCheckbox" id="STWCheckbox" type="checkbox"><span style="vertical-align: bottom">&nbsp;mit Stadtteilwahl</span>';
  2443. submitBtn.parentNode.appendChild(newtd, document.getElementsByName("xycoords")[0]);
  2444. document.getElementById("BCCheckbox").checked = PGu_getValue("AutoCollect", false);
  2445. // Click-Handler hinzufügen
  2446. document.getElementById("BCCheckbox").addEventListener("click", function(event) {
  2447. // Klickstatus speichern
  2448. PGu_setValue("AutoCollect", this.checked);
  2449. if (this.checked) {
  2450. var timeOptions = document.getElementsByName("time")[0];
  2451. PGu_setValue(nameLastCollectTime, timeOptions.selectedIndex);
  2452. }
  2453. }, false);
  2454. document.getElementById("KWCheckbox").checked = PGu_getValue("AutoCollectKW", false);
  2455. // Click-Handler hinzufügen
  2456. document.getElementById("KWCheckbox").addEventListener("click", function(event) {
  2457. // Klickstatus speichern
  2458. PGu_setValue("AutoCollectKW", this.checked);
  2459. }, false);
  2460. document.getElementById("STWCheckbox").checked = PGu_getValue("chooseDistrict", true);
  2461. document.getElementById("STWCheckbox").addEventListener("click", function(event) {
  2462. // Klickstatus speichern
  2463. PGu_setValue("chooseDistrict", this.checked);
  2464. window.location.href = prothost + '/activities/';
  2465. }, false);
  2466. if (!loaded)
  2467. return;
  2468. }
  2469. if (PGu_getValue("chooseDistrict", true))
  2470. trace('Get ' + prothost + '/city/district/', 2);
  2471. GM_xmlhttpRequest({method:"GET", url: prothost + '/city/district/', onload:function(responseDetails) {
  2472. var content = responseDetails.responseText;
  2473. // Wenn die Seite abgerufen werden konnte (kein Seitenladefehler)
  2474. if (content.indexOf("<strong>Mein Penner</strong>") != -1) {
  2475. var district = document.getElementsByTagName("table")[0].getElementsByTagName("tr")[2].getElementsByTagName("td")[0].innerHTML.split(":").pop().trim();
  2476. var districts = content.split('class="pet_tab_help"')[1].split("<table ")[1].split("</table")[0].split("/city/district/buy/");
  2477. var option = '<option value="0"> </option> ';
  2478. var foption = '<option value="0"> </option> ';
  2479. var fastest = 0;
  2480. var setfast = "";
  2481. var dist = [];
  2482. var hdist = [];
  2483. var mplunder = [];
  2484. var mpdist = [];
  2485. if (missionContent != "") {
  2486. var missions = missionContent.split('class="gang_mission"');
  2487. if (missions.length > 1) {
  2488. for (var i = 1; i < missions.length; i++) {
  2489. var lis = missions[i].split("stage_area")[1].split("<li>");
  2490. for (var j = 1; j < lis.length; j++) {
  2491. var beg = lis[j].split('"amount"');
  2492. if (beg.length > 1) {
  2493. var list = lis[j].match(/show_.*city_list.*activate'/);
  2494. if (list != null) {
  2495. if (list[0].indexOf("deactivate") != -1) {
  2496. var plnd = beg[0].split("<span>")[1].split("<")[0].trim();
  2497. mplunder.push(plnd);
  2498. var dlist = missions[i].split("stage_area")[1].split("<ul>").pop().split("</ul>")[0].split("<li>");
  2499. dlist.splice(0, 1);
  2500. for (var k = 0; k < dlist.length; k++)
  2501. dlist[k] = dlist[k].split("<")[0].trim();
  2502. mpdist.push(dlist);
  2503. }
  2504. }
  2505. }
  2506. }
  2507. }
  2508. }
  2509. }
  2510. dist["0"] = "";
  2511. for (var i = 1; i < districts.length; i++) {
  2512. var distr = districts[i].split("</span")[0].split(">").pop().trim();
  2513. if (districts[i].indexOf('value="Kaufen"') == -1) {
  2514. var nr = districts[i].split('value="')[1].split('"')[0];
  2515. var ff = Number(districts[i].split("<td")[4].split("</td")[0].split(">").pop().replace("&nbsp;", "").trim());
  2516. var bonus = districts[i].split("<td")[5].split("<span").pop().split("</span")[0].replace("<br/>", " ").split(">").pop().trim();
  2517. if (bonus == "frei")
  2518. bonus = "";
  2519. else if (bonus != "")
  2520. bonus = " (" + bonus.replace("&nbsp;", " ") + ")";
  2521. var fmtch = districts[i].replace(/&nbsp;/g, " ").match(/\d+% schneller Sammeln/);
  2522. option += '<option value="' + nr + '">' + distr + '</option> ';
  2523. if (bonus.indexOf("schneller Sammeln") != -1) {
  2524. foption += '<option value="' + nr + '">' + distr + bonus + '</option>';
  2525. var proz = Number(bonus.match(/\d+/)[0]);
  2526. if (proz >= fastest) {
  2527. if (proz > fastest || distr == district || distr == PGu_getValue("befDistrict", "0;").split(";")[1])
  2528. setfast = nr + ";" + distr;
  2529. fastest = proz;
  2530. }
  2531. }
  2532. else {
  2533. if (bonus.indexOf("mehr " + flaschentxt) != -1)
  2534. moption += '<option value="' + nr + '">' + distr + " (FF: " + ff + ")" + bonus + '</option> ';
  2535. else
  2536. moption += '<option value="' + nr + '">' + distr + '</option> ';
  2537. }
  2538. hdist.push([ff, nr, distr, bonus]);
  2539. dist[nr] = distr;
  2540. }
  2541. else {
  2542. if (PGu_getValue("homeDistrict", "0;" + distr).split(";")[1] == distr)
  2543. PGu_setValue("homeDistrict", "");
  2544. if (PGu_getValue("befDistrict", "0;" + distr).split(";")[1] == distr)
  2545. PGu_setValue("befDistrict", "");
  2546. if (PGu_getValue("aftDistrict", "0;" + distr).split(";")[1] == distr)
  2547. PGu_setValue("aftDistrict", "");
  2548. }
  2549. }
  2550. if (hdist.length < 2)
  2551. PGu_setValue("chooseDistrict", false);
  2552. else {
  2553. hdist.sort(function(a,b) {return a[0]>b[0]?-1:(a[0]<b[0]?1:(a[2]<b[2]?-1:1));});
  2554. var hoption = '<option value="0"> </option> ';
  2555. var moption = '<option value="0"> </option> ';
  2556. for (var i = 0; i < hdist.length; i++) {
  2557. var mplnd = [];
  2558. for (var j = 0; j < mpdist.length; j++)
  2559. if (mpdist[j].indexOf(hdist[i][2]) != -1)
  2560. mplnd.push(mplunder[j]);
  2561. if (mplnd.length > 0)
  2562. mplnd = " (" + mplnd.join(", ") + ")";
  2563. else
  2564. mplnd = "";
  2565. bonus = hdist[i][3];
  2566. hoption += '<option value="' + hdist[i][1] + '">' + hdist[i][2] + mplnd + " (FF: " + hdist[i][0] + ")" + bonus + '</option> ';
  2567. if (hdist[i][3].indexOf("mehr " + flaschentxt) == -1)
  2568. bonus = "";
  2569. moption += '<option value="' + hdist[i][1] + '">' + hdist[i][2] + mplnd + " (FF: " + hdist[i][0] + ")" + bonus + '</option> ';
  2570. }
  2571.  
  2572. if (fastest == 0)
  2573. foption = option;
  2574. else
  2575. PGu_setValue("befDistrict", setfast);
  2576. var homeDist = PGu_getValue("homeDistrict", "0;" + district);
  2577. var befDist = PGu_getValue("befDistrict", "0;" + district);
  2578. var aftDist = PGu_getValue("aftDistrict", "0;" + district);
  2579. var newtd2 = document.createElement("span");
  2580. var newtd3 = document.createElement("span");
  2581. var newtd4 = document.createElement("span");
  2582. newtd2.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  2583. newtd3.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  2584. newtd4.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  2585. newtd2.innerHTML = '<form name="cityhome" id="cityhome">Heimatstandort: <input id="movehom" style="visibility:hidden; float:right; position:relative; top:-5px" type="button" value="nach ' + homeDist.split(";")[1] + ' ziehen"> <select id="cityhomeid" name="cityhomeid"> ' + hoption + ' </select>';
  2586. newtd3.innerHTML = '<form style="padding-top: 10px" name="citybefore" id="citybefore">vor Start wechseln nach: <input id="movebef" style="visibility:hidden; float:right; position:relative; top:-5px" type="button" value="nach ' + befDist.split(";")[1] + ' ziehen"> <select id="citybefid" name="citybefid"> ' + foption + ' </select>';
  2587. newtd4.innerHTML = '<form style="padding-top: 10px; padding-bottom: 10px" name="cityafter" id="cityafter">vor Ausleeren wechseln nach: <input id="moveaft" style="visibility:hidden; float:right; position:relative; top:-5px" type="button" value="nach ' + aftDist.split(";")[1] + ' ziehen"> <select id="cityaftid" name="cityaftid"> ' + moption + ' </select>';
  2588. submitBtn.parentNode.appendChild(newtd2, document.getElementsByName("xycoords")[0]);
  2589. submitBtn.parentNode.appendChild(newtd3, document.getElementsByName("xycoords")[0]);
  2590. submitBtn.parentNode.appendChild(newtd4, document.getElementsByName("xycoords")[0]);
  2591. document.getElementById("cityhomeid").value = PGu_getValue("homeDistrict", "0").split(";")[0];
  2592. document.getElementById("citybefid").value = PGu_getValue("befDistrict", "0").split(";")[0];
  2593. document.getElementById("cityaftid").value = PGu_getValue("aftDistrict", "0").split(";")[0];
  2594. if (homeDist.split(";")[0] != "0" && homeDist.split(";")[1] != district) {
  2595. document.getElementById("movehom").value = "nach " + homeDist.split(";")[1] + " ziehen";
  2596. document.getElementById("movehom").style.visibility = "";
  2597. }
  2598. document.getElementById("movehom").addEventListener("click", function(event) {
  2599. moveTo(homeDist.split(";")[0], "", "");
  2600. }, false);
  2601. if (befDist.split(";")[0] != "0" && befDist.split(";")[1] != district) {
  2602. document.getElementById("movebef").value = "nach " + befDist.split(";")[1] + " ziehen";
  2603. document.getElementById("movebef").style.visibility = "";
  2604. }
  2605. document.getElementById("movebef").addEventListener("click", function(event) {
  2606. moveTo(befDist.split(";")[0], "", "");
  2607. }, false);
  2608. if (aftDist.split(";")[0] != "0" && aftDist.split(";")[1] != district) {
  2609. document.getElementById("moveaft").value = "nach " + aftDist.split(";")[1] + " ziehen";
  2610. document.getElementById("moveaft").style.visibility = "";
  2611. }
  2612. document.getElementById("moveaft").addEventListener("click", function(event) {
  2613. moveTo(aftDist.split(";")[0], "", "");
  2614. }, false);
  2615. // Click-Handler hinzufügen
  2616. document.getElementById("cityhomeid").addEventListener("change", function(event) {
  2617. // Klickstatus speichern
  2618. if (this.value == "0") {
  2619. PGu_setValue("homeDistrict", "");
  2620. document.getElementById("movehom").style.visibility = "hidden";
  2621. }
  2622. else {
  2623. homeDist = this.value + ";" + dist[this.value];
  2624. PGu_setValue("homeDistrict", homeDist);
  2625. if (dist[this.value] != district) {
  2626. document.getElementById("movehom").value = "nach " + homeDist.split(";")[1] + " ziehen";
  2627. document.getElementById("movehom").style.visibility = "";
  2628. }
  2629. else
  2630. document.getElementById("movehom").style.visibility = "hidden";
  2631. }
  2632. }, false);
  2633. document.getElementById("citybefid").addEventListener("change", function(event) {
  2634. // Klickstatus speichern
  2635. if (this.value == "0") {
  2636. PGu_setValue("befDistrict", "");
  2637. document.getElementById("movebef").style.visibility = "hidden";
  2638. }
  2639. else {
  2640. befDist = this.value + ";" + dist[this.value];
  2641. PGu_setValue("befDistrict", befDist);
  2642. if (dist[this.value] != district) {
  2643. document.getElementById("movebef").value = "nach " + befDist.split(";")[1] + " ziehen";
  2644. document.getElementById("movebef").style.visibility = "";
  2645. }
  2646. else
  2647. document.getElementById("movebef").style.visibility = "hidden";
  2648. }
  2649. }, false);
  2650. document.getElementById("cityaftid").addEventListener("change", function(event) {
  2651. // Klickstatus speichern
  2652. if (this.value == "0") {
  2653. PGu_setValue("aftDistrict", "");
  2654. document.getElementById("moveaft").style.visibility = "hidden";
  2655. }
  2656. else {
  2657. aftDist = this.value + ";" + dist[this.value];
  2658. PGu_setValue("aftDistrict", aftDist);
  2659. if (dist[this.value] != district) {
  2660. document.getElementById("moveaft").value = "nach " + aftDist.split(";")[1] + " ziehen";
  2661. document.getElementById("moveaft").style.visibility = "";
  2662. }
  2663. else
  2664. document.getElementById("moveaft").style.visibility = "hidden";
  2665. }
  2666. }, false);
  2667. }
  2668. }
  2669. else
  2670. trace("Fehler beim Laden", 2);
  2671. }});
  2672. }
  2673. function insertCheckBox2(loaded) {
  2674. var newtd = document.createElement("td");
  2675. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  2676. var male = "";
  2677. if (PGu_getValue("AutoCrime", false))
  2678. male = " (noch " + PGu_getValue("AutoCrimeFkt", 0) + " Mal)";
  2679. newtd.innerHTML = '<input name="SCCheckbox" id="SCCheckbox" type="checkbox"><span style="vertical-align: bottom">&nbsp;Automatisch starten' + male + '</span>';
  2680. var buttons = document.getElementsByTagName("button");
  2681. if (buttons.length > 0)
  2682. var button = buttons[0];
  2683. else {
  2684. buttons = document.getElementsByName("xycoords");
  2685. var button = buttons[buttons.length-1];
  2686. }
  2687. button.parentNode.insertBefore(newtd, button);
  2688. document.getElementById("SCCheckbox").checked = PGu_getValue("AutoCrime", false);
  2689. // Click-Handler hinzufügen
  2690. document.getElementById("SCCheckbox").addEventListener("click", function(event) {
  2691. // Klickstatus speichern
  2692. if (this.checked) {
  2693. if (PGu_getValue("AutoCrimePic", "") == "") {
  2694. alert("Bitte erst " + crimetxt + " festlegen !!");
  2695. this.checked = false;
  2696. }
  2697. if (PGu_getValue("AutoCrimeFkt", -1) <= 0)
  2698. PGu_setValue("AutoCrimeFkt", 1);
  2699. }
  2700. PGu_setValue("AutoCrime", this.checked);
  2701. reload("insertCheckBox2");
  2702. }, false);
  2703. }
  2704.  
  2705. function insertCheckBox3(button) {
  2706. var crimepic = button.parentNode.parentNode.innerHTML.split('plunder_crime/')[1].split('"')[0];
  2707. var name = 'CbButton_' + crimepic;
  2708. var newtd = document.createElement("td");
  2709. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  2710. newtd.innerHTML = '<input name="CbCrime" id="' + name +'" type="checkbox"><span style="vertical-align: bottom">&nbsp;diese' + (TOWNEXTENSION!="VT"&&TOWNEXTENSION!="AT"?"s ":" ") + crimetxt + '&nbsp;&nbsp;</span><input name="CbCrimeFkt" style="width:30px" id="' + name +'Fkt"><span style="vertical-align: bottom">mal automatisch starten</span>';
  2711. button.parentNode.appendChild(newtd, button);
  2712. var crimep = PGu_getValue("AutoCrimePic", "");
  2713. if (crimep == crimepic) {
  2714. document.getElementById(name).checked = true;
  2715. document.getElementById(name+"Fkt").value=PGu_getValue("AutoCrimeFkt",1);
  2716. }
  2717. // Click-Handler hinzufügen
  2718. document.getElementById(name+"Fkt").addEventListener("change", function(event) {
  2719. var crimeFkt = parseInt(document.getElementById(this.id).value);
  2720. if (isNaN(crimeFkt))
  2721. crimeFkt = 1;
  2722. document.getElementById(this.id).value = crimeFkt;
  2723. PGu_setValue("AutoCrimeFkt", crimeFkt);
  2724. }, false);
  2725.  
  2726.  
  2727. // Click-Handler hinzufügen
  2728. document.getElementById(name).addEventListener("click", function(event) {
  2729. var crimepic = this.id.split("_")[1];
  2730. crimepic = this.parentNode.parentNode.parentNode.innerHTML.split('plunder_crime/')[1].split('"')[0];
  2731. if (this.parentNode.parentNode.innerHTML.split("start_crime(").length > 1)
  2732. var crimeNr = this.parentNode.parentNode.innerHTML.split("start_crime(")[1].split(")")[0];
  2733. else
  2734. var crimeNr = 0;
  2735. // Klickstatus speichern
  2736. if (this.checked) {
  2737. PGu_setValue("AutoCrime", true);
  2738. PGu_setValue("AutoCrimePic", crimepic);
  2739. PGu_setValue("AutoCrimeNr", crimeNr);
  2740. var crimeFkt = parseInt(document.getElementById(this.id+"Fkt").value);
  2741. if (isNaN(crimeFkt) || crimeFkt <= 0)
  2742. crimeFkt = 1;
  2743. document.getElementById(this.id+"Fkt").value = crimeFkt;
  2744. PGu_setValue("AutoCrimeFkt", crimeFkt);
  2745. var buttons = document.getElementsByName("CbCrime");
  2746. for (var i = 0; i < buttons.length; i++) {
  2747. var crimep = buttons[i].parentNode.parentNode.parentNode.innerHTML.split('plunder_crime/')[1].split('"')[0];
  2748. if (crimepic != crimep) {
  2749. document.getElementById(buttons[i].id).checked = false;
  2750. document.getElementById(buttons[i].id+"Fkt").value = "";
  2751. }
  2752. }
  2753. }
  2754. else {
  2755. PGu_setValue("AutoCrimePic", "");
  2756. PGu_setValue("AutoCrimeNr", 0);
  2757. PGu_setValue("AutoCrimeFkt", 0);
  2758. PGu_setValue("AutoCrime", false);
  2759. }
  2760. }, false);
  2761. }
  2762. function insertCheckBox4() {
  2763. var newtd = document.createElement("li");
  2764. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  2765. newtd.innerHTML = '<input name="GSCheckbox" id="GSCheckbox" type="checkbox"><span style="vertical-align: bottom">&nbsp;Geld automatisch einsacken</span>';
  2766. var town = ["HH", "B", "MU", "HR", "K"];
  2767. var sptown = (town.indexOf(TOWNEXTENSION) != -1);
  2768. if (sptown) {
  2769. var option = '<option value="4everproxy">4everproxy.com</option> ';
  2770. newtd.innerHTML += '<form name="spsammler" id="spsammler" style="visibility:hidden" >Spenden sammeln über: <select id="spsammlerid" name="spsammlerid"> ' + option + ' </select> </form>';
  2771. }
  2772. var tieritems = document.getElementsByClassName("tieritemA");
  2773. for (var i = 0; i < tieritems.length; i++) {
  2774. if (tieritems[i].innerHTML.indexOf("minijobs") != -1 || tieritems[i].innerHTML.indexOf("change_please") != -1) {
  2775. var lis = tieritems[i].getElementsByClassName("double");
  2776. if (lis.length == 0)
  2777. lis = tieritems[i].getElementsByClassName("first");
  2778. lis = lis[lis.length-1].getElementsByTagName("li");
  2779. lis[lis.length-1].parentNode.appendChild(newtd, lis[lis.length-1]);
  2780. document.getElementById("GSCheckbox").checked = PGu_getValue("getSalary", false);
  2781. if (sptown) {
  2782. if (PGu_getValue("getSalary", false))
  2783. document.getElementById("spsammler").style.visibility = "visible";
  2784. document.getElementById("spsammlerid").value = PG_getValue("spendensammler", "4everproxy");
  2785. }
  2786. // Click-Handler hinzufügen
  2787. document.getElementById("GSCheckbox").addEventListener("click", function(event) {
  2788. // Klickstatus speichern
  2789. PGu_setValue("getSalary", this.checked);
  2790. GM_deleteValue("4everproxy");
  2791. PGu_delete("spendenwait");
  2792. PGu_delete("spendenrest");
  2793. if (sptown) {
  2794. if (this.checked)
  2795. document.getElementById("spsammler").style.visibility = "visible";
  2796. else
  2797. document.getElementById("spsammler").style.visibility = "hidden";
  2798. }
  2799. }, false);
  2800. // Click-Handler hinzufügen
  2801. if (sptown)
  2802. document.getElementById("spsammlerid").addEventListener("change", function(event) {
  2803. PG_setValue("spendensammler", this.value);
  2804. }, false);
  2805. }
  2806. }
  2807. }
  2808.  
  2809. function selectcraft(i, craftlist, usedPlunder, tr) {
  2810. function handleClick(id, value) {
  2811. // neuen Wert speichern
  2812. var craftnr = id.replace("craftid", "");
  2813. if (value == "0")
  2814. usedPlunder.splice(craftnr, 1);
  2815. else {
  2816. usedPlunder[craftnr] = value;
  2817. PGu_setValue("craftindex", 0);
  2818. }
  2819. PGu_setValue("craftlist", usedPlunder.join(";"));
  2820. for (var i = 0; document.getElementById("craftid"+i); i++) {
  2821. if (i == usedPlunder.length - 1) {
  2822. if (document.getElementById("craftid"+(i+1)))
  2823. document.getElementById("craft"+(i+1)).parentNode.parentNode.style.visibility = "visible";
  2824. else {
  2825. var newtd = document.createElement("td");
  2826. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  2827. var newtr = document.createElement("tr");
  2828. var option = '<option value="0"> </option> ';
  2829. for (var j = 0; j < craftlist.length; j++) {
  2830. var pos = usedPlunder.indexOf(craftlist[j][1]);
  2831. if (pos == -1)
  2832. option += '<option value="' + craftlist[j][1] + '">' + craftlist[j][0] + '</option> ';
  2833. }
  2834. 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>';
  2835. newtr.appendChild(newtd, newtr);
  2836. tr.parentNode.appendChild(newtr, tr);
  2837. // Click-Handler hinzufügen
  2838. document.getElementById("craftid"+(i+1)).addEventListener("change", function(event) {
  2839. handleClick(this.id, this.value);
  2840. }, false);
  2841. continue;
  2842. }
  2843. }
  2844. if (i > usedPlunder.length) {
  2845. document.getElementById("craft"+i).parentNode.parentNode.style.visibility = "hidden";
  2846. continue;
  2847. }
  2848. var option = '<option value="0"> </option> ';
  2849. for (var j = 0; j < craftlist.length; j++) {
  2850. var pos = usedPlunder.indexOf(craftlist[j][1]);
  2851. if (pos == -1 || pos == i)
  2852. option += '<option value="' + craftlist[j][1] + '">' + craftlist[j][0] + '</option> ';
  2853. }
  2854. document.getElementById("craftid"+i).innerHTML = option;
  2855. document.getElementById("craftid"+i).value = i < usedPlunder.length?usedPlunder[i]:"0";
  2856. }
  2857. }
  2858.  
  2859. var option = '<option value="0"> </option> ';
  2860. for (var j = 0; j < craftlist.length; j++) {
  2861. var pos = usedPlunder.indexOf(craftlist[j][1]);
  2862. if (pos == -1 || pos == i)
  2863. option += '<option value="' + craftlist[j][1] + '">' + craftlist[j][0] + '</option> ';
  2864. }
  2865. var newtd = document.createElement("td");
  2866. var newtr = document.createElement("tr");
  2867. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  2868. var pid = i < usedPlunder.length?usedPlunder[i]:"0";
  2869. 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>';
  2870. newtr.appendChild(newtd, newtr);
  2871. tr.parentNode.appendChild(newtr, tr);
  2872. document.getElementById("craftid"+i).value = pid;
  2873. if (!PGu_getValue("autoDaily", false))
  2874. document.getElementById("craft"+i).parentNode.parentNode.style.visibility = "hidden";
  2875. else
  2876. document.getElementById("craft"+i).parentNode.parentNode.style.visibility = "visible";
  2877. // Click-Handler hinzufügen
  2878. document.getElementById("craftid"+i).addEventListener("change", function(event) {
  2879. handleClick(this.id, this.value);
  2880. }, false);
  2881. }
  2882. var eventPlunder = [
  2883. "Geschenk", "Weihnachtsmütze", "Schere", "Kölner Plörre", "Gebiss",
  2884. "Lupe", "Rote Weihnachtssocke", "Grüne Weihnachtssocke", "Gelbe Weihnachtssocke",
  2885. "Dynamit", "Zwiebelkuchen", "Wollhandschuhe", "Eispickel", "Karnevalströte",
  2886. "Roter Partyballon", "Grüner Partyballon", "Gelber Partyballon",
  2887. "Hasenpfote", "Plüschhäschen","Hacke", "Hacke",
  2888. "Molotowcocktail", "Absperrung", "Farbflutkiosk", "Mülleimer", "Polizeiwagen", "Bullenbully",
  2889. "Rabattflyer", "Schwarzer Nagellack", "George Clooney Double",
  2890. "Gutscheincode", "Nagellackentferner", "Johnny Depp Original",
  2891. "Fußballerina", "Schlüpper", "BH", "Dildo",
  2892. "Orange", "Banane", "Maracuja", "Ananas", "Kokusnuss", "Erdbeere", "Apfel", "Limette",
  2893. "Strohhalm", "Cocktailkirsche", "Cocktailschirmchen", "Minzblättchen",
  2894. "Fruchtschalenspirale", "Physalis", "Cocktailglas", "Eiswürfel"];
  2895. var evPlunder = [];
  2896.  
  2897. function getPlunderlist(k, pltab, allplunderArr, tr, mincost, allplunder, plunderlist, link)
  2898. {
  2899. function buildSelectBox(allplunderArr, tr, mode, mincost) {
  2900. var newtd = document.createElement("td");
  2901. var newtr = document.createElement("tr");
  2902. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  2903. var option = '<option value="0"> </option> ';
  2904. for (var i = 0; i < allplunderArr.length; i++)
  2905. if (allplunderArr[i][4] >= mincost)
  2906. option += '<option value="' + allplunderArr[i][2] + '">' + allplunderArr[i][0] + ' [x' + allplunderArr[i][1] + '] (' + allplunderArr[i][3] + ')</option> ';
  2907. var pid = PGu_getValue("sellPlunder" + (mode==0?"":mode), 0);
  2908. var text = "Plunder verkaufen" + (mode==0?"":", wenn kein Geld mehr");
  2909. newtd.innerHTML = '<form name="plunderdef' + mode + '" id="plunderdef' + mode + '">' + text + ': <select id="pid' + mode + '" name="pid' + mode + '"> ' + option + ' </select> </form>';
  2910. newtr.appendChild(newtd, newtr);
  2911. tr.parentNode.appendChild(newtr, tr);
  2912. document.getElementById("pid" + mode).value = pid;
  2913. if (!PGu_getValue("autoDaily", false) && mode == 0)
  2914. document.getElementById("plunderdef"+mode).parentNode.parentNode.style.visibility = "hidden";
  2915. else
  2916. document.getElementById("plunderdef"+mode).parentNode.parentNode.style.visibility = "visible";
  2917. // Click-Handler hinzufügen
  2918. document.getElementById("pid"+mode).addEventListener("change", function(event) {
  2919. // neuen Wert speichern
  2920. PGu_setValue("sellPlunder"+(mode==0?"":mode), this.value);
  2921. }, false);
  2922. }
  2923. if (pltab == 0) {
  2924. trace('Get ' + prothost + '/stock/plunder/', 2);
  2925. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/plunder/', onload:function(responseDetails) {
  2926. var content = responseDetails.responseText.split('id="plundertab"')[1];
  2927. var lis = content.split("</ul>")[0].split("<li>");
  2928. pltab = lis.length - 1;
  2929. link = lis[1].split('href="')[1].split("=")[0] + "=";
  2930. getPlunderlist(k, pltab, allplunderArr, tr, mincost, allplunder, plunderlist, link);
  2931. }});
  2932. return;
  2933. }
  2934.  
  2935. trace('Get ' + prothost + link + k, 2);
  2936. GM_xmlhttpRequest({method:"GET", url: prothost + link + k, onload:function(responseDetails) {
  2937. var content = responseDetails.responseText;
  2938.  
  2939. var trs = content.split("<tr ");
  2940. for (var i = 1; i < trs.length; i++) {
  2941. var plname = trs[i].split(">x ")[0].split("</strong")[0].split(">").pop().trim();
  2942. var plAnz = trs[i].split(">x ")[1].split("<")[0].trim();
  2943. var pid = trs[i].split('pm_')[1].split("'")[0].trim();
  2944. var cost = trs[i].split("show_multiple_sell")[1].split("<li>")[1].split("</li>")[0].split("(")[1].match(/ .*[\d.,]+/)[0].trim();
  2945. var cost2 = Number(cost.match(/[\d.,]+/)[0].replace(/[.,]/g, ""));
  2946. if (plunderlist.indexOf(plname) == -1) {
  2947. var misspl = 0;
  2948. if (trs[i].indexOf('"pinfo2"') != -1)
  2949. if (trs[i].split('"pinfo2"')[1].indexOf("Missionsplunder") != -1 ||
  2950. trs[i].split('"pinfo2"')[1].indexOf("Bandenmission") != -1)
  2951. misspl = 1;
  2952. allplunder.push(plname+":"+misspl);
  2953. plunderlist.push(plname);
  2954. }
  2955. for (var j = 0; j < allplunderArr.length; j++)
  2956. if (allplunderArr[j][4] < cost2)
  2957. break;
  2958. allplunderArr.splice(j, 0, [plname, plAnz, pid, cost, cost2]);
  2959. if (eventPlunder.indexOf(plname) != -1)
  2960. evPlunder.push(allplunderArr[j]);
  2961. }
  2962. if (k < pltab)
  2963. getPlunderlist(k+1, pltab, allplunderArr, tr, mincost, allplunder, plunderlist, link);
  2964. else {
  2965. PG_setValue("allplunder", allplunder.join(";"));
  2966. var evCost = 0;
  2967. var evAnz = 0;
  2968. var title = "";
  2969. var e = document.createElement('div');
  2970. for (var j = 0; j < evPlunder.length; j++) {
  2971. evAnz += Number(evPlunder[j][1]);
  2972. evCost = evCost + Number(evPlunder[j][1]) * evPlunder[j][4];
  2973. e.innerHTML = evPlunder[j][3];
  2974. title += '<tr><td style="border-bottom:0px">' + evPlunder[j][1] + "x " + evPlunder[j][0] + " (" + e.childNodes[0].nodeValue + ')</td></tr>';
  2975. }
  2976. /*
  2977. title = '<tr><td style="font-size:16px;border-bottom:0px">Du besitzt ' + evAnz + " Stück Eventplunder im Wert von " + e.childNodes[0].nodeValue.match(/[^\d]+/)[0] + Math.floor(evCost/100) + "," + evCost.toString().substr(-2) + ":</td></tr><br>" + title;
  2978. var today = new Date();
  2979. var tagesdatum = FormatDate(today);
  2980. if (evPlunder.length > 0) {
  2981. if (tagesdatum <= "2015-09-10" && PGu_getValue("eventPlunderWarning", "") < tagesdatum) {
  2982. e.innerHTML = evPlunder[0][3];
  2983. alert("Du besitzt " + evAnz + " Stück Eventplunder im Wert von " + e.childNodes[0].nodeValue.match(/[^\d]+/)[0] + Math.floor(evCost/100) + "," + evCost.toString().substr(-2));
  2984. PGu_setValue("eventPlunderWarning", tagesdatum);
  2985. }
  2986. var newtr2 = document.createElement("tr");
  2987. var newtd2 = document.createElement("input");
  2988. newtd2.id = 'sellEventPlnd';
  2989. newtd2.type = 'button';
  2990. newtd2.value = 'Eventplunder verkaufen';
  2991. newtd2.onmouseover = function () { document.getElementById("eventPlunderInfo").style.display = "" };
  2992. newtd2.onmouseout = function () { document.getElementById("eventPlunderInfo").style.display = "none" };
  2993. var width = 450;
  2994. var newspan = document.createElement('span');
  2995. newspan.id = "eventPlunderInfo";
  2996. newspan.style.width = width+"px";
  2997. newspan.style.color = "white";
  2998. newspan.style.backgroundColor = "#505050";
  2999. newspan.style.fontSize = "12px";
  3000. newspan.style.position = "absolute";
  3001. newspan.style.display = "none";
  3002. newspan.style.zIndex = "100";
  3003. newspan.innerHTML = '<table>' + title + '</table>';
  3004. newtr2.appendChild(newtd2, newtr2);
  3005. newtr2.appendChild(newspan);
  3006. tr.parentNode.appendChild(newtr2, tr);
  3007. document.getElementById("sellEventPlnd").addEventListener("click", function(event) {
  3008. sellManyPlunder(evPlunder);
  3009. }, false);
  3010. var newtd3 = document.createElement("td");
  3011. var newtr3 = document.createElement("tr");
  3012. newtd3.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  3013. newtd3.innerHTML = '<input name="eventPlndNoRem" id="eventPlndNoRem" type="checkbox"><span style="vertical-align: bottom">&nbsp;Nicht mehr an Eventplunderverkauf erinnern</span>';
  3014. newtr3.appendChild(newtd3, newtr3);
  3015. tr.parentNode.appendChild(newtr3, tr);
  3016. document.getElementById("eventPlndNoRem").checked = PGu_getValue("eventPlunderWarning", tagesdatum) >= '2015-09-10';
  3017. // Click-Handler hinzufügen
  3018. document.getElementById("eventPlndNoRem").addEventListener("change", function(event) {
  3019. // neuen Wert speichern
  3020. if (this.checked)
  3021. PGu_setValue("eventPlunderWarning", '2015-09-30');
  3022. else
  3023. PGu_setValue("eventPlunderWarning", tagesdatum);
  3024. }, false);
  3025. }
  3026. */
  3027. buildSelectBox(allplunderArr, tr, 1, mincost);
  3028. if (expertMode) {
  3029. var newtd0 = document.createElement("td");
  3030. var newtr0 = document.createElement("tr");
  3031. newtd0.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  3032. var dtsitttime = PGu_getValue("dtsitttime", latestDTtime);
  3033. newtd0.innerHTML = '<form name="dtsitting" id="dtsitting"><input name="dtsittingChb" id="dtsittingChb" type="checkbox" style="vertical-align:middle"><span style="vertical-align: middle">&nbsp;wenn bis <input id="dtsitthr" name="dtsitthr" style="width:20px;text-align:right">:<input id="dtsittmi" name="dtsittmi" style="width:20px"> nicht erledigt, dann per Sitting erledigen</span></form>';
  3034. newtr0.appendChild(newtd0, newtr0);
  3035. tr.parentNode.appendChild(newtr0, tr);
  3036. document.getElementById("dtsittingChb").checked = PGu_getValue("dtsitting", false) && m_ownusername.toLowerCase() == GM_getValue(host + "_username", "").toLowerCase();
  3037. // Click-Handler hinzufügen
  3038. document.getElementById("dtsittingChb").addEventListener("change", function(event) {
  3039. // neuen Wert speichern
  3040. if (this.checked)
  3041. if (m_ownusername.toLowerCase() != GM_getValue(host + "_username", "").toLowerCase()) {
  3042. alert("Passwort unbekannt. Bitte neu einloggen.");
  3043. this.checked = false;
  3044. return;
  3045. }
  3046. PGu_setValue("dtsitting", this.checked);
  3047. }, false);
  3048. document.getElementById("dtsitthr").value = dtsitttime.split(":")[0];
  3049. document.getElementById("dtsittmi").value = dtsitttime.split(":")[1];
  3050. if (PGu_getValue("autoDaily", false))
  3051. document.getElementById("dtsitting").parentNode.parentNode.style.visibility = "visible";
  3052. else
  3053. document.getElementById("dtsitting").parentNode.parentNode.style.visibility = "hidden";
  3054. // Click-Handler hinzufügen
  3055. function timeChecker(obj, indx) {
  3056. if (indx != 0 && indx != 1)
  3057. return;
  3058. var dtsitttime = PGu_getValue("dtsitttime", latestDTtime).split(":");
  3059. var val = dtsitttime[indx];
  3060. dtsitttime[indx] = obj.value.length < 2 ? ("00" + obj.value).substr(-2) : obj.value;
  3061. if (isNaN(obj.value) || Number(obj.value) < 0 || Number(obj.value) > (indx == 0 ? 23 : 59) || dtsitttime.join(":") > latestDTtime)
  3062. dtsitttime[indx] = val;
  3063. else // neuen Wert speichern
  3064. PGu_setValue("dtsitttime", dtsitttime.join(":"));
  3065. obj.value = dtsitttime[indx];
  3066. }
  3067.  
  3068. document.getElementById("dtsitthr").addEventListener("change", function(event) {
  3069. timeChecker(this, 0);
  3070. }, false);
  3071. document.getElementById("dtsittmi").addEventListener("change", function(event) {
  3072. timeChecker(this, 1);
  3073. }, false);
  3074. }
  3075.  
  3076. buildSelectBox(allplunderArr, tr, 0, 1);
  3077. trace('Get ' + prothost + '/friendlist/', 2);
  3078. GM_xmlhttpRequest({method:"GET", url: prothost + '/friendlist/', onload:function(responseDetails) {
  3079. var content = responseDetails.responseText;
  3080. // Wenn die Seite abgerufen werden konnte (kein Seitenladefehler)
  3081. if (content.indexOf("<strong>Mein Penner</strong>") != -1) {
  3082. var newtd = document.createElement("td");
  3083. var newtr = document.createElement("tr");
  3084. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  3085. var friendid = PGu_getValue("friendid", "0");
  3086. var friends = content.split('class="listshop"')[1].split("<table ")[1].split("</table")[0].split("/profil/id:");
  3087. var option = '<option value="0"> </option> ';
  3088. for (var i = 1; i < friends.length; i++) {
  3089. option += '<option value="' + friends[i].split("/")[0] + '">' + friends[i].split("<")[0].split(">")[1].trim() + '</option> ';
  3090. }
  3091. newtd.innerHTML = '<form name="frienddef" id="frienddef">PN senden an: <select id="friendid" name="friendid"> ' + option + ' </select> </form>';
  3092. newtr.appendChild(newtd, newtr);
  3093. tr.parentNode.appendChild(newtr, tr);
  3094. document.getElementById("friendid").value = friendid;
  3095. if (!PGu_getValue("autoDaily", false))
  3096. document.getElementById("frienddef").parentNode.parentNode.style.visibility = "hidden";
  3097. else
  3098. document.getElementById("frienddef").parentNode.parentNode.style.visibility = "visible";
  3099. // Click-Handler hinzufügen
  3100. document.getElementById("friendid").addEventListener("change", function(event) {
  3101. // neuen Wert speichern
  3102. PGu_setValue("friendid", this.value);
  3103. }, false);
  3104. if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" || TOWNEXTENSION == "MU" ||
  3105. TOWNEXTENSION == "HR" || TOWNEXTENSION == "K") {
  3106. var newtd2 = document.createElement("td");
  3107. var newtr2 = document.createElement("tr");
  3108. newtd2.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  3109. newtd2.innerHTML = '<input name="LoseKaufSofort" id="LoseKaufSofort" type="checkbox"><span style="vertical-align: bottom">&nbsp;Lose ohne Rücksicht auf Casino-Besuch kaufen</span>';
  3110. newtr2.appendChild(newtd2, newtr2);
  3111. tr.parentNode.appendChild(newtr2, tr);
  3112. document.getElementById("LoseKaufSofort").checked = PGu_getValue("LoseKaufSofort", false);
  3113. if (!PGu_getValue("autoDaily", false))
  3114. document.getElementById("LoseKaufSofort").parentNode.parentNode.style.visibility = "hidden";
  3115. else
  3116. document.getElementById("LoseKaufSofort").parentNode.parentNode.style.visibility = "visible";
  3117. // Click-Handler hinzufügen
  3118. document.getElementById("LoseKaufSofort").addEventListener("change", function(event) {
  3119. // neuen Wert speichern
  3120. PGu_setValue("LoseKaufSofort", this.checked);
  3121. }, false);
  3122. }
  3123. else
  3124. PGu_setValue("LoseKaufSofort", true);
  3125. if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" || TOWNEXTENSION == "MU" ||
  3126. TOWNEXTENSION == "HR" || TOWNEXTENSION == "K") {
  3127. var newtd2 = document.createElement("td");
  3128. var newtr2 = document.createElement("tr");
  3129. newtd2.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  3130. var donlink = PGu_getValue("donationlink", "");
  3131. newtd2.innerHTML = '<form>Spendenlink: <input style="color: black; background-color:white; width:300px" type="text" name="donlink" id="donlink"></form>';
  3132. newtr2.appendChild(newtd2, newtr2);
  3133. tr.parentNode.appendChild(newtr2, tr);
  3134. document.getElementById("donlink").value = donlink;
  3135. if (!PGu_getValue("autoDaily", false))
  3136. document.getElementById("donlink").parentNode.parentNode.style.visibility = "hidden";
  3137. else
  3138. document.getElementById("donlink").parentNode.parentNode.style.visibility = "visible";
  3139. // Click-Handler hinzufügen
  3140. document.getElementById("donlink").addEventListener("change", function(event) {
  3141. // neuen Wert speichern
  3142. PGu_setValue("donationlink", this.value);
  3143. }, false);
  3144. }
  3145. }
  3146. trace('Get ' + prothost + '/stock/plunder/craftlist/', 2);
  3147. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/plunder/craftlist/', onload:function(responseDetails) {
  3148. var table = responseDetails.responseText.split("<table").pop().split("</table")[0];
  3149. var trs = table.split("<tr");
  3150. var craftlist = [];
  3151. for (var i = 1; i < trs.length; i++) {
  3152. if (trs[i].indexOf('href="/stock/plunder/craft/details/') == -1)
  3153. continue;
  3154. var details = trs[i].split('href="/stock/plunder/craft/details/')[1];
  3155. if (details.indexOf("disabled") != -1)
  3156. continue;
  3157. var pid = details.split("/")[0];
  3158. var plunder = details.split("</strong")[0].split(">").pop();
  3159. craftlist.push([plunder, pid]);
  3160. }
  3161. var usedPlunder = PGu_getValue("craftlist", "").split(";");
  3162. for (var i = 0; i <= usedPlunder.length; i++)
  3163. var pid = selectcraft(i, craftlist, usedPlunder, tr);
  3164. }});
  3165. }});
  3166. }
  3167. }});
  3168. }
  3169.  
  3170. function setVisibility(vsbl) {
  3171. document.getElementById("dtsitting").parentNode.parentNode.style.visibility = vsbl;
  3172. document.getElementById("plunderdef0").parentNode.parentNode.style.visibility = vsbl;
  3173. document.getElementById("frienddef").parentNode.parentNode.style.visibility = vsbl;
  3174. if (document.getElementById("donlink"))
  3175. document.getElementById("donlink").parentNode.parentNode.style.visibility = vsbl;
  3176. if (document.getElementById("LoseKaufSofort"))
  3177. document.getElementById("LoseKaufSofort").parentNode.parentNode.style.visibility = vsbl;
  3178. for (var i = 0; true; i++)
  3179. if (document.getElementById("craft"+i))
  3180. document.getElementById("craft"+i).parentNode.parentNode.style.visibility = vsbl;
  3181. else
  3182. break;
  3183. }
  3184.  
  3185. function insertCheckBox5() {
  3186. var town = ["HH", "B", "MU", "HR", "K", "SY", "ML", "VT", "AT"];
  3187. if (town.indexOf(TOWNEXTENSION) == -1)
  3188. return;
  3189. var newtd = document.createElement("td");
  3190. var newtr = document.createElement("tr");
  3191. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  3192. newtd.innerHTML = '<input name="DTCheckbox" id="DTCheckbox" type="checkbox"><span style="vertical-align: bottom">&nbsp;Tagesaufgabe automatisch lösen</span><br><span id="dailytxt"></span>';
  3193. newtr.appendChild(newtd, newtr);
  3194. var tr = document.getElementsByTagName("table")[0].getElementsByTagName("tr")[2];
  3195. tr.parentNode.appendChild(newtr, tr);
  3196. var allplunderArr = [];
  3197. var allplunder = PG_getValue("allplunder", "");
  3198. if (allplunder == "") {
  3199. allplunder = [];
  3200. var plunderlist = [];
  3201. }
  3202. else {
  3203. allplunder = allplunder.replace("&auml;", "ä").replace("&ouml;", "ö").replace("&uuml;", "ü").replace("&szlig;", "ß");
  3204. var plunderlist = allplunder.replace(/:\d*/g, "").split(";");
  3205. allplunder = allplunder.split(";");
  3206. for (var i = allplunder.length - 1; i >= 0; i--)
  3207. if (allplunder.indexOf(allplunder[i]) < i || allplunder[i] == "Zertr&uuml" || allplunder[i] == "Zertrü" || allplunder[i].startsWith("mmerte"))
  3208. allplunder.splice(i, 1);
  3209. }
  3210. getPlunderlist(1, 0, allplunderArr, tr, (TOWNEXTENSION == "VT"||TOWNEXTENSION == "AT"?100:2500), allplunder, plunderlist, "");
  3211.  
  3212. var checked = PGu_getValue("autoDaily", false);
  3213. var dailytxt = "";
  3214. if (checked) {
  3215. var today = new Date();
  3216. var tagesdatum = FormatDate(today);
  3217. tryDaily = PGu_getValue("tryDailyTask", ";0").split(";");
  3218. if (tryDaily[0] != tagesdatum) {
  3219. var tries = 0;
  3220. PGu_delete("tryDailyTask");
  3221. }
  3222. else
  3223. var tries = Number(tryDaily[1]);
  3224. if (tryDaily[0] == tagesdatum && (tries >= 5 && today.getHours() < 23 || tries >= 10 && today.getHours() >= 23)) {
  3225. checked = false;
  3226. if (tries < 10)
  3227. dailytxt = "Aufgrund zuvieler Fehlversuche ist die Automatik bis 23 Uhr oder erneute Aktivierung abgeschaltet.";
  3228. else
  3229. dailytxt = "Aufgrund zuvieler Fehlversuche ist die Automatik für den Rest des Tages oder bis zur erneuten Aktivierung abgeschaltet.";
  3230. document.getElementById("dailytxt").innerHTML = dailytxt;
  3231. }
  3232. }
  3233.  
  3234. document.getElementById("DTCheckbox").checked = checked;
  3235. // Click-Handler hinzufügen
  3236. document.getElementById("DTCheckbox").addEventListener("click", function(event) {
  3237. // Klickstatus speichern
  3238. PGu_setValue("autoDaily", this.checked);
  3239. if (!this.checked) {
  3240. setVisibility("hidden");
  3241. }
  3242. else {
  3243. setVisibility("visible");
  3244. PGu_delete("dailyTaskDone");
  3245. PGu_delete("tryDailyTask");
  3246. }
  3247. }, false);
  3248. }
  3249.  
  3250. function insertCheckBox6(show) {
  3251. var noMissCtrl = (document.getElementById("content").innerHTML.indexOf('onclick="show_city_list') == -1);
  3252. if (!show || noMissCtrl && show != 1)
  3253. return;
  3254. var tables = document.getElementsByTagName("table");
  3255. var missions = [];
  3256. var boosts = [];
  3257. var plunder = [];
  3258. for (var i = 0; i < tables.length; i++) {
  3259. var mission = tables[i].getElementsByClassName("gang_mission")[0].style.backgroundImage.split(/[()]/)[1].split("/").pop().split(".")[0];
  3260. missions[i] = mission;
  3261. var tr = tables[i].getElementsByTagName("tr")[1];
  3262. var div = tr.getElementsByTagName("div");
  3263. if (!noMissCtrl) {
  3264. var newtd = document.createElement("td");
  3265. newtd.setAttribute('style', 'padding-top: 10px');
  3266. newtd.innerHTML = '<input name="MissCheckbox'+i+'" id="MissCheckbox'+i+'" type="checkbox"><span style="vertical-align: bottom">&nbsp;Diese Mission automatisch starten</span>';
  3267. div[div.length-1].appendChild(newtd, div);
  3268. document.getElementById("MissCheckbox"+i).checked = PGu_getValue(mission+"Auto", false);
  3269. // Click-Handler hinzufügen
  3270. document.getElementById("MissCheckbox"+i).addEventListener("click", function(event) {
  3271. // Klickstatus speichern
  3272. var indx = this.id.substr(-1);
  3273. PGu_setValue(missions[indx]+"Auto", this.checked);
  3274. }, false);
  3275. var newbr = document.createElement("br");
  3276. div[div.length-1].appendChild(newbr, div);
  3277. var newtd2 = document.createElement("td");
  3278. newtd2.innerHTML = '<input name="RewardChb'+i+'" id="RewardChb'+i+'" type="checkbox" style="vertical-align:bottom"><span style="vertical-align: bottom">&nbsp;Belohnung automatisch abholen</span>';
  3279. div[div.length-1].appendChild(newtd2, div);
  3280. document.getElementById("RewardChb"+i).checked = PGu_getValue(mission+"Rwd", false);
  3281. // Click-Handler hinzufügen
  3282. document.getElementById("RewardChb"+i).addEventListener("click", function(event) {
  3283. // Klickstatus speichern
  3284. var indx = this.id.substr(-1);
  3285. PGu_setValue(missions[indx]+"Rwd", this.checked);
  3286. }, false);
  3287. }
  3288. if (!noMissCtrl)
  3289. if (mission == "kieztour" || mission == "davinci_code" || mission == "schrottplatz" || mission == "kreuzzug") {
  3290. var newbr = document.createElement("br");
  3291. div[div.length-1].appendChild(newbr, div);
  3292. var newtd2 = document.createElement("td");
  3293. newtd2.innerHTML = '<input name="TimeCheckbox'+i+'" id="TimeCheckbox'+i+'" type="checkbox" style="vertical-align:bottom"><span style="vertical-align: bottom">&nbsp;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">&nbsp;Minuten bis zur nächsten Mission</span>';
  3294. div[div.length-1].appendChild(newtd2, div);
  3295. document.getElementById("MissTime"+i).value = PGu_getValue(mission+"Time", "");
  3296. document.getElementById("TimeCheckbox"+i).checked = PGu_getValue(missions[i]+"MissT", false);
  3297. // Click-Handler hinzufügen
  3298. document.getElementById("TimeCheckbox"+i).addEventListener("click", function(event) {
  3299. // Klickstatus speichern
  3300. var indx = this.id.substr(-1);
  3301. PGu_setValue(missions[indx]+"MissT", this.checked);
  3302. }, false);
  3303. // Change-Handler hinzufügen
  3304. document.getElementById("MissTime"+i).addEventListener("change", function(event) {
  3305. // aktuellen Wert speichern
  3306. if (this.value != "" && (isNaN(this.value) || Number(this.value) < 0))
  3307. alert ("Bitte nur eine Zahl >= 0 eingeben oder frei lassen");
  3308. else {
  3309. var indx = this.id.substr(-1);
  3310. PGu_setValue(missions[indx]+"Time", this.value);
  3311. }
  3312. }, false);
  3313. }
  3314. var lis = tables[i].getElementsByClassName("stage_area")[0].getElementsByTagName("li");
  3315. plunder[i] = [];
  3316. var first = noMissCtrl;
  3317. for (var j = 0; j < lis.length; j++) {
  3318. if (lis[j].innerHTML.indexOf('">x ') == -1)
  3319. continue;
  3320. var plnd = lis[j].innerHTML.split("<span>")[1].split("</span>")[0].trim();
  3321. var amnt = Number(lis[j].innerHTML.split(">x ")[1].match(/\d+/)[0].trim());
  3322. plunder[i].push([plnd, amnt]);
  3323. if (amnt >= 1000 || !noMissCtrl) {
  3324. if (!first) {
  3325. var newbr = document.createElement("br");
  3326. div[div.length-1].appendChild(newbr, div);
  3327. }
  3328. var newtd = document.createElement("td");
  3329. newtd.innerHTML = '<input name="'+plnd+'payin'+i+'" id="'+plnd+'payin'+i+'" type="checkbox"><span style="vertical-align: bottom">&nbsp;'+plnd+' bei Bedarf in Plunderbank einzahlen'+'</span>';
  3330. div[div.length-1].appendChild(newtd, div);
  3331. PGu_setValue(plnd+"PayIn", PGu_getValue(plnd+"PayIn", false));
  3332. document.getElementById(plnd+"payin"+i).checked = PGu_getValue(plnd+"PayIn", false);
  3333. // Click-Handler hinzufügen
  3334. document.getElementById(plnd+"payin"+i).addEventListener("click", function(event) {
  3335. // Klickstatus speichern
  3336. var plnd = this.id.split("payin")[0];
  3337. PGu_setValue(plnd+"PayIn", this.checked);
  3338. }, false);
  3339. first = false;
  3340. if (amnt >= 1000 && !noMissCtrl) {
  3341. var newbr = document.createElement("br");
  3342. div[div.length-1].appendChild(newbr, div);
  3343. var newtd = document.createElement("td");
  3344. newtd.innerHTML = '<input name="'+plnd+'Smml'+i+'" id="'+plnd+'Smml'+i+'" type="checkbox"><span style="vertical-align: bottom">&nbsp;'+plnd+' nach Missionsstart wieder sammeln</span>';
  3345. div[div.length-1].appendChild(newtd, div);
  3346. PGu_setValue(plnd+"Coll", PGu_getValue(plnd+"Coll", false));
  3347. document.getElementById(plnd+"Smml"+i).checked = PGu_getValue(plnd+"Coll", false);
  3348. // Click-Handler hinzufügen
  3349. document.getElementById(plnd+"Smml"+i).addEventListener("click", function(event) {
  3350. // Klickstatus speichern
  3351. var plnd = this.id.split("Smml")[0];
  3352. PGu_setValue(plnd+"Coll", this.checked);
  3353. }, false);
  3354. }
  3355. }
  3356. }
  3357. if (noMissCtrl)
  3358. continue;
  3359. var divs = tables[i].getElementsByClassName("stage_area")[2].getElementsByClassName("icon_display");
  3360. var boost = divs[divs.length-1].innerHTML.split('src="')[1].split("/").pop().split(".")[0];
  3361. boosts[i] = boost;
  3362. if (boost.startsWith("boost")) {
  3363. var newbr = document.createElement("br");
  3364. div[div.length-1].appendChild(newbr, div);
  3365. var newtd = document.createElement("td");
  3366. newtd.innerHTML = '<input name="MissAbhol'+i+'" id="MissAbhol'+i+'" type="checkbox"><span style="vertical-align: bottom">&nbsp;diesen Boost überschreiben</span>';
  3367. div[div.length-1].appendChild(newtd, div);
  3368. document.getElementById("MissAbhol"+i).checked = PGu_getValue(boost+"Over", false);
  3369. // Click-Handler hinzufügen
  3370. document.getElementById("MissAbhol"+i).addEventListener("click", function(event) {
  3371. // Klickstatus speichern
  3372. var indx = this.id.substr(-1);
  3373. PGu_setValue(boosts[indx]+"Over", this.checked);
  3374. }, false);
  3375. var newbr2 = document.createElement("br");
  3376. div[div.length-1].appendChild(newbr2, div);
  3377. var newtd2 = document.createElement("td");
  3378. newtd2.innerHTML = '<input name="BoostStart'+i+'" id="BoostStart'+i+'" type="checkbox"><span style="vertical-align: bottom">&nbsp;diesen Boost sofort starten</span>';
  3379. div[div.length-1].appendChild(newtd2, div);
  3380. document.getElementById("BoostStart"+i).checked = PGu_getValue(boost+"Start", false);
  3381. // Click-Handler hinzufügen
  3382. document.getElementById("BoostStart"+i).addEventListener("click", function(event) {
  3383. // Klickstatus speichern
  3384. var indx = this.id.substr(-1);
  3385. PGu_setValue(boosts[indx]+"Start", this.checked);
  3386. }, false);
  3387. }
  3388. if (mission == "schrottplatz" || mission == "kreuzzug") {
  3389. var newbr = document.createElement("br");
  3390. div[div.length-1].appendChild(newbr, div);
  3391. var newtd = document.createElement("td");
  3392. newtd.innerHTML = '<input name="trashAll" id="trashAll" type="checkbox"><span style="vertical-align: bottom">&nbsp;Missionsplunder unter 60 auch verschrotten</span>';
  3393. div[div.length-1].appendChild(newtd, div);
  3394. document.getElementById("trashAll").checked = PGu_getValue("trashAllMissPlund", false);
  3395. // Click-Handler hinzufügen
  3396. document.getElementById("trashAll").addEventListener("click", function(event) {
  3397. // Klickstatus speichern
  3398. PGu_setValue("trashAllMissPlund", this.checked);
  3399. }, false);
  3400. for (var j = 0; j < plunder.length; j++) {
  3401. for (var k = 0; k < plunder[j].length; k++) {
  3402. if (plunder[j][k][1] >= 1000)
  3403. continue;
  3404. var newbr = document.createElement("br");
  3405. div[div.length-1].appendChild(newbr, div);
  3406. var newtd = document.createElement("td");
  3407. newtd.innerHTML = '<input name="Schr'+plunder[j][k][0]+'" id="Schr'+plunder[j][k][0]+'" type="checkbox"><span style="vertical-align: bottom">&nbsp;' + plunder[j][k][0] + ' kann verschrottet werden</span>';
  3408. div[div.length-1].appendChild(newtd, div);
  3409. document.getElementById("Schr"+plunder[j][k][0]).checked = PGu_getValue(plunder[j][k][0]+"Schrott", false);
  3410. // Click-Handler hinzufügen
  3411. document.getElementById("Schr"+plunder[j][k][0]).addEventListener("click", function(event) {
  3412. // Klickstatus speichern
  3413. PGu_setValue(this.id.substr(4)+"Schrott", this.checked);
  3414. }, false);
  3415. }
  3416. }
  3417. }
  3418. }
  3419. }
  3420.  
  3421. function insertCheckBox7() {
  3422. function chkBox(id, varname, def) {
  3423. document.getElementById(id).checked = PGu_getValue(varname, def);
  3424. // Click-Handler hinzufügen
  3425. document.getElementById(id).addEventListener("click", function(event) {
  3426. // Klickstatus speichern
  3427. PGu_setValue(varname, this.checked);
  3428. }, false);
  3429. }
  3430. function chkValue(id, varname, def) {
  3431. document.getElementById(id).value = PGu_getValue(varname, def);
  3432. document.getElementById(id).addEventListener("change", function(event) {
  3433. // aktuellen Wert speichern
  3434. if (this.value != "" && (isNaN(this.value) || Number(this.value) < 0))
  3435. alert ("Bitte nur eine Zahl >= 0 eingeben oder frei lassen");
  3436. else {
  3437. PGu_setValue(varname, Number(this.value));
  3438. }
  3439. }, false);
  3440. }
  3441. var town = ["HH", "B", "MU", "HR", "K", "SY", "ML", "VT", "AT"];
  3442. if (town.indexOf(TOWNEXTENSION) == -1)
  3443. return;
  3444. var newtd = document.createElement("td");
  3445. var newtr = document.createElement("tr");
  3446. newtd.setAttribute('colspan', '2');
  3447. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  3448. newtd.innerHTML = '<input name="moneyover" id="moneyover" type="checkbox" style="vertical-align:bottom"><span style="vertical-align: bottom">&nbsp;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">&nbsp;folgenden Betrag einzahlen: </span><input name="payIn" id="payIn" type="text" style="width:60px;color:black;background-color:white" value="">';
  3449. newtd.innerHTML += '<br><input name="minmoneychb" id="minmoneychb" type="checkbox" style="vertical-align:bottom"><span style="vertical-align: bottom">&nbsp;Mindestgeldbetrag: </span><input name="minMoney" id="minMoney" type="text" style="width:60px;color:black;background-color:white" value="">';
  3450. newtr.setAttribute('align', 'left');
  3451. newtr.setAttribute('valign', 'top');
  3452. newtr.appendChild(newtd, newtr);
  3453. var trs = document.getElementsByTagName("table")[0].getElementsByTagName("tr");
  3454. for (var i = 0; i < trs.length; i++)
  3455. if (trs[i].innerHTML.indexOf("f_comment") != -1)
  3456. break;
  3457. for ( ; i < trs.length; i++)
  3458. if (trs[i].innerHTML.indexOf("<hr") != -1)
  3459. break;
  3460. if (i >= trs.length)
  3461. trs[0].parentNode.appendChild(newtr);
  3462. else
  3463. trs[0].parentNode.insertBefore(newtr, trs[i]);
  3464. chkBox("moneyover", "moneyOver", false);
  3465. chkValue("moreThan", "maxMoney", 0);
  3466. chkValue("payIn", "maxMoneyPayIn", 0);
  3467. chkBox("minmoneychb", "minmoneychb", false);
  3468. chkValue("minMoney", "minMoney", 0);
  3469. }
  3470.  
  3471. function insertCheckBox8() {
  3472. var trs = document.getElementsByClassName("item_list")[0].getElementsByTagName("tr");
  3473. var trnr = (TOWNEXTENSION == "VT"||TOWNEXTENSION == "AT"?3:1);
  3474. var tr1 = trs[trnr].cloneNode(true);
  3475. var tr2 = trs[trnr].cloneNode(true);
  3476. var inp1 = document.createElement("input");
  3477. inp1.id = "minmoney";
  3478. inp1.type = "text";
  3479. inp1.value = PGu_getValue("minMoney", 0);
  3480. inp1.size = "9";
  3481. var inp3 = document.createElement("input");
  3482. inp3.type = "button";
  3483. inp3.value = "übernehmen";
  3484. inp3.addEventListener("click", function(event) {
  3485. // aktuellen Wert speichern
  3486. var val = document.getElementById("minmoney").value;
  3487. if (val != "" && (isNaN(val) || Number(val) < 0))
  3488. alert ("Bitte nur eine Zahl >= 0 eingeben oder frei lassen");
  3489. else {
  3490. PGu_setValue("minMoney", Number(val));
  3491. }
  3492. }, false);
  3493. if (TOWNEXTENSION == "VT" || TOWNEXTENSION == "AT") {
  3494. tr1.getElementsByTagName("td")[0].innerHTML = 'Mindestgeldbetrag:';
  3495. tr1.getElementsByTagName("td")[1].appendChild(inp1, tr1.getElementsByTagName("td")[1]);
  3496. tr1.getElementsByTagName("td")[1].appendChild(inp3, tr1.getElementsByTagName("td")[1]);
  3497. }
  3498. else {
  3499. tr1.getElementsByTagName("td")[1].innerHTML = 'Mindestgeldbetrag:';
  3500. tr1.getElementsByTagName("span")[0].parentNode.removeChild(tr1.getElementsByTagName("span")[0]);
  3501. tr1.getElementsByTagName("td")[2].appendChild(inp1, tr1.getElementsByTagName("td")[1]);
  3502. tr1.getElementsByTagName("td")[2].appendChild(inp3, tr1.getElementsByTagName("td")[1]);
  3503. }
  3504. trs[trnr].parentNode.appendChild(tr1, trs[trnr]);
  3505. var inp2 = document.createElement("input");
  3506. inp2.id = "minprice";
  3507. inp2.type = "text";
  3508. inp2.value = "0," + ("0" + PGu_getValue("bottleprice", 0)).substr(-2);
  3509. inp2.size = "5";
  3510. var inp4 = document.createElement("input");
  3511. inp4.type = "button";
  3512. inp4.value = "übernehmen";
  3513. inp4.addEventListener("click", function(event) {
  3514. if (!document.getElementById("minprice").value.startsWith("0,"))
  3515. alert ("Wert unzulässig!");
  3516. else
  3517. PGu_setValue("bottleprice", Number(document.getElementById("minprice").value.substr(2)));
  3518. }, false);
  3519. if (TOWNEXTENSION == "VT" || TOWNEXTENSION == "AT") {
  3520. tr2.getElementsByTagName("td")[0].innerHTML = 'Mindestverkaufspreis ' + flaschentxt + ':';
  3521. tr2.getElementsByTagName("td")[1].appendChild(inp2, tr2.getElementsByTagName("td")[1]);
  3522. tr2.getElementsByTagName("td")[1].appendChild(inp4, tr2.getElementsByTagName("td")[1]);
  3523. }
  3524. else {
  3525. tr2.getElementsByTagName("td")[1].innerHTML = 'Mindestverkaufspreis Flaschen:';
  3526. tr2.getElementsByTagName("span")[0].parentNode.removeChild(tr2.getElementsByTagName("span")[0]);
  3527. tr2.getElementsByTagName("td")[2].appendChild(inp2, tr2.getElementsByTagName("td")[2]);
  3528. tr2.getElementsByTagName("td")[2].appendChild(inp4, tr2.getElementsByTagName("td")[2]);
  3529. }
  3530. trs[trnr].parentNode.appendChild(tr2, trs[trnr+1]);
  3531. if (TOWNEXTENSION == "VT" || TOWNEXTENSION == "AT") {
  3532. var tr3 = trs[trnr].cloneNode(true);
  3533. var inp6 = document.createElement("input");
  3534. inp6.id = "maxfill";
  3535. inp6.type = "text";
  3536. inp6.value = PGu_getValue("maxfillbottle", 90);
  3537. inp6.size = "5";
  3538. var inp8 = document.createElement("input");
  3539. inp8.type = "button";
  3540. inp8.value = "übernehmen";
  3541. inp8.addEventListener("click", function(event) {
  3542. if (isNaN(document.getElementById("maxfill").value) ||
  3543. Number(document.getElementById("maxfill").value) < 1 ||
  3544. Number(document.getElementById("maxfill").value) > 100)
  3545. alert ("Wert unzulässig!");
  3546. else
  3547. PGu_setValue("maxfillbottle", Number(document.getElementById("maxfill").value));
  3548. }, false);
  3549. tr3.getElementsByTagName("td")[0].innerHTML = 'Maximaler ' + flaschentxt + 'füllgrad:';
  3550. tr3.getElementsByTagName("td")[1].appendChild(inp6, tr3.getElementsByTagName("td")[1]);
  3551. tr3.getElementsByTagName("td")[1].appendChild(inp8, tr3.getElementsByTagName("td")[1]);
  3552. trs[trnr].parentNode.appendChild(tr3, trs[trnr+1]);
  3553. }
  3554. }
  3555.  
  3556. function insertCheckBox9() {
  3557. function makeSelection (allplunder, option, div, pos, upgr) {
  3558. function getPlunderSpez (plist, val) {
  3559. if (val != 0)
  3560. for (var i = 0; i < plist.length; i++)
  3561. if (plist[i][2] == val)
  3562. return val + ";" + plist[i][0];
  3563. return "0;";
  3564. }
  3565. function makeBox(actInact) {
  3566. var val = (PGu_getValue(actInact+"ivePlunder", 0) + ";").split(";")[0];
  3567. document.getElementById("pid" + actInact).value = val;
  3568. // Click-Handler hinzufügen
  3569. document.getElementById("pid" + actInact).addEventListener("change", function(event) {
  3570. // neuen Wert speichern
  3571. PGu_setValue(actInact+"ivePlunder", getPlunderSpez(allplunder, this.value));
  3572. }, false);
  3573. return;
  3574. }
  3575. var text = '<form name="' + upgr + 'Plunder" style="padding-top:12px" 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>';
  3576. div.innerHTML = div.innerHTML.substr(0, pos) + text + div.innerHTML.substr(pos);
  3577. div.style.height = (parseInt(div.style.height) + 60) + "px";
  3578. makeBox(upgr + "Act");
  3579. makeBox(upgr + "Inact");
  3580. return;
  3581. }
  3582. var town = ["HH", "B", "MU", "HR", "K", "SY", "ML", "VT", "AT"];
  3583. if (town.indexOf(TOWNEXTENSION) == -1)
  3584. return;
  3585. var tr = document.getElementsByTagName("table")[0].getElementsByTagName("tr")[2];
  3586.  
  3587. var allplunder = [];
  3588. trace('Get ' + prothost + '/stock/plunder/ajax/?c=1', 2);
  3589. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/plunder/ajax/?c=1', onload:function(responseDetails) {
  3590. var content = responseDetails.responseText;
  3591. var trs = content.split("<tr ");
  3592. for (var i = 1; i < trs.length; i++) {
  3593. var plname = trs[i].split(">x ")[0].split("</strong")[0].split(">").pop().trim();
  3594. var plAnz = trs[i].split(">x ")[1].split("<")[0].trim();
  3595. var pid = trs[i].split('pm_')[1].split("'")[0].trim();
  3596. for (var j = 0; j < allplunder.length; j++)
  3597. if (allplunder[j][0] >= plname)
  3598. break;
  3599. allplunder.splice(j, 0, [plname, plAnz, pid]);
  3600. }
  3601. var divs = tr.getElementsByTagName("div");
  3602. var div = divs[divs.length-1];
  3603. var pos = div.innerHTML.indexOf("<br clear");
  3604. if (pos <= 0)
  3605. return;
  3606. var option = '<option value="-1">letzte Auswahl ungültig</option> <option value="0"> </option> ';
  3607. for (var i = 0; i < allplunder.length; i++)
  3608. option += '<option value="' + allplunder[i][2] + '">' + allplunder[i][0] + '</option> ';
  3609. makeSelection (allplunder, option, div, pos, "WiWu");
  3610. div = divs[divs.length-2];
  3611. pos = div.innerHTML.indexOf("<br clear");
  3612. if (pos <= 0)
  3613. return;
  3614. makeSelection (allplunder, option, div, pos, "Wut");
  3615. }});
  3616. }
  3617.  
  3618. function insertCheckBox10() {
  3619. var town = ["HH", "B", "MU", "HR", "K", "SY", "ML", "VT", "AT"];
  3620. if (town.indexOf(TOWNEXTENSION) == -1)
  3621. return;
  3622.  
  3623. var today = new Date();
  3624. var tagesdatum = FormatDate(today);
  3625. var div = document.getElementsByClassName("pet_tab_help")[0];
  3626. if (document.getElementById("content").innerHTML.indexOf("javascript:display_show('memory'") != -1) {
  3627. var newtd = document.createElement("td");
  3628. newtd.setAttribute('style', 'padding-top: 10px');
  3629. newtd.innerHTML = '<input name="memoryChb" id="memoryChb" type="checkbox"><span style="vertical-align: bottom">&nbsp;Memory automatisch spielen</span>';
  3630. div.appendChild(newtd, div);
  3631.  
  3632. document.getElementById("memoryChb").checked = PGu_getValue("memoryauto", false);
  3633. // Click-Handler hinzufügen
  3634. document.getElementById("memoryChb").addEventListener("click", function(event) {
  3635. // Klickstatus speichern
  3636. PGu_setValue("memoryauto", this.checked);
  3637. if (this.checked) {
  3638. PGu_setValue("memorydate", "");
  3639. PGu_setValue("dispshow_date", 0);
  3640. if (PGu_getValue("gamechkr_date", "xx") == tagesdatum)
  3641. PGu_setValue("gamechkr_date", "xx");
  3642. }
  3643. }, false);
  3644. }
  3645. else
  3646. PGu_delete("memoryauto");
  3647.  
  3648. if (document.getElementById("content").innerHTML.indexOf('javascript:display_show("icecube"') != -1) {
  3649. var newtd = document.createElement("td");
  3650. newtd.setAttribute('style', 'padding-top: 10px');
  3651. newtd.innerHTML = '<input name="icecubeChb" id="icecubeChb" type="checkbox"><span style="vertical-align: bottom">&nbsp;Eiswürfelspiel automatisch spielen</span>';
  3652. div.appendChild(newtd, div);
  3653.  
  3654. document.getElementById("icecubeChb").checked = PGu_getValue("icecubeauto", false);
  3655. // Click-Handler hinzufügen
  3656. document.getElementById("icecubeChb").addEventListener("click", function(event) {
  3657. // Klickstatus speichern
  3658. PGu_setValue("icecubeauto", this.checked);
  3659. if (this.checked) {
  3660. PGu_setValue("icecubedate", "");
  3661. PGu_setValue("dispshow_date", 0);
  3662. if (PGu_getValue("gamechkr_date", "xx") == tagesdatum)
  3663. PGu_setValue("gamechkr_date", "xx");
  3664. }
  3665. }, false);
  3666.  
  3667. for (var i = 1; i <= 6; i++) {
  3668. var newtd = document.createElement("td");
  3669. newtd.setAttribute('style', 'padding-top: 10px');
  3670. newtd.innerHTML = '&nbsp;&nbsp;&nbsp;<input name="icecubeChb'+i+'" id="icecubeChb'+i+'" type="checkbox"><span style="vertical-align: bottom">&nbsp;'+i+(i==6?' automatisch behalten':'')+'</span>';
  3671. div.appendChild(newtd, div);
  3672. document.getElementById("icecubeChb"+i).checked = PGu_getValue("icecubekeep"+i, i==6);
  3673. // Click-Handler hinzufügen
  3674. document.getElementById("icecubeChb"+i).addEventListener("click", function(event) {
  3675. // Klickstatus speichern
  3676. PGu_setValue("icecubekeep"+this.id.substr(-1), this.checked);
  3677. }, false);
  3678. }
  3679.  
  3680. var newbr = document.createElement("br");
  3681. div.appendChild(newbr, div);
  3682. }
  3683. else
  3684. PGu_delete("icecubeauto");
  3685.  
  3686. if (document.getElementById("content").innerHTML.indexOf('href="/livegame/bb/"') != -1) {
  3687. var newtd2 = document.createElement("td");
  3688. newtd2.innerHTML = '<input name="FruitChb" id="FruitChb" type="checkbox"><span style="vertical-align: bottom">&nbsp;Freche Früchtchen automatisch spielen&nbsp;&nbsp;</span><input name="FruitKKChb" id="FruitKKChb" type="checkbox"><span style="vertical-align: bottom">&nbsp;angefangene Treffer mit Kronkorken beenden</span>';
  3689. div.appendChild(newtd2, div);
  3690.  
  3691. document.getElementById("FruitChb").checked = PGu_getValue("livegameauto", false);
  3692. // Click-Handler hinzufügen
  3693. document.getElementById("FruitChb").addEventListener("click", function(event) {
  3694. // Klickstatus speichern
  3695. PGu_setValue("livegameauto", this.checked);
  3696. }, false);
  3697.  
  3698. document.getElementById("FruitKKChb").checked = PGu_getValue("livegameKK", false);
  3699. // Click-Handler hinzufügen
  3700. document.getElementById("FruitKKChb").addEventListener("click", function(event) {
  3701. // Klickstatus speichern
  3702. PGu_setValue("livegameKK", this.checked);
  3703. if (this.checked)
  3704. PGu_delete("livegame_date");
  3705. }, false);
  3706.  
  3707. var newbr2 = document.createElement("br");
  3708. div.appendChild(newbr2, div);
  3709. }
  3710. else
  3711. PGu_delete("livegameauto");
  3712.  
  3713. if (document.getElementById("content").innerHTML.indexOf("javascript:display_show('cocktail'") != -1) {
  3714. var newtd3 = document.createElement("td");
  3715. //newtd3.innerHTML = '<input name="CocktailChb" id="CocktailChb" type="checkbox"><span style="vertical-align: bottom">&nbsp;Cocktails automatisch mixen</span>';
  3716. newtd3.innerHTML = '<input name="CocktailChb" id="CocktailChb" type="checkbox"><span style="vertical-align: bottom">&nbsp;Kekse automatisch backen</span>';
  3717. div.appendChild(newtd3, div);
  3718.  
  3719. document.getElementById("CocktailChb").checked = PGu_getValue("cocktailauto", false);
  3720. // Click-Handler hinzufügen
  3721. document.getElementById("CocktailChb").addEventListener("click", function(event) {
  3722. // Klickstatus speichern
  3723. PGu_setValue("cocktailauto", this.checked);
  3724. if (this.checked) {
  3725. PGu_setValue("cocktaildate", "");
  3726. PGu_setValue("dispshow_date", 0);
  3727. }
  3728. }, false);
  3729. }
  3730. else
  3731. PGu_delete("cocktailauto");
  3732. }
  3733.  
  3734. function insertCheckBox11() {
  3735. var town = ["HH", "B", "MU", "HR", "K", "SY", "ML", "VT", "AT"];
  3736. if (town.indexOf(TOWNEXTENSION) == -1)
  3737. return;
  3738.  
  3739. var div = document.getElementsByClassName("counters")[0];
  3740. var newspan = document.createElement("span");
  3741. newspan.innerHTML = '<input type="submit" value="gefundener Plunder" style="font-size:18px; background-color:darkgreen; position:relative; top:-37px" id="junkfound">';
  3742. div.insertBefore(newspan, div.firstChild);
  3743. var center = div.getElementsByTagName("center");
  3744. for (i = 0; i < center.length; i++)
  3745. center[i].style.top = (33 + i*29 - Math.floor(i/2)) + "px";
  3746.  
  3747. // Click-Handler hinzufügen
  3748. document.getElementById("junkfound").addEventListener("click", function(event) {
  3749. var junk = PGu_getValue("junkfound", "");
  3750. if (junk == "")
  3751. junk = "Nichts gefunden:";
  3752. else {
  3753. junkArr = junk.split(";");
  3754. junk = "Gefunden:\n\n";
  3755. for (var i = 0; i < junkArr.length; i++) {
  3756. if (junkArr[i] != "") {
  3757. var arr = junkArr[i].split(":");
  3758. for (var j = 1; j < arr.length; j++) {
  3759. if (arr[j].match(/^\d/))
  3760. break;
  3761. else {
  3762. arr.splice(j-1, 2, arr[j-1] + ":" + arr[j]);
  3763. j--;
  3764. }
  3765. }
  3766. junk += arr.pop() + " x " + arr[0];
  3767. if (arr.length > 1) {
  3768. arr.splice(0, 1);
  3769. junk += " (" + arr.join(" + ") + ")";
  3770. }
  3771. junk += "\n";
  3772. }
  3773. else
  3774. junk += "---------------------------\n";
  3775. }
  3776. }
  3777. alert(junk);
  3778. }, false);
  3779. }
  3780.  
  3781. var ghostPages = ['activities/crime', 'activities', 'city/medicine', 'city/stuff', 'city/supermarket',
  3782. 'skills', 'stock/bottle', 'messages', 'itemsale', 'stock'];
  3783. function insertCheckBox12(obj) {
  3784. var town = ["HH", "B", "MU", "HR", "K", "SY", "ML", "VT", "AT"];
  3785. if (town.indexOf(TOWNEXTENSION) == -1)
  3786. return;
  3787.  
  3788. var PageNames = ['Verbrechen', 'Aktionen', 'Apotheke', 'Zubehör', 'Supermarkt',
  3789. 'Weiterbildung', pflaschen, 'Kommunikation', 'Kronkorken', 'Inventar'];
  3790. var today = new Date();
  3791. var tagesdatum = FormatDate(today);
  3792. while (PGu_getValue("ghostsfound", "") != "" || PGu_getValue("blackjackcards", "") != ""){
  3793. var div = document.getElementById("1");
  3794. if (!div)
  3795. break;
  3796. var newspan = document.createElement("span");
  3797. if (PGu_getValue("ghostsfound", "") != "")
  3798. newspan.innerHTML += '<input type="submit" value="gefundene ' + obj + '" style="font-size:18px; background-color:darkgreen; position:relative; top:170px" id="ghostsfound">';
  3799. if (PGu_getValue("blackjackcards", "") != "")
  3800. newspan.innerHTML += '<input type="submit" value="gewonnene ' + obj + '" style="font-size:18px; background-color:darkgreen; position:relative; top:170px" id="blackjackwins">';
  3801. div.insertBefore(newspan, div.firstChild);
  3802.  
  3803. // Click-Handler hinzufügen
  3804. if (PGu_getValue("ghostsfound", "") != "")
  3805. document.getElementById("ghostsfound").addEventListener("click", function(event) {
  3806. var ghosts = PGu_getValue("ghostsfound", "");
  3807. if (ghosts == "")
  3808. ghosts = "Nichts gefunden:";
  3809. else {
  3810. ghostsArr = ghosts.split(";");
  3811. ghosts = "Gefunden:\n\n";
  3812. for (var i = 0; i < ghostsArr.length; i++) {
  3813. var arr = ghostsArr[i].split(":");
  3814. ghosts += obj + " am " + arr[0].substr(8,2) + "." + arr[0].substr(5,2) + "." + arr[0].substr(0,4) + ": ";
  3815. for (var j = 1; j < arr.length; j++)
  3816. ghosts += arr[j] + " x " + (isNaN(arr[j+1])?arr[j+1]:PageNames[arr[j+1]]) + (++j < arr.length-1?", ":"\n");
  3817. }
  3818. }
  3819. alert(ghosts);
  3820. }, false);
  3821. if (PGu_getValue("blackjackcards", "") != "")
  3822. document.getElementById("blackjackwins").addEventListener("click", function(event) {
  3823. var cardstat = PGu_getValue("blackjackcards", "");
  3824. if (cardstat == "")
  3825. cardstat = "Nichts gefunden:";
  3826. else {
  3827. cardsArr = cardstat.split(";");
  3828. cards = "Gewonnen:\n\n";
  3829. for (var i = 0; i < cardsArr.length; i++) {
  3830. var arr = cardsArr[i].split("+");
  3831. cards += "Karten am " + arr[0].substr(8,2) + "." + arr[0].substr(5,2) + "." + arr[0].substr(0,4) + ": ";
  3832. for (var j = 1; j < arr.length; j++) {
  3833. cArr = arr[j].split(":");
  3834. var sum = 0;
  3835. if (j > 1)
  3836. cards += "; ";
  3837. for (var k = 0; k < cArr.length; k++) {
  3838. cards += cArr[k] + " ";
  3839. if (cArr[k] == "A")
  3840. sum += 11;
  3841. else if (isNaN(cArr[k]))
  3842. sum += 10;
  3843. else
  3844. sum += Number(cArr[k]);
  3845. }
  3846. cards += "(" + sum + (sum <= 21?"":" --> 1") + ")";
  3847. }
  3848. cards += "\n";
  3849. }
  3850. }
  3851. alert(cards);
  3852. }, false);
  3853. break;
  3854. }
  3855.  
  3856. var div = document.getElementsByClassName("pet_tab_help")[0];
  3857. if (document.getElementById("content").innerHTML.indexOf("javascript:display_show('countdowngame'") != -1) {
  3858. var newtd = document.createElement("td");
  3859. newtd.setAttribute('style', 'padding-top: 10px');
  3860. newtd.innerHTML = '<input name="hendlChb" id="hendlChb" type="checkbox"><span style="vertical-align: bottom">&nbsp;Hendl automatisch grillen</span>';
  3861. div.appendChild(newtd, div);
  3862.  
  3863. document.getElementById("hendlChb").checked = PGu_getValue("countdowngameauto", false);
  3864. // Click-Handler hinzufügen
  3865. document.getElementById("hendlChb").addEventListener("click", function(event) {
  3866. // Klickstatus speichern
  3867. PGu_setValue("countdowngameauto", this.checked);
  3868. if (this.checked) {
  3869. PGu_setValue("countdowngamedate", "");
  3870. PGu_setValue("dispshow_date", 0);
  3871. if (PGu_getValue("gamechkr_date", "xx") == tagesdatum)
  3872. PGu_setValue("gamechkr_date", "xx");
  3873. }
  3874. }, false);
  3875. }
  3876. else
  3877. PGu_delete("countdowngameauto");
  3878.  
  3879. if (document.getElementById("content").innerHTML.indexOf("javascript:blackjack(") != -1) {
  3880. var newbr = document.createElement("br");
  3881. div.appendChild(newbr, div);
  3882. var newtd2 = document.createElement("td");
  3883. newtd2.innerHTML = '<input name="BlackjackChb" id="BlackjackChb" type="checkbox" style="vertical-align:bottom"><span style="vertical-align: bottom">&nbsp;Brezngaudi automatisch spielen: Karte bis höchstens </span><input name="Blackjacklimit" id="Blackjacklimit" type="text" style="width:25px;color:black;background-color:white" value=""><span style="vertical-align: bottom">&nbsp;ziehen</span>';
  3884. div.appendChild(newtd2, div);
  3885. document.getElementById("BlackjackChb").checked = PGu_getValue("blackjackauto", false);
  3886. document.getElementById("Blackjacklimit").value = PGu_getValue("blackjacklimit", 13);
  3887. // Click-Handler hinzufügen
  3888. document.getElementById("BlackjackChb").addEventListener("click", function(event) {
  3889. // Klickstatus speichern
  3890. PGu_setValue("blackjackauto", this.checked);
  3891. PGu_setValue("blackjack_date", "");
  3892. if (PGu_getValue("gamechkr_date", "xx") == tagesdatum)
  3893. PGu_setValue("gamechkr_date", "xx");
  3894. }, false);
  3895. // Change-Handler hinzufügen
  3896. document.getElementById("Blackjacklimit").addEventListener("change", function(event) {
  3897. // aktuellen Wert speichern
  3898. if (isNaN(this.value) || Number(this.value) < 2 || Number(this.value) > 21)
  3899. alert ("Bitte nur eine Zahl zwischen 2 und 21 eingeben");
  3900. else {
  3901. PGu_setValue("blackjacklimit", Number(this.value));
  3902. }
  3903. }, false);
  3904. }
  3905. else
  3906. PGu_delete("blackjackauto");
  3907. }
  3908.  
  3909. function buildSelectBox(i, allplunderArr, usedPlunder, tr) {
  3910. function handleClick(id, value) {
  3911. // neuen Wert speichern
  3912. var boxnr = id.replace("shopid", "");
  3913. if (value == "-1")
  3914. usedPlunder.splice(boxnr, 1);
  3915. else if (value == "0") {
  3916. if (usedPlunder[0] != "0")
  3917. usedPlunder.splice(0, 0, "0");
  3918. }
  3919. else if (usedPlunder.indexOf(value) != -1)
  3920. usedPlunder.splice(boxnr, 1);
  3921. else
  3922. usedPlunder[boxnr] = value;
  3923. PGu_setValue("alwaysbuy", usedPlunder.join(";"));
  3924. for (var i = 0; i < usedPlunder.length || document.getElementById("shopid"+i); i++) {
  3925. if (i >= usedPlunder.length || usedPlunder[0] == "0" && i > 0) {
  3926. if (document.getElementById("shopid"+i))
  3927. document.getElementById("shopid"+i).parentNode.parentNode.style.visibility = "hidden";
  3928. continue;
  3929. }
  3930. buildSelectBox(i, allplunderArr, usedPlunder, tr);
  3931. }
  3932. if (i >= allplunderArr.length - 1 || usedPlunder[0] == "0")
  3933. return;
  3934. buildSelectBox(usedPlunder.length, allplunderArr, usedPlunder, tr);
  3935. }
  3936. if (i >= allplunderArr.length - 1 || usedPlunder[0] == "0" && i > 0)
  3937. return;
  3938. var option = '<option value="-1"> </option><option value="0">alles kaufen</option> ';
  3939. for (var j = 0; j < allplunderArr.length; j++) {
  3940. var pos = usedPlunder.indexOf(allplunderArr[j][1]);
  3941. if (pos == -1 || pos == i || usedPlunder[0] == "0")
  3942. option += '<option value="' + allplunderArr[j][1] + '">' + allplunderArr[j][0] + ' (' + allplunderArr[j][2].split("*")[1] + ')</option> ';
  3943. }
  3944. var newtd = document.getElementById("shopid"+i);
  3945. if (newtd) {
  3946. newtd.parentNode.parentNode.style.visibility = "visible";
  3947. newtd.innerHTML = option;
  3948. }
  3949. else {
  3950. newtd = document.createElement("td");
  3951. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  3952. newtd.innerHTML = '<form name="shop' + i + '" id="shop' + i + '">' + (i==0?"Plunder immer kaufen":"und außerdem") + ': <select id="shopid' + i +'" name="shopid' + i + '"> ' + option + ' </select> </form>';
  3953. var newdiv = document.createElement("div");
  3954. newdiv.appendChild(newtd, newdiv);
  3955. tr.parentNode.appendChild(newdiv, tr);
  3956. newtd = document.getElementById("shopid"+i);
  3957. // Click-Handler hinzufügen
  3958. newtd.addEventListener("change", function(event) {
  3959. handleClick(this.id, this.value);
  3960. }, false);
  3961. }
  3962. newtd.value = i < usedPlunder.length?usedPlunder[i]:"-1";
  3963. return;
  3964. }
  3965.  
  3966. function getPlunderlistForShop(k, pltab, allplunderArr, tr, plunderlist, plunderP, link)
  3967. {
  3968. if (pltab == 0) {
  3969. trace('Get ' + prothost + '/stock/plunder/', 2);
  3970. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/plunder/', onload:function(responseDetails) {
  3971. var content = responseDetails.responseText.split('id="plundertab"')[1];
  3972. var lis = content.split("</ul>")[0].split("<li>");
  3973. pltab = lis.length - 1;
  3974. link = lis[1].split('href="')[1].split("=")[0] + "=";
  3975. getPlunderlistForShop(k, pltab, allplunderArr, tr, plunderlist, plunderP, link);
  3976. }});
  3977. return;
  3978. }
  3979.  
  3980. trace('Get ' + prothost + link + k, 2);
  3981. GM_xmlhttpRequest({method:"GET", url: prothost + link + k, onload:function(responseDetails) {
  3982. var content = responseDetails.responseText;
  3983.  
  3984. var trs = content.split("<tr ");
  3985. for (var i = 1; i < trs.length; i++) {
  3986. var plname = trs[i].split(">x ")[0].split("</strong")[0].split(">").pop().trim();
  3987. var pid = trs[i].split('stock/plunder/craft/details/')[1].split("/")[0];
  3988. var indx = plunderlist.indexOf(pid);
  3989. if (indx != -1) {
  3990. allplunderArr.push([plname, pid, plunderP[indx]]);
  3991. plunderP[indx] = plunderP[indx].split(":")[0]+":"+plname;
  3992. }
  3993. }
  3994. if (k < pltab)
  3995. getPlunderlistForShop(k+1, pltab, allplunderArr, tr, plunderlist, plunderP, link);
  3996. else {
  3997. for (var i = 0; i < plunderP.length; i++)
  3998. plunderP[i] = plunderlist[i] + "=" + plunderP[i];
  3999. PG_setValue("buyablegoods", plunderP.join("#"));
  4000. var alwaysbuy = PGu_getValue("alwaysbuy", "");
  4001. if (alwaysbuy == "")
  4002. alwaysbuy = [];
  4003. else
  4004. alwaysbuy = alwaysbuy.split(";");
  4005. for (var i = 0; i <= alwaysbuy.length; i++)
  4006. buildSelectBox(i, allplunderArr.sort(function(a,b) {return a[0].toLowerCase()<b[0].toLowerCase()?-1:1;}), alwaysbuy, tr);
  4007. }
  4008. }});
  4009. }
  4010.  
  4011. function insertCheckBox13(obj) {
  4012. var buyable = PG_getValue("buyablegoods", "");
  4013. if (buyable == "")
  4014. return;
  4015. var newtd = document.createElement("td");
  4016. var newdiv = document.createElement("div");
  4017. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  4018. var div = document.getElementsByClassName("ps_outer_shell")[0];
  4019. div.appendChild(newdiv, div);
  4020. var allplunderArr = [];
  4021. var gpl = false;
  4022. if (buyable == "") {
  4023. buyableP = [];
  4024. buyable = [];
  4025. }
  4026. else {
  4027. buyableP = buyable.replace(/[^#]+=/g, "").split("#");
  4028. buyable = buyable.replace(/=[^#]+/g, "").split("#");
  4029. for (var i = 0; i < buyableP.length; i++)
  4030. if (buyableP[i].indexOf("*") == -1)
  4031. gpl = true;
  4032. }
  4033. if (gpl) {
  4034. alert("gpl is true: " + buyableP);
  4035. getPlunderlistForShop(1, 0, allplunderArr, div, buyable, buyableP, "");
  4036. }
  4037. else {
  4038. for (var i = 0; i < buyable.length; i++)
  4039. allplunderArr.push([buyableP[i].split("*")[0], buyable[i], buyableP[i]]);
  4040. var alwaysbuy = PGu_getValue("alwaysbuy", "");
  4041. if (alwaysbuy == "")
  4042. alwaysbuy = [];
  4043. else
  4044. alwaysbuy = alwaysbuy.split(";");
  4045. for (var i = 0; i <= alwaysbuy.length; i++)
  4046. if (alwaysbuy[0] != "0" || i == 0)
  4047. buildSelectBox(i, allplunderArr.sort(function(a,b) {return a[0].toLowerCase()<b[0].toLowerCase()?-1:1;}), alwaysbuy, div);
  4048. }
  4049. var bought = PGu_getValue("bought", "");
  4050. if (bought != "") {
  4051. var newspan = document.createElement("span");
  4052. newspan.innerHTML += '<input type="submit" value="gekaufter Plunder" style="font-size:18px; background-color:darkgreen; float:right" id="boughtplnd">';
  4053. var header = div.getElementsByClassName("ps_header")[0];
  4054. div.insertBefore(newspan, header);
  4055. var buyable = PG_getValue("buyablegoods", "");
  4056. var buyableP = [];
  4057. if (buyable == "")
  4058. buyable = [];
  4059. else {
  4060. buyableP = buyable.replace(/[^#]*=/g, "").replace(/\*[^#]*/g, "").split("#");
  4061. buyable = buyable.replace(/=[^#]*/g, "").split("#");
  4062. }
  4063.  
  4064. // Click-Handler hinzufügen
  4065. document.getElementById("boughtplnd").addEventListener("click", function(event) {
  4066. var bought = PGu_getValue("bought", "");
  4067. if (bought == "")
  4068. bought = "Nichts gekauft";
  4069. else {
  4070. boughtArr = bought.split(";");
  4071. bought = "";
  4072. var btime = new Date();
  4073. for (var i = 0; i < boughtArr.length; i++) {
  4074. var arr = boughtArr[i].replace(/,/g, ":").split(":");
  4075. btime.setTime(arr[0]);
  4076. bought += btime.toLocaleString() + ": ";
  4077. for (var j = 1; j < arr.length; j++) {
  4078. bought += buyableP[buyable.indexOf(arr[j])] + (j < arr.length-1?", ":"\n");
  4079. }
  4080. }
  4081. }
  4082. alert(bought);
  4083. }, false);
  4084. }
  4085. }
  4086.  
  4087. function insertCheckBox14() {
  4088. var town = ["HH", "B", "MU", "HR", "K", "SY", "ML", "VT", "AT"];
  4089. if (town.indexOf(TOWNEXTENSION) == -1)
  4090. return;
  4091.  
  4092. var el = document.getElementById("6");
  4093. if (!el)
  4094. return;
  4095. el.getElementsByTagName("a")[0].href = "#";
  4096. el.getElementsByTagName("img")[0].addEventListener("click", function(event) {
  4097. if (event.altKey != 0)
  4098. unsafeWindow.display_show("sticker_shop");
  4099. else
  4100. unsafeWindow.display_show("shop");
  4101. }, false);
  4102. }
  4103.  
  4104. function insertCheckBox15() {
  4105. if (!expertMode)
  4106. return;
  4107.  
  4108. var town = ["HH", "B", "MU", "HR", "K", "SY", "VT", "AT", "ML"];
  4109. if (town.indexOf(TOWNEXTENSION) == -1)
  4110. return;
  4111.  
  4112. var options = "";
  4113. var pltab = 4;
  4114. if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" || TOWNEXTENSION == "MU")
  4115. pltab = 3;
  4116. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
  4117. var content = responseDetails.responseText;
  4118. var trs = content.split("<tr ");
  4119. for (var i = 1; i < trs.length; i++) {
  4120. if ((trs[i].indexOf('ktuellen Kampf') != -1 || trs[i].indexOf('ktuellen Angriff') != -1) && trs[i].indexOf("eingehend") == -1) {
  4121. var pid = trs[i].split('pm_')[1].split("'")[0].trim();
  4122. var pname = trs[i].split("<strong ")[1].split("</strong")[0].split(">")[1].trim();
  4123. var anz = trs[i].split("</strong>")[1].split("</span>")[0].split(">x ")[1].trim();
  4124. var effect = trs[i].split('class="pinfo2"')[1].split("</p>")[0].split(">").pop().trim();
  4125. var prozp = effect.indexOf("%");
  4126. if (prozp != -1)
  4127. effect = effect.substr(0, prozp+1) + " ab";
  4128. else {
  4129. var p = effect.indexOf("Minute");
  4130. if (p != -1) {
  4131. effect = effect.match(/[^ ]+ [^ ]+ Minute[n]*/)[0].replace(/folgenden |nächsten |auf /, "").replace("zwei", 2).trim();
  4132. }
  4133. }
  4134. options = options + '<option value="' + pid + '">' + pname + ' (' + anz + ') (' + effect + ')</option>';
  4135. }
  4136. }
  4137. var el = document.getElementsByTagName("hr")[2];
  4138. if (!el)
  4139. return;
  4140. var td = el.parentNode.parentNode.previousSibling.previousSibling.getElementsByTagName("td")[0];
  4141. td.innerHTML = '<input name="downfightChb" id="downfightChb" type="checkbox"><span style="vertical-align: bottom">&nbsp;Downfighter automatisch angreifen</span><br>' +
  4142. '<input name="downfightChb2" id="downfightChb2" type="checkbox" style="visibility:hidden"><span id="dftext1" style="vertical-align: bottom;visibility:hidden">&nbsp;wenn keine Wut, dann </span><select id="dfplunder" name="dfplunder" style="visibility:hidden">'+options+'</select><span id="dftext2" style="vertical-align: bottom;visibility:hidden"> benutzen</span>';
  4143.  
  4144. if (PGu_getValue("downfightauto", false)) {
  4145. document.getElementById("downfightChb").checked = true;
  4146. document.getElementById("downfightChb2").checked = PGu_getValue("dfUsePlunder", false);
  4147. document.getElementById("downfightChb2").style.visibility = "visible";
  4148. document.getElementById("dftext1").style.visibility = "visible";
  4149. if (PGu_getValue("dfPlunder", "") === "")
  4150. document.getElementById("dfplunder").selectedIndex = 0;
  4151. else
  4152. document.getElementById("dfplunder").value = PGu_getValue("dfPlunder", "");
  4153. document.getElementById("dfplunder").style.visibility = "visible";
  4154. document.getElementById("dftext2").style.visibility = "visible";
  4155. }
  4156. else
  4157. document.getElementById("downfightChb").checked = false;
  4158. // Click-Handler hinzufügen
  4159. document.getElementById("downfightChb").addEventListener("click", function(event) {
  4160. // Klickstatus speichern
  4161. PGu_setValue("downfightauto", this.checked);
  4162. if (this.checked) {
  4163. PG_setValue("LastUpdateDF", "0");
  4164. document.getElementById("downfightChb2").style.visibility = "visible";
  4165. document.getElementById("dftext1").style.visibility = "visible";
  4166. document.getElementById("dfplunder").style.visibility = "visible";
  4167. document.getElementById("dftext2").style.visibility = "visible";
  4168. }
  4169. else {
  4170. document.getElementById("downfightChb2").style.visibility = "hidden";
  4171. document.getElementById("dftext1").style.visibility = "hidden";
  4172. document.getElementById("dfplunder").style.visibility = "hidden";
  4173. document.getElementById("dftext2").style.visibility = "hidden";
  4174. }
  4175. }, false);
  4176. document.getElementById("downfightChb2").addEventListener("click", function(event) {
  4177. PGu_setValue("dfUsePlunder", this.checked);
  4178. if (this.checked)
  4179. PGu_setValue("dfPlunder", document.getElementById("dfplunder").value);
  4180. }, false);
  4181. document.getElementById("dfplunder").addEventListener("change", function(event) {
  4182. PGu_setValue("dfPlunder", this.value);
  4183. }, false);
  4184. }});
  4185. }
  4186.  
  4187. function buildSelectBox(i, allplunderArr, usedPlunder, tr) {
  4188. function handleClick(id, value) {
  4189. // neuen Wert speichern
  4190. var boxnr = id.replace("shopid", "");
  4191. if (value == "-1")
  4192. usedPlunder.splice(boxnr, 1);
  4193. else if (value == "0") {
  4194. if (usedPlunder[0] != "0")
  4195. usedPlunder.splice(0, 0, "0");
  4196. }
  4197. else if (usedPlunder.indexOf(value) != -1)
  4198. usedPlunder.splice(boxnr, 1);
  4199. else
  4200. usedPlunder[boxnr] = value;
  4201. PGu_setValue("alwaysbuy", usedPlunder.join(";"));
  4202. for (var i = 0; i < usedPlunder.length || document.getElementById("shopid"+i); i++) {
  4203. if (i >= usedPlunder.length || usedPlunder[0] == "0" && i > 0) {
  4204. if (document.getElementById("shopid"+i))
  4205. document.getElementById("shopid"+i).parentNode.parentNode.style.visibility = "hidden";
  4206. continue;
  4207. }
  4208. buildSelectBox(i, allplunderArr, usedPlunder, tr);
  4209. }
  4210. if (i >= allplunderArr.length - 1 || usedPlunder[0] == "0")
  4211. return;
  4212. buildSelectBox(usedPlunder.length, allplunderArr, usedPlunder, tr);
  4213. }
  4214. if (i >= allplunderArr.length - 1 || usedPlunder[0] == "0" && i > 0)
  4215. return;
  4216. var option = '<option value="-1"> </option><option value="0">alles kaufen</option> ';
  4217. for (var j = 0; j < allplunderArr.length; j++) {
  4218. var pos = usedPlunder.indexOf(allplunderArr[j][1]);
  4219. if (pos == -1 || pos == i || usedPlunder[0] == "0")
  4220. option += '<option value="' + allplunderArr[j][1] + '">' + allplunderArr[j][0] + ' (' + allplunderArr[j][2].split("*")[1] + ')</option> ';
  4221. }
  4222. var newtd = document.getElementById("shopid"+i);
  4223. if (newtd) {
  4224. newtd.parentNode.parentNode.style.visibility = "visible";
  4225. newtd.innerHTML = option;
  4226. }
  4227. else {
  4228. newtd = document.createElement("td");
  4229. newtd.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  4230. newtd.innerHTML = '<form name="shop' + i + '" id="shop' + i + '">' + (i==0?"Plunder immer kaufen":"und außerdem") + ': <select id="shopid' + i +'" name="shopid' + i + '"> ' + option + ' </select> </form>';
  4231. var newdiv = document.createElement("div");
  4232. newdiv.appendChild(newtd, newdiv);
  4233. tr.parentNode.appendChild(newdiv, tr);
  4234. newtd = document.getElementById("shopid"+i);
  4235. // Click-Handler hinzufügen
  4236. newtd.addEventListener("change", function(event) {
  4237. handleClick(this.id, this.value);
  4238. }, false);
  4239. }
  4240. newtd.value = i < usedPlunder.length?usedPlunder[i]:"-1";
  4241. return;
  4242. }
  4243.  
  4244. // ***********************************************************************************************
  4245. // ***********************************************************************************************
  4246. // check for enemy game and play it
  4247. // ***********************************************************************************************
  4248. // ***********************************************************************************************
  4249. function CheckEnemygame () {
  4250. PG_log("CheckEnemygame");
  4251. if (!document.getElementById("enemy_info"))
  4252. return;
  4253. GM_xmlhttpRequest({method:"GET", url: prothost + '/enemies/', onload:function(responseDetails) {
  4254. var content = responseDetails.responseText;
  4255. var pos = content.indexOf('id="fight_button');
  4256. if (pos != -1) {
  4257. if (content.substr(pos, 100).indexOf('counter(') == -1)
  4258. setTimeout(Enemyattack, 1500);
  4259. return;
  4260. }
  4261. pos = content.indexOf('hp_bar_blue');
  4262. if (pos == -1) {
  4263. return;
  4264. }
  4265. else {
  4266. var poscnt = content.indexOf('counter(', pos);
  4267. if (poscnt != -1) {
  4268. var cnt = parseInt(content.substr(poscnt+8).split(")")[0].split(',')[0]);
  4269. if (cnt > 0)
  4270. setTimeout(enemyreload, cnt*1000, "CheckEnemygame");
  4271. }
  4272. }
  4273. }
  4274. });
  4275. }
  4276.  
  4277. // ***********************************************************************************************
  4278. // ***********************************************************************************************
  4279. // buy luck
  4280. // ***********************************************************************************************
  4281. // ***********************************************************************************************
  4282. function LoseKaufen (content, anzLose) {
  4283. if (anzLose <= 0) {
  4284. reload("LoseKaufen");
  4285. return;
  4286. }
  4287.  
  4288. var pos = content.indexOf('name="preis_cent"');
  4289. if (pos < 0)
  4290. return;
  4291. var anz = (anzLose > 10?10:anzLose);
  4292. var preis = (Number(content.substr(content.lastIndexOf("<input", pos)).split('value="')[1].split('"')[0]) * anz).toString();
  4293.  
  4294. pos = content.indexOf('name="submitForm"');
  4295. if (pos < 0)
  4296. return;
  4297. var val = content.substr(content.lastIndexOf("<input", pos)).split('value="').pop().split('"')[0];
  4298. preis = preis.substr(0, preis.length-2) + "." + preis.substr(-2);
  4299.  
  4300. HttpPost(content, 1, ["menge", anz, "submitForm", val.replace("1.00", preis)],
  4301. function() { LoseKaufen(content, anzLose - anz); });
  4302. }
  4303.  
  4304. // ***********************************************************************************************
  4305. // ***********************************************************************************************
  4306. // start a mission
  4307. // ***********************************************************************************************
  4308. // ***********************************************************************************************
  4309. function StartMission (missionname, id, plist, losecont, nochlose)
  4310. {
  4311. trace("Post Missionstart " + id, 2);
  4312. GM_xmlhttpRequest({method: 'POST',
  4313. url: prothost + '/gang/missions/start/',
  4314. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  4315. data: encodeURI('mission_id='+id+'&cancel=false'),
  4316. onload: function(responseDetails) {
  4317. var to = (responseDetails.responseText.indexOf("aktuelle Mission erst abschl") != -1);
  4318. if (to)
  4319. setTimeout(reload, 30000, "StartMission1");
  4320. else {
  4321. trace('Get ' + prothost + '/gang/admin/log/', 2);
  4322. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/admin/log/', onload:function(responseDetails) {
  4323. var start = responseDetails.responseText.split(" wurde gestartet");
  4324. var missText = start[0].split("<td").pop().split('"')[1];
  4325. var user = start[0].substr(0, start[0].lastIndexOf("</td")).split(">").pop().trim();
  4326. if (user != m_ownusername) {
  4327. setTimeout(reload, 30000, "StartMission2");
  4328. return;
  4329. }
  4330. if (missionname == "kieztour" || missionname == "strassenkampf") {
  4331. trace("Post Bandenmail", 2);
  4332. GM_xmlhttpRequest({method: 'POST',
  4333. url: prothost + '/gang/admin/massmail/',
  4334. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  4335. data: encodeURI('f_subject=Mission ' + missText + ' gestartet&sel=Alle&f_text='+(losecont==""?"":losecont+"\n\nGruß "+user)),
  4336. onload: function(responseDetails) {
  4337. }
  4338. });
  4339. }
  4340. function plEnable (plist, i) {
  4341. if (i >= plist.length) {
  4342. if (missionname == "casino") {
  4343. trace("Lose kaufen: " + nochlose, 5);
  4344. LoseKaufen(losecont, nochlose);
  4345. }
  4346. else
  4347. reload("plEnable");
  4348. return;
  4349. }
  4350. trace("Post Enable Plunder", 2);
  4351. GM_xmlhttpRequest({method: 'POST',
  4352. url: prothost + '/gang/missions/plunder/enable/',
  4353. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  4354. data: encodeURI('pid='+plist[i]),
  4355. onload: function(responseDetails) {
  4356. plEnable(plist, i+1);
  4357. }
  4358. });
  4359. }
  4360. plEnable(plist, 0);
  4361. }
  4362. });
  4363. }
  4364. }
  4365. });
  4366. }
  4367. // ***********************************************************************************************
  4368. // ***********************************************************************************************
  4369. // handle a mission
  4370. // ***********************************************************************************************
  4371. // ***********************************************************************************************
  4372. function HandleMission (missionname, missionStart, missions)
  4373. {
  4374. var m = MissIndex(missionStart, missionname);
  4375. if (m < 1 || m >= missionStart.length)
  4376. return -1;
  4377. var missname = missionStart[m][0];
  4378. var pos = missions[m].indexOf(missname + '.png');
  4379. if (pos == -1)
  4380. return -1;
  4381. var mission = missions[m].substr(pos).split("</table>")[0];
  4382. pos = mission.indexOf("counter(");
  4383. var counter = 0;
  4384. if (pos != -1) {
  4385. counter = mission.substr(pos).split("counter(")[1].split(")")[0].trim();
  4386. if (counter != done) {
  4387. counter = Number(counter);
  4388. PGu_setValue("NextStart" + missionname, counter);
  4389. }
  4390. else
  4391. PGu_setValue("NextStart" + missionname, -1);
  4392. if (counter > 0 && counter < 3600)
  4393. setTimeout(reload, (counter<3?3:counter) * 1000, "HandleMission1");
  4394. }
  4395. var plist = mission.split('show_city_list(');
  4396. var plnd = [];
  4397. for (var j = 1; j < plist.length; j++) {
  4398. var pid = plist[j].split(",")[0];
  4399. var pos = plist[j-1].lastIndexOf("icon_display");
  4400. if (pos == -1)
  4401. continue;
  4402. var plunder = plist[j-1].substr(pos).split("<span>")[1].split("</span>")[0].trim();
  4403. if (PGu_getValue(plunder+"Coll", false))
  4404. plnd.push(pid);
  4405. }
  4406.  
  4407. var cnt = 0;
  4408. for (var j = 0; j < plnd.length; j++) {
  4409. var pos = mission.indexOf('show_city_list('+plnd[j]+',');
  4410. if (pos == -1)
  4411. continue;
  4412. if (mission.substr(pos,40).indexOf('deactivate') == -1) {
  4413. cnt++;
  4414. var today = new Date();
  4415. var now = Math.floor(today.getTime()/1000);
  4416. var plndColl = PGu_getValue(plnd[j] + "_Coll", -1);
  4417. if (plndColl == -1)
  4418. PGu_setValue(plnd[j] + "_Coll", Math.floor(now/1000));
  4419. else if (plndColl + 30 < now) {
  4420. PGu_setValue(plnd[j] + "_Coll", -1);
  4421. trace("Post Enable Plunder", 2);
  4422. GM_xmlhttpRequest({method: 'POST',
  4423. url: prothost + '/gang/missions/plunder/enable/',
  4424. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  4425. data: encodeURI('pid='+plnd[j]),
  4426. onload: function(responseDetails) {
  4427. reload("HandleMission2");
  4428. }
  4429. });
  4430. }
  4431. }
  4432. else
  4433. PGu_setValue(plnd[j] + "_Coll", -1);
  4434. }
  4435. if (cnt > 0)
  4436. return 0;
  4437.  
  4438. var pos = mission.indexOf('job_notdone');
  4439. if (pos != -1) {
  4440. if (missionname == "kieztour")
  4441. PGu_setValue("KiezTourAct", 1);
  4442. if (missionname == "strassenkampf")
  4443. PGu_setValue("StrassenKampfAct", 1);
  4444. if (missionname == "casino" && mission.substr(pos).split("<br")[0].indexOf("Rubbellose") == -1)
  4445. return -1;
  4446. return pos;
  4447. }
  4448. if (missionname == "kieztour")
  4449. PGu_setValue("KiezTourAct", 0);
  4450. if (missionname == "strassenkampf")
  4451. PGu_setValue("StrassenKampfAct", 0);
  4452.  
  4453. if (missions[1].indexOf("return cancel_popup(") != -1)
  4454. return -1;
  4455.  
  4456. if (missionname == "schrottplatz") {
  4457. var allplunder = PG_getValue("allplunder", "").replace("&auml;", "ä").replace("&ouml;", "ö").replace("&uuml;", "ü").replace("&szlig;", "ß").split(";");
  4458. for (var i = allplunder.length - 1; i >= 0; i--)
  4459. if (allplunder.indexOf(allplunder[i]) < i || allplunder[i] == "Zertr&uuml" || allplunder[i] == "Zertrü" || allplunder[i].startsWith("mmerte"))
  4460. allplunder.splice(i, 1);
  4461. else if (allplunder[i] == "Abgehackte Hand:0" || allplunder[i] == "Blutige Axt:0")
  4462. allplunder[i] = allplunder[i].replace(":0", ":1");
  4463. PG_setValue("allplunder", allplunder.join(";"));
  4464. }
  4465. pos = mission.indexOf("mission_item_notready");
  4466. if (pos != -1) {
  4467. var amount = mission.substr(pos).split('class="amount">x')[1].split('</span')[0].trim();
  4468. var plunder = mission.substr(pos).split('class="amount">x')[0].split("<span>").pop().split('</span')[0].trim();
  4469. var muss = Number(amount.split("(")[0].trim());
  4470. var ist = Number(amount.split("(")[1].split(")")[0].trim());
  4471. if (muss < 1000 && !PGu_getValue(plunder+"Coll", false))
  4472. return -1;
  4473. if (muss >= 1000 && !PGu_getValue(plunder+"PayIn", false))
  4474. return -1;
  4475. if (ist < muss) {
  4476. gangpayin(plunder, muss - ist);
  4477. return 0;
  4478. }
  4479. }
  4480. if (mission.indexOf('start_mission(') != -1) {
  4481. var auto = PGu_getValue(missname+"Auto", false);
  4482. if (!auto)
  4483. return -1;
  4484. var mintime = -1;
  4485. for (var j = 1; j < missionStart.length; j++)
  4486. if (missname == missionStart[j][0])
  4487. continue;
  4488. else if (mintime == -1 || mintime > missionStart[j][1])
  4489. mintime = missionStart[j][1];
  4490. if (PGu_getValue(missname+"MissT", false) && PGu_getValue(missname+"Time", 0)*60 > mintime)
  4491. return -1;
  4492. var id = mission.split('start_mission(')[1].split(')')[0];
  4493. if (missionname == "casino") {
  4494. trace('Get ' + prothost + '/city/games/', 2);
  4495. GM_xmlhttpRequest({method:"GET",
  4496. url: prothost + '/city/games/',
  4497. onload:function(responseDetails) {
  4498. var content = responseDetails.responseText.split('id="content"')[1];
  4499. var to = 0;
  4500. var nochlose = content.split("Du kannst heute noch ").pop();
  4501. if (nochlose.indexOf("lose_remaining") != -1)
  4502. nochlose = nochlose.split("</span>")[0].split(">").pop();
  4503. if (nochlose == 0)
  4504. return;
  4505. var gesamt = Number(mission.match(/Kauft \d* Rubbel/)[0].split(" ")[1]);
  4506. if (gesamt < nochlose)
  4507. nochlose = gesamt;
  4508. StartMission (missionname, id, plnd, content, nochlose);
  4509. }
  4510. });
  4511. return -1;
  4512. }
  4513. if (missionname == "kieztour" || missionname == "strassenkampf") {
  4514. var zText = "";
  4515. if (missionname == "strassenkampf") {
  4516. var lis = mission.split("stage_area")[2].split("<li");
  4517. var spl = lis[1].split(/\d+ +Kämpfe/)[0].split("</div>")[1].trim().split(" ");
  4518. spl.splice(0,2);
  4519. zText = "Bitte alle bei Kämpfen nach " + spl.join(" ") + " ziehen.";
  4520. }
  4521. StartMission (missionname, id, plnd, zText, 0);
  4522. return 0;
  4523. }
  4524. if (missionname == "schrottplatz") {
  4525. var neededPlunder = [];
  4526. var pAnz = 0;
  4527. for (var i = 1; i < missions.length; i++) {
  4528. var lis = missions[i].split("stage_area")[1].split("<li>");
  4529. for (var j = 1; j < lis.length; j++) {
  4530. var beg = lis[j].split('"amount"');
  4531. if (beg.length > 1) {
  4532. var plname = beg[0].split("<span>")[1].split("<")[0].trim();
  4533. if (!PGu_getValue(plname+"Schrott", false))
  4534. neededPlunder[pAnz++] = plname;
  4535. }
  4536. }
  4537. }
  4538. var gesamt = Number(missions[m].split(" Plunder verschrotten")[0].substr(-50).match(/[\d]+/g).pop().trim());
  4539. var allplunder = PG_getValue("allplunder", "");
  4540. if (allplunder == "")
  4541. return 0;
  4542. var plunderlist = allplunder.replace(/:\d*/g, "").split(";");
  4543. allplunder = allplunder.split(";");
  4544. var openCalls = 0;
  4545. trace('Get ' + prothost + '/gang/stuff/upgrades/', 2);
  4546. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/stuff/upgrades/', onload:function(responseDetails) {
  4547. var upgrstuff = responseDetails.responseText.split(responseDetails.responseText.indexOf('class="skill_block')==-1?"<tr":'class="skill_block');
  4548. for (var j = 0; j < upgrstuff.length; j++) {
  4549. if (upgrstuff[j].indexOf("required_skills") != -1) {
  4550. var skpt = upgrstuff[j].match(/skill_progress_text">\d+ von \d+</);
  4551. if (skpt.length == 0)
  4552. continue;
  4553. skpt = skpt[0].split("<")[0].split(">").pop().split("von");
  4554. if (skpt.length != 2)
  4555. continue;
  4556. if (skpt[0].trim() == skpt[1].trim())
  4557. continue;
  4558. var plname = upgrstuff[j].split('required_skills')[1].split("</div")[0].split("<span");
  4559. for (var k = 0; k < plname.length-1; k++) {
  4560. var skspl = plname[k].split(">").pop().trim().split(" ");
  4561. var amnt = skspl.pop();
  4562. var pl = skspl.join(" ");
  4563. if (neededPlunder.indexOf(pl) == -1)
  4564. neededPlunder[pAnz++] = pl;
  4565. }
  4566. continue;
  4567. }
  4568. if (upgrstuff[j].indexOf("<td>Kosten") == -1)
  4569. continue;
  4570. var plname = upgrstuff[j].split("<td").pop().split("<br");
  4571. for (var k = 0; k < plname.length-1; k++) {
  4572. var pl = plname[k].split(/\d+x /)[1].trim();
  4573. if (neededPlunder.indexOf(pl) == -1)
  4574. neededPlunder[pAnz++] = pl;
  4575. }
  4576. }
  4577. trace('Get ' + prothost + '/gang/stuff/', 2);
  4578. GM_xmlhttpRequest({method:"GET",
  4579. url: prothost + '/gang/stuff/',
  4580. onload:function(responseDetails) {
  4581. function TestMissionPlunder(msgs, akti, missStart) {
  4582. for (var i = akti; i < msgs.length; i++) {
  4583. var tds = msgs[i].split("<td ");
  4584. if (tds[4].split("<span")[1].split(">")[1].split("<")[0].replace(/&nbsp;/g, "").trim() != "0")
  4585. continue;
  4586. var plname = tds[2].split("<strong>")[1].split("<")[0];
  4587. if (neededPlunder.indexOf(plname) != -1)
  4588. continue;
  4589. var plAnz = Number(tds[3].split("<span")[1].split(">")[1].split("<")[0].replace(/&nbsp;/g, "").trim());
  4590. var plInd = plunderlist.indexOf(plname);
  4591. if (plInd != -1) {
  4592. plAnz = Math.floor(plAnz/(allplunder[plInd].endsWith(":1")?60:1));
  4593. plAnzGes += plAnz;
  4594. }
  4595. else {
  4596. var trash = tds[6].split("trash_plunder('");
  4597. if (trash.length > 1) {
  4598. var pid = trash[1].split("'")[0].trim();
  4599. openCalls++;
  4600. trace('Get ' + prothost + '/stock/plunder/craft/details/'+pid+'/', 2);
  4601. GM_xmlhttpRequest({method:"GET",
  4602. url: prothost + '/stock/plunder/craft/details/'+pid+'/',
  4603. onload:function(responseDetails) {
  4604. var pcont = responseDetails.responseText.split('class="plundertitle"')[1];
  4605. if (pcont.indexOf('"pinfo2"') != -1) {
  4606. var pinfo2 = pcont.split('"pinfo2"')[1];
  4607. var plname = pcont.split("</strong")[0].split(">").pop().trim();
  4608. if (pinfo2.indexOf("Missionsplunder") != -1 || pinfo2.indexOf("Bandenmission") != -1)
  4609. allplunder.push(plname+":1");
  4610. else
  4611. allplunder.push(plname+":0");
  4612. plunderlist.push(plname);
  4613. }
  4614. openCalls--;
  4615. TestMissionPlunder(msgs, i+1, missStart);
  4616. }
  4617. });
  4618. return;
  4619. }
  4620. }
  4621. }
  4622. if (i >= msgs.length && missStart) {
  4623. PG_setValue("allplunder", allplunder.join(";"));
  4624. if (plAnzGes >= gesamt)
  4625. StartMission (missionname, id, plnd, "", 0);
  4626. }
  4627. }
  4628. function getGangStuff(categ, ix) {
  4629. if (openCalls > 0) {
  4630. window.setTimeout(getGangStuff, 500, categ, ix);
  4631. return;
  4632. }
  4633. if (ix < categ.length) {
  4634. var href = categ[ix].split('"')[0];
  4635. trace('Get ' + prothost + href, 2);
  4636. GM_xmlhttpRequest({method:"GET",
  4637. url: prothost + href,
  4638. onload:function(responseDetails) {
  4639. var msgs = responseDetails.responseText.split('"msglist"');
  4640. TestMissionPlunder(msgs, 1, false);
  4641. getGangStuff (categ, ix+1);
  4642. }
  4643. });
  4644. return;
  4645. }
  4646. PG_setValue("allplunder", allplunder.join(";"));
  4647. if (plAnzGes >= gesamt)
  4648. StartMission (missionname, id, plnd, "", 0);
  4649. }
  4650. var stuff = responseDetails.responseText;
  4651. if (stuff.indexOf("/category/") == -1) {
  4652. var msgs = stuff.split('"msglist"');
  4653. var plAnzGes = 0;
  4654. TestMissionPlunder(msgs, 1, true);
  4655. }
  4656. else {
  4657. var cat = stuff.split('id="plundertab')[1].split("</ul")[0].split('href="');
  4658. var plAnzGes = 0;
  4659. getGangStuff(cat, 1);
  4660. }
  4661. }
  4662. });
  4663. }});
  4664. return 0;
  4665. }
  4666. }
  4667. else if (mission.indexOf('return reward_popup(') != -1 || mission.indexOf('href="/gang/missions/reward/') != -1) {
  4668. var aktBoost = missions[0].split("Aktueller Bandenboost");
  4669. if (!PGu_getValue(missname+"Rwd", false))
  4670. var abhol = false;
  4671. else if (aktBoost.length == 1 || aktBoost[1].indexOf("Kein Boost vorh") != -1 || missionname == "kieztour")
  4672. var abhol = true;
  4673. else {
  4674. var boost = aktBoost[1].split('src="')[1].split('"')[0].split("/").pop().split(".")[0];
  4675. var abhol = PGu_getValue(boost+"Over", false);
  4676. }
  4677. if (abhol) {
  4678. window.location = prothost + '/gang/missions/reward/';
  4679. }
  4680. }
  4681. return -1;
  4682. }
  4683.  
  4684. // ***********************************************************************************************
  4685. // ***********************************************************************************************
  4686. // get time until start of mission
  4687. // ***********************************************************************************************
  4688. // ***********************************************************************************************
  4689. function getMissTime(missionname, content) {
  4690. var misstime = -1;
  4691. var missname = missionname;
  4692. var pos = content.indexOf(missionname+'.png');
  4693. if (pos == -1) {
  4694. if (missionname == "kieztour")
  4695. missname = "davinci_code";
  4696. else if (missionname == "strassenkampf")
  4697. missname = "schlacht_petersplatz";
  4698. else if (missionname == "schrottplatz")
  4699. missname = "kreuzzug";
  4700. pos = content.indexOf(missname+'.png');
  4701. }
  4702. if (pos > 0) {
  4703. misstime = 0;
  4704. var mission = content.substr(pos).split("</table>")[0];
  4705. pos = mission.split("stage_area")[1].indexOf("counter(");
  4706. if (pos != -1) {
  4707. var counter = mission.substr(pos).split("counter(")[1].split(")")[0].trim();
  4708. if (counter == done)
  4709. counter = "0";
  4710. misstime = Number(counter);
  4711. }
  4712. else if (!PGu_getValue(missname+"Auto", false) || mission.indexOf("mission_item_notready") != -1)
  4713. misstime = 999999999;
  4714. }
  4715. return misstime;
  4716. }
  4717.  
  4718. // ***********************************************************************************************
  4719. // ***********************************************************************************************
  4720. // find mission index
  4721. // ***********************************************************************************************
  4722. // ***********************************************************************************************
  4723. function MissIndex (missions, mission) {
  4724. for (var i = 1; i < missions.length; i++)
  4725. if (missions[i][0] == mission)
  4726. return i;
  4727. var missname = mission;
  4728. if (missname == "kieztour")
  4729. missname = "davinci_code";
  4730. else if (missname == "strassenkampf")
  4731. missname = "schlacht_petersplatz";
  4732. else if (missname == "schrottplatz")
  4733. missname = "kreuzzug";
  4734. for (var i = 1; i < missions.length; i++)
  4735. if (missions[i][0] == missname)
  4736. return i;
  4737. return -1;
  4738. }
  4739.  
  4740. // ***********************************************************************************************
  4741. // ***********************************************************************************************
  4742. // check for mission
  4743. // ***********************************************************************************************
  4744. // ***********************************************************************************************
  4745. function CheckMission () {
  4746. PG_log("CheckMission");
  4747. trace('Get ' + prothost + '/gang/missions/', 2);
  4748. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/missions/', onload:function(responseDetails) {
  4749. var content = responseDetails.responseText;
  4750. missionContent = content;
  4751. var missions = content.split('class="gang_mission"');
  4752. if (missions.length < 2)
  4753. return;
  4754. var mission = missions[1].split("</table>")[0];
  4755. var aktBoost = content.split("Aktueller Bandenboost");
  4756. var boost = "";
  4757. if (aktBoost.length > 1 && aktBoost[1].indexOf("Kein Boost vorh") == -1) {
  4758. boost = aktBoost[1].split('src="')[1].split('"')[0].split("/").pop().split(".")[0];
  4759. if (boost == "boost_nitro" && aktBoost[1].split("</script")[0].indexOf("counter(") != -1)
  4760. nitroCount = Number(aktBoost[1].split("</script")[0].split("counter(")[1].split(")")[0]);
  4761. }
  4762. if (mission.indexOf('return reward_popup(') != -1 || mission.indexOf('href="/gang/missions/reward/') != -1) {
  4763. var missname = mission.split("background-image")[1].split(")")[0].split("/").pop().split(".")[0];
  4764. if (PGu_getValue(missname+"Rwd", false) && (boost == "" || PGu_getValue(boost+"Over", false))) {
  4765. window.location = prothost + '/gang/missions/reward/';
  4766. return;
  4767. }
  4768. }
  4769. var pos = content.indexOf('boost_button');
  4770. if (pos != -1)
  4771. pos = content.substr(pos).indexOf('activate_boost(');
  4772. if (pos != -1) {
  4773. var aktBoost = content.split("Aktueller Bandenboost");
  4774. if (aktBoost.length == 1 || aktBoost[1].indexOf("Kein Boost vorh") != -1)
  4775. var Start = false;
  4776. else {
  4777. var boost = aktBoost[1].split('src="')[1].split('"')[0].split("/").pop().split(".")[0];
  4778. var Start = PGu_getValue(boost+"Start", false);
  4779. }
  4780. if (Start) {
  4781. HttpPost(content, "boost_form", [], function() { reload("CheckMission1"); });
  4782. return;
  4783. }
  4784. }
  4785. var missionStart = [];
  4786. for (var i = 1; i < missions.length; i++) {
  4787. var mission = missions[i].split("background-image")[1].split(")")[0].split("/").pop().split(".")[0];
  4788. var missTime = getMissTime(mission, missions[i]);
  4789. missionStart[i] = [mission, missTime];
  4790. if (i == 1)
  4791. missionStart[0] = [mission, missTime];
  4792. if (!PGu_getValue(mission+"MissT", false))
  4793. continue;
  4794. missTime = PGu_getValue(mission + "Time", 0)*60;
  4795. for (var j = 1; j < i; j++)
  4796. if (missTime + missionStart[i][1] > missionStart[j][1])
  4797. missionStart[i][1] = missionStart[j][1];
  4798. if (missionStart[i][1] == 0)
  4799. missionStart[i][1] = missTime;
  4800.  
  4801. if (missionStart[i][1] < missionStart[0][1])
  4802. missionStart[0] = missionStart[i];
  4803. }
  4804.  
  4805. pos = HandleMission("casino", missionStart, missions);
  4806. if (pos > 0) {
  4807. var kauf = missions[1].substr(pos).split("<br")[1].split("</span")[0].split(">").pop().trim();
  4808. kauf = kauf.split("/");
  4809. var gekauft = Number(kauf[0].trim());
  4810. var gesamt = Number(kauf[1].trim());
  4811. if (gekauft == gesamt)
  4812. return;
  4813. trace('Get ' + prothost + '/gang/admin/log/', 2);
  4814. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/admin/log/', onload:function(responseDetails) {
  4815. var casino = responseDetails.responseText.split('Mission "Casino-Besuch" wurde gestartet');
  4816. var pos = casino[0].lastIndexOf("</td>");
  4817. var to = 0;
  4818. if (pos == -1)
  4819. to = 30;
  4820. if (!casino[0].substr(0, pos).endsWith(m_ownusername))
  4821. to = 30;
  4822. if (to > 0) {
  4823. var now = new Date().getTime();
  4824. var tdiff = now - Number(PGu_getValue("LastLoseKauf", "0"));
  4825. if (tdiff > 60000) {
  4826. PGu_setValue("LastLoseKauf", now+"");
  4827. tdiff = 0;
  4828. }
  4829. if (tdiff < to*1000) {
  4830. setTimeout(reload, to*1000 - tdiff, "CheckMission2");
  4831. return;
  4832. }
  4833. }
  4834. trace('Get ' + prothost + '/city/games/', 2);
  4835. GM_xmlhttpRequest({method:"GET", url: prothost + '/city/games/', onload:function(responseDetails) {
  4836. var content = responseDetails.responseText.split('id="content"')[1];
  4837. var nochlose = content.split("Du kannst heute noch ").pop();
  4838. if (nochlose.indexOf("lose_remaining") != -1)
  4839. nochlose = nochlose.split("</span>")[0].split(">").pop();
  4840. if (nochlose == 0)
  4841. return;
  4842. if (gesamt - gekauft < nochlose)
  4843. nochlose = gesamt - gekauft;
  4844. if (nochlose > 100)
  4845. nochlose = 100;
  4846. trace("Lose kaufen: " + nochlose, 5);
  4847. LoseKaufen(content, nochlose);
  4848. }
  4849. });
  4850. }
  4851. });
  4852. return;
  4853. }
  4854. pos = HandleMission("schrottplatz", missionStart, missions);
  4855. if (pos > 0 && PGu_getValue(missionStart[0][0]+"Auto", false)) {
  4856. var neededPlunder = [];
  4857. var pAnz = 0;
  4858. for (var i = 1; i < missions.length; i++) {
  4859. var lis = missions[i].split("stage_area")[1].split("<li>");
  4860. for (var j = 1; j < lis.length; j++) {
  4861. var beg = lis[j].split('"amount"');
  4862. if (beg.length > 1) {
  4863. var plnd = beg[0].split("<span>")[1].split("<")[0].trim();
  4864. if (!PGu_getValue(plnd+"Schrott", false))
  4865. neededPlunder[pAnz++] = plnd;
  4866. }
  4867. }
  4868. }
  4869. var kauf = missions[1].substr(pos).split("<br")[1].split("</span")[0].split(">").pop().trim();
  4870. kauf = kauf.split("/");
  4871. var gekauft = Number(kauf[0].trim());
  4872. var gesamt = Number(kauf[1].trim());
  4873. if (gekauft == gesamt)
  4874. return;
  4875. var allplunder = PG_getValue("allplunder", "");
  4876. if (allplunder == "")
  4877. return;
  4878. var plunderlist = allplunder.replace(/:\d*/g, "").split(";");
  4879. allplunder = allplunder.split(";");
  4880. var openCalls = 0;
  4881. trace('Get ' + prothost + '/gang/stuff/upgrades/', 2);
  4882. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/stuff/upgrades/', onload:function(responseDetails) {
  4883. var upgrstuff = responseDetails.responseText.split(responseDetails.responseText.indexOf('class="skill_block')==-1?"<tr":'class="skill_block');
  4884. for (var j = 0; j < upgrstuff.length; j++) {
  4885. if (upgrstuff[j].indexOf("required_skills") != -1) {
  4886. var skpt = upgrstuff[j].match(/skill_progress_text">\d+ von \d+</);
  4887. if (skpt.length == 0)
  4888. continue;
  4889. skpt = skpt[0].split("<")[0].split(">").pop().split("von");
  4890. if (skpt.length != 2)
  4891. continue;
  4892. if (skpt[0].trim() == skpt[1].trim())
  4893. continue;
  4894. var plnd = upgrstuff[j].split('required_skills')[1].split("</div")[0].split("<span");
  4895. for (var k = 0; k < plnd.length-1; k++) {
  4896. var skspl = plnd[k].split(">").pop().trim().split(" ");
  4897. var amnt = skspl.pop();
  4898. var pl = skspl.join(" ");
  4899. if (neededPlunder.indexOf(pl) == -1)
  4900. neededPlunder[pAnz++] = pl;
  4901. }
  4902. continue;
  4903. }
  4904. if (upgrstuff[j].indexOf("<td>Kosten") == -1)
  4905. continue;
  4906. var plnd = upgrstuff[j].split("<td").pop().split("<br");
  4907. for (var k = 0; k < plnd.length-1; k++) {
  4908. var pl = plnd[k].split(/\d+x /)[1].trim();
  4909. if (neededPlunder.indexOf(pl) == -1)
  4910. neededPlunder[pAnz++] = pl;
  4911. }
  4912. }
  4913. trace('Get ' + prothost + '/gang/stuff/', 2);
  4914. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/stuff/', onload:function(responseDetails) {
  4915. function TestMissionPlunder(msgs, akti, trash) {
  4916. for (var i = akti; i < msgs.length; i++) {
  4917. var tds = msgs[i].split("<td ");
  4918. if (tds[4].split("<span")[1].split(">")[1].split("<")[0].replace(/&nbsp;/g, "").trim() != "0")
  4919. continue;
  4920. var pltext = tds[6].split("trash_plunder(")[1].split(")")[0];
  4921. var plnd = pltext.split("'")[1].trim();
  4922. if (neededPlunder.indexOf(plnd) != -1)
  4923. continue;
  4924. var pid = pltext.split(",")[0].trim();
  4925. var plAnz = Number(pltext.split(",")[1].trim());
  4926. var plInd = plunderlist.indexOf(plnd);
  4927. if (plInd != -1) {
  4928. if (allplunder[plInd].endsWith("1")) {
  4929. if ((mp && plAnz <= leastAnz || !mp) && plAnz >= minMiss) {
  4930. leastAnz = plAnz;
  4931. leastpl = pltext;
  4932. mp = true;
  4933. }
  4934. }
  4935. else if (!mp && (leastpl == "" || plAnz < leastAnz)) {
  4936. leastAnz = plAnz;
  4937. leastpl = pltext;
  4938. }
  4939. }
  4940. else {
  4941. openCalls++;
  4942. trace('Get ' + prothost + '/stock/plunder/craft/details/'+pid+'/', 2);
  4943. GM_xmlhttpRequest({method:"GET",
  4944. url: prothost + '/stock/plunder/craft/details/'+pid+'/',
  4945. onload:function(responseDetails) {
  4946. var pcont = responseDetails.responseText.split('class="plundertitle"')[1];
  4947. var plname = pcont.split("</strong")[0].split(">").pop().trim();
  4948. var mpl = 0;
  4949. if (pcont.indexOf('"pinfo2"') != -1)
  4950. if (pcont.split('"pinfo2"')[1].indexOf("Missionsplunder") != -1 ||
  4951. pcont.split('"pinfo2"')[1].indexOf("Bandenmission") != -1)
  4952. mpl = 1;
  4953. allplunder.push(plname+":"+mpl);
  4954. plunderlist.push(plname);
  4955. if (mpl == 1) {
  4956. if ((mp && plAnz <= leastAnz || !mp) && plAnz >= minMiss) {
  4957. leastAnz = plAnz;
  4958. leastpl = pltext;
  4959. mp = true;
  4960. }
  4961. }
  4962. else if (!mp && (leastpl == "" || plAnz < leastAnz)) {
  4963. leastAnz = plAnz;
  4964. leastpl = pltext;
  4965. }
  4966. openCalls--;
  4967. TestMissionPlunder(msgs, i+1, trash);
  4968. }
  4969. });
  4970. return;
  4971. }
  4972. }
  4973. if (i >= msgs.length && trash) {
  4974. PG_setValue("allplunder", allplunder.join(";"));
  4975. if (leastAnz > 0) {
  4976. var pid = leastpl.split(",")[0].trim();
  4977. if (gesamt - gekauft < leastAnz/(mp?60:1))
  4978. leastAnz = (gesamt - gekauft)*(mp?60:1);
  4979. else if (mp && minMiss != 0)
  4980. leastAnz = Math.floor(leastAnz / 60) * 60;
  4981. HttpPost(stuff, "stuff_trash_form", ["plunder_id", pid, "trash_amount", leastAnz], function() { reload("CheckMission3"); });
  4982. }
  4983. }
  4984. }
  4985. function getGangStuff(categ, ix) {
  4986. if (openCalls > 0) {
  4987. window.setTimeout(getGangStuff, 500, categ, ix);
  4988. return;
  4989. }
  4990. if (ix < categ.length) {
  4991. var href = categ[ix].split('"')[0];
  4992. trace('Get ' + prothost + href, 2);
  4993. GM_xmlhttpRequest({method:"GET",
  4994. url: prothost + href,
  4995. onload:function(responseDetails) {
  4996. var msgs = responseDetails.responseText.split('"msglist"');
  4997. TestMissionPlunder(msgs, 1, false);
  4998. getGangStuff (categ, ix+1);
  4999. }
  5000. });
  5001. return;
  5002. }
  5003. PG_setValue("allplunder", allplunder.join(";"));
  5004. if (leastAnz > 0) {
  5005. var pid = leastpl.split(",")[0].trim();
  5006. if (gesamt - gekauft < leastAnz/(mp?60:1))
  5007. leastAnz = (gesamt - gekauft)*(mp?60:1);
  5008. else if (mp && minMiss != 0)
  5009. leastAnz = Math.floor(leastAnz / 60) * 60;
  5010. HttpPost(stuff, "stuff_trash_form", ["plunder_id", pid, "trash_amount", leastAnz], function() { reload("CheckMission3"); });
  5011. }
  5012. }
  5013. var stuff = responseDetails.responseText;
  5014. if (stuff.indexOf("/category/") == -1) {
  5015. var msgs = stuff.split('"msglist"');
  5016. var leastpl = "";
  5017. var leastAnz = 0;
  5018. var mp = false;
  5019. var minMiss = PGu_getValue("trashAllMissPlund", false)?0:60;
  5020. TestMissionPlunder(msgs, 1, true);
  5021. }
  5022. else {
  5023. var cat = stuff.split('id="plundertab')[1].split("</ul")[0].split('href="');
  5024. var leastpl = "";
  5025. var leastAnz = 0;
  5026. var mp = false;
  5027. var minMiss = PGu_getValue("trashAllMissPlund", false)?0:60;
  5028. getGangStuff(cat, 1);
  5029. }
  5030. }});
  5031. }});
  5032. return;
  5033. }
  5034. pos = HandleMission("kieztour", missionStart, missions);
  5035. if (pos >= 0)
  5036. return;
  5037. pos = HandleMission("strassenkampf", missionStart, missions);
  5038. }
  5039. });
  5040. }
  5041.  
  5042. function getSeks(counter) {
  5043. if (counter == done)
  5044. return 0;
  5045.  
  5046. var days = 0;
  5047. var cnt = counter.split(":");
  5048. if (cnt[0].indexOf(" ") != -1) {
  5049. days = Number(cnt[0].split(" ")[0]);
  5050. cnt[0] = cnt[0].split(" ").pop();
  5051. }
  5052. var seks = 0;
  5053. for (var i = 0; i < cnt.length; i++)
  5054. seks = seks * 60 + Number(cnt[i]);
  5055. return days * 86400 + seks;
  5056. }
  5057.  
  5058. function getvcounter () {
  5059. var vcounter = done;
  5060. if (document.getElementsByClassName("chest_counter").length == 0) {
  5061. var tbl = document.getElementsByTagName("table");
  5062. for (var i = tbl.length - 1; i > 0; i--)
  5063. if (tbl[i].className)
  5064. if (tbl[i].className == "cbox")
  5065. break;
  5066. var trs = tbl[i].getElementsByTagName("tr");
  5067. if (trs.length > 2) {
  5068. var span = trs[2].getElementsByTagName("span");
  5069. for (var i = 0; i < span.length; i++) {
  5070. if (span[i].id)
  5071. if (span[i].id.startsWith("counter")) {
  5072. vcounter = span[i].innerHTML;
  5073. if (vcounter.trim() == done0) // is the time 00:00 ?
  5074. vcounter = done;
  5075. break;
  5076. }
  5077. }
  5078. }
  5079. }
  5080. return getSeks(vcounter);
  5081. }
  5082.  
  5083. // ***********************************************************************************************
  5084. // ***********************************************************************************************
  5085. // Funktion sendet einen HTTP-Request via POST
  5086. // ***********************************************************************************************
  5087. // ***********************************************************************************************
  5088. function PostToHTTP(URL, pars, onsuccess) {
  5089. var params = [];
  5090. for (var i = 0; i < pars.length / 2; i++)
  5091. params[i] = pars[i*2] + "=" + encodeURIComponent(pars[i*2+1]);
  5092.  
  5093. GM_xmlhttpRequest({
  5094. method: 'POST',
  5095. url: URL,
  5096. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  5097. data: params.join("&"),
  5098. onload: function(responseDetails)
  5099. {
  5100. if (URL.indexOf('downfight.de') != -1 && responseDetails.status != 200) {
  5101. alert("Fehler beim Abruf der Daten von downfight.de: " + responseDetails.statusText + ". Bitte später noch einmal versuchen.");
  5102. return;
  5103. }
  5104. if (URL.indexOf('www.downfight.de') != -1) {
  5105. if (responseDetails.responseText.indexOf('unscharf.png') != -1) {
  5106. PostToHTTP(URL.replace('www.', ''), pars, onsuccess);
  5107. return;
  5108. }
  5109. }
  5110. if (typeof onsuccess == "function")
  5111. onsuccess(responseDetails.responseText);
  5112. else if (onsuccess != "")
  5113. alert(onsuccess);
  5114. }
  5115. });
  5116. }
  5117.  
  5118. // ***********************************************************************************************
  5119. // ***********************************************************************************************
  5120. // Funktion überprüft, ob die im GM-Key "keyname" gespeicherte Zeit länger als "interval"
  5121. // Minuten vorüber ist. Falls ja, wird true zurückgegeben und die neue Zeit gespeichert
  5122. // ***********************************************************************************************
  5123. // ***********************************************************************************************
  5124. function IsTimeToCheck(keyname, interval) {
  5125. var now = new Date();
  5126.  
  5127. if (isNaN(GM_getValue(keyname, "0")))
  5128. return true;
  5129. if ((Number(now) - Number(GM_getValue(keyname, "0"))) / 1000 / 60 >= interval) {
  5130. return true;
  5131. }
  5132. return false;
  5133. }
  5134.  
  5135. // ***********************************************************************************************
  5136. // Funktion ermittelt den Usernamen von df.de
  5137. // ***********************************************************************************************
  5138. function GetUserNameFromDFDE(content) {
  5139. if (content.indexOf('target="_blank') == -1)
  5140. return [0, ""];
  5141. var username = content.split('target="_blank')[1].split('">')[1].split('</a>')[0].split('<br>')[0].trim();
  5142. var userid = content.split("/profil/id:")[1].split("/")[0];
  5143. return [userid, username];
  5144. }
  5145.  
  5146. // **********************************************************************************
  5147. // **********************************************************************************
  5148. // Funktion wandelt einen HTML-Content in ein DOM um
  5149. // **********************************************************************************
  5150. // **********************************************************************************
  5151. function HTML2DOM(content) {
  5152.  
  5153. var dummyDiv = document.createElement('div');
  5154. dummyDiv.innerHTML = content;
  5155.  
  5156. return dummyDiv;
  5157. }
  5158.  
  5159. // ***********************************************************************************************
  5160. // Abrufen der DF-Liste von downfight.de
  5161. // ***********************************************************************************************
  5162. function updDFList() {
  5163. var DFusers = [];
  5164. function testDF(userid, username) {
  5165. updDFcount++;
  5166. trace("Statusprüfung User " + username, 2);
  5167. PostToHTTP(prothost + "/profil/id:" + userid + "/", [], function(content) {
  5168. if (content.split("button.attack_not")[1].split('name="form_friend"')[1].split("<div")[0].indexOf("/fight/?to=" + username) != -1) {
  5169. var pkt = Number(content.split('id="userbox"')[1].split('valign="middle"')[1].split("</td")[1].split(">").pop());
  5170. DFusers.push([userid, pkt, username]);
  5171. }
  5172. updDFcount--;
  5173. });
  5174. }
  5175. function setDFList() {
  5176. if (updDFcount > 0) {
  5177. trace("noch " + updDFcount + " Statusprüfung" + (updDFcount == 1?"":"en") + " offen.", 2);
  5178. setTimeout(setDFList, 500);
  5179. }
  5180. else {
  5181. DFusers.sort(function(a, b) { return a[1] - b[1]; });
  5182. for (var i = 0; i < DFusers.length; i++)
  5183. DFusers[i] = DFusers[i].join(":");
  5184. trace("DFList wird aktualisiert auf " + DFusers.join(";"), 2);
  5185. PGu_setValue("DFList", DFusers.join(";"));
  5186. PGu_delete("lastDF");
  5187. PGu_delete("nextDF");
  5188. PG_setValue("LastUpdateDF", (new Date()).getTime().toString());
  5189. trace("DFList aktualisiert auf " + DFusers.join(";"), 2);
  5190. }
  5191. }
  5192. PG_log("updDFList");
  5193. var town = ["HH", "B", "MU", "HR", "K", "SY", "VT", "AT", "ML"];
  5194. var DFTownCode = ["hamburg", "berlin", "muenchen", "reloaded", "koeln", "sylt", "vatikan", "atlantis", "malle"];
  5195. var ix = town.indexOf(TOWNEXTENSION);
  5196. if (ix < 0)
  5197. return;
  5198. if (IsTimeToCheck(TOWNEXTENSION + "LastUpdateDF", 10)) {
  5199. trace("DFList wird aktualisiert", 2);
  5200. var URL = window.location.protocol + "//www.downfight.de/?seite=downfight_" + DFTownCode[ix];
  5201. var Params = ['myatt', myATT, 'mydef', myDEF];
  5202. PostToHTTP(URL, Params, function(content) {
  5203. var doc = HTML2DOM(content);
  5204. for (var i = doc.getElementsByTagName("table").length - 1; i > 0; i--)
  5205. if (doc.getElementsByTagName("table")[i].innerHTML.indexOf("angriff.gif") != -1)
  5206. break;
  5207. var dftrs = doc.getElementsByTagName("table")[i].getElementsByTagName("tr")[1].getElementsByTagName("table")[0].getElementsByTagName("tr");
  5208. for (var i = 1; i <= dftrs.length - 2; i++) {
  5209. if (dftrs[i].getElementsByTagName("td").length < 10)
  5210. continue;
  5211. var user = GetUserNameFromDFDE(dftrs[i].getElementsByTagName("td")[4].innerHTML);
  5212. if (user[1] != "")
  5213. testDF(user[0], user[1]);
  5214. }
  5215. setTimeout(setDFList, 1000);
  5216. });
  5217. }
  5218. }
  5219.  
  5220. function submit(){
  5221.  
  5222. PG_log("submit");
  5223.  
  5224. if (updDFcount > 0) {
  5225. var lastupdDFc = PGu_getValue("lastupdDFc", 0);
  5226. if (lastupdDFc != updDFcount) {
  5227. PGu_setValue("lastupdDFc", updDFcount);
  5228. setTimeout(submit, 5000);
  5229. return;
  5230. }
  5231. PGu_delete("lastupdDFc");
  5232. }
  5233.  
  5234. if (document.getElementsByName("bottlecollect_pending").length == 0 && PGu_getValue("downfightauto", false)) {
  5235. var DFList = PGu_getValue("DFList", "");
  5236. if (DFList != "") {
  5237. var DFusers = DFList.split(";");
  5238. var lastDF = PGu_getValue("lastDF", "");
  5239. var ldf = 0;
  5240. if (lastDF != "")
  5241. for (var i = 0; i < DFusers.length; i++)
  5242. if (DFusers[i].split(":")[2] == lastDF) {
  5243. ldf = i + 1;
  5244. break;
  5245. }
  5246.  
  5247. if (ldf < DFusers.length) {
  5248. var user = DFusers[ldf].split(":");
  5249. PGu_setValue("nextDF", user[2]);
  5250. window.location.href = prothost + "/fight/?to=" + user[2];
  5251. return;
  5252. }
  5253. else
  5254. PGu_delete("DFList");
  5255. }
  5256. }
  5257.  
  5258. if(window.location.pathname.indexOf("/activities/") != -1 && window.location.pathname.indexOf("/crime/") == -1 && autoSubmit){
  5259.  
  5260. if (document.getElementsByClassName("chest_key_on").length > 0) {
  5261. var href = document.getElementsByClassName("chest_menu")[0].getElementsByClassName("chest_button")[0].href;
  5262. window.location.href = href;
  5263. }
  5264.  
  5265. if (getvcounter() != 0) {
  5266. PG_log("Verbrechen läuft");
  5267. var lastURL = PGu_getValue("AutoCollURL", "");
  5268. if (lastURL != "") {
  5269. PGu_setValue ("AutoCollURL", "");
  5270. window.location.replace( lastURL );
  5271. }
  5272. else {
  5273. PGu_setValue(nameTime, time);
  5274. PGu_setValue("AskedForCollect", 0);
  5275. checkInterval = window.setInterval(check,intervalTime);
  5276. }
  5277. return;
  5278. }
  5279.  
  5280. var lastCollectTime = PGu_getValue(nameLastCollectTime,0);
  5281. if (PGu_getValue("KiezTourAct", 0) == 1)
  5282. lastCollectTime = 0;
  5283.  
  5284. var evt = document.createEvent("HTMLEvents");
  5285. evt.initEvent("change", true, true);
  5286.  
  5287. var timeOptions = document.getElementsByName("time")[0];
  5288. if (!timeOptions)
  5289. refer();
  5290.  
  5291. if (lastCollectTime > 0) {
  5292. var options = timeOptions.innerHTML.split('value="');
  5293. if (options.length < lastCollectTime + 2)
  5294. lastCollectTime = 0;
  5295. else {
  5296. var minopt = Number(options[1].split('"')[0]);
  5297. var selopt = Number(options[lastCollectTime+1].split('"')[0]);
  5298. var nitrotime = lastCollectTime;
  5299. if (nitroCount >= 610 && selopt*30 >= nitroCount-30)
  5300. for (nitrotime--; nitrotime > 0; nitrotime--) {
  5301. selopt = Number(options[nitrotime+1].split('"')[0]);
  5302. if (selopt*30 <= nitroCount-30)
  5303. break;
  5304. }
  5305. var nextTime = PGu_getValue("NextStartkieztour", -1);
  5306. if (nextTime == -1)
  5307. lastCollectTime = 0;
  5308. else if (selopt*60 > nextTime && lastCollectTime > 0) {
  5309. for (var k = lastCollectTime - 1; k > 0; k--) {
  5310. selopt = Number(options[k+1].split('"')[0]);
  5311. if (selopt*60 <= nextTime)
  5312. break;
  5313. }
  5314. lastCollectTime = k;
  5315. }
  5316. if (nitrotime < lastCollectTime)
  5317. lastCollectTime = nitrotime;
  5318. }
  5319. }
  5320. timeOptions.selectedIndex = lastCollectTime;
  5321.  
  5322. timeOptions.dispatchEvent(evt);
  5323. timeOptions.addEventListener( "change",
  5324. function(){ PGu_setValue(nameLastCollectTime, document.getElementsByName("time")[0].selectedIndex);
  5325. timeOptionsCaptcha.selectedIndex = timeOptions.selectedIndex; },
  5326. true );
  5327.  
  5328. var timeOptionsCaptcha = timeOptions.cloneNode(true);
  5329. timeOptionsCaptcha.selectedIndex = timeOptions.selectedIndex;
  5330. timeOptionsCaptcha.addEventListener( "change",
  5331. function(){ PGu_setValue(nameLastCollectTime, document.getElementsByName("time")[0].selectedIndex);
  5332. timeOptions.selectedIndex = timeOptionsCaptcha.selectedIndex;},
  5333. true);
  5334.  
  5335. /* var captchaHolder = document.getElementById("holder");
  5336. var infoText = captchaHolder.insertBefore(document.createElement('p'),captchaHolder.getElementsByTagName("span")[1]);
  5337. infoText.innerHTML = strTime;
  5338. infoText.appendChild(timeOptionsCaptcha);
  5339. infoText.style.margin = "0px";
  5340. infoText.style.marginTop = "8px";
  5341. captchaHolder.getElementsByTagName("span")[1].style.marginTop = "-8px";
  5342. captchaHolder.getElementsByTagName("span")[1].style.marginLeft = "-10px";
  5343.  
  5344. var cancelButton = captchaHolder.getElementsByClassName("cancel")[0];
  5345. cancelButton.style.margin = "0px";
  5346. cancelButton.style.marginLeft = "10px";
  5347. infoText.appendChild(cancelButton);*/
  5348.  
  5349. var district = document.getElementsByTagName("table")[0].getElementsByTagName("tr")[2].getElementsByTagName("td")[0].innerHTML.split(":").pop().trim();
  5350. if (document.getElementsByName("bottlecollect_pending").length > 0 && (PGu_getValue("AutoCollect", false) || PGu_getValue("AutoCrime", false) && crimePic != "" && crimeFkt > 0)) {
  5351. PG_log(flaschentxt + " ausleeren");
  5352. var maxfill = PGu_getValue("maxfillbottle", 90);
  5353. if (maxfill > 0 && (TOWNEXTENSION == "VT" || TOWNEXTENSION == "AT")) {
  5354. var price = Number(document.getElementsByClassName("icon bottle")[0].innerHTML.split(">")[1].match(/\d+/));
  5355. trace('Get ' + prothost + '/activities/', 2);
  5356. GM_xmlhttpRequest({method:"GET", url: prothost + '/activities/', onload:function(responseDetails) {
  5357. var content = responseDetails.responseText;
  5358. var fass = content.split("Fassungsverm")[1].match(/[\d.,]+/);
  5359. trace('Get ' + prothost + '/stock/bottle/', 2);
  5360. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/bottle/', onload:function(responseDetails) {
  5361. var content = responseDetails.responseText;
  5362. var p = content.indexOf('id="hp_bar_blue"');
  5363. var p2 = content.lastIndexOf("<span", p);
  5364. var p3 = content.indexOf("</span", p);
  5365. var text = content.substring(p2, p3+10).split("</span>");
  5366. var bottles = Number(text[0].split("</strong>")[0].split("<strong>").pop().split(" ")[0]);
  5367. if (bottles > fass * maxfill / 100) {
  5368. var menge = Math.floor(bottles - fass * maxfill / 100);
  5369. getOverviewPage(mainFunc4, price, content);
  5370. }
  5371. }});
  5372. }});
  5373. }
  5374. var aftDist = PGu_getValue("aftDistrict", "0" + ";" + district).split(";");
  5375. trace("districts: " + district + "/" + aftDist, 8);
  5376. if (PGu_getValue("chooseDistrict", true) && aftDist[1] != district)
  5377. moveTo (aftDist[0], "", "");
  5378. else {
  5379. PGu_setValue("bottletime", 0);
  5380. trace("set timeout for bottle collect", 8);
  5381. window.setTimeout('if (document.getElementsByName("Submit2")[0].parentNode.name == "xycoords") document.getElementsByName("Submit2")[0].click(); else window.location.href=window.location.protocol + "//" + window.location.hostname + "/activities/";', 5000);
  5382. }
  5383. return;
  5384. }
  5385. var crimePic = PGu_getValue("AutoCrimePic", "");
  5386. var crimeFkt = PGu_getValue("AutoCrimeFkt", 0);
  5387. var crimeTO = "";
  5388. if (PGu_getValue("AutoCrime", false) && crimePic != "" && crimeFkt > 0) {
  5389. PG_log("Starte Verbrechen");
  5390. var crimeNr = PGu_getValue("AutoCrimeNr", -1);
  5391. if (crimeNr > 0) {
  5392. crimeTO = " if (document.getElementById('SCCheckbox').checked) window.location = window.location.protocol + '//' + window.location.hostname + '/activities/crime/?start_crime=" + crimeNr + "'";
  5393. PGu_setValue("AutoCrimeFkt", crimeFkt - 1);
  5394. }
  5395. else if (crimeNr == 0) {
  5396. trace('Get ' + prothost + '/activities/crime/', 2);
  5397. GM_xmlhttpRequest({method:"GET", url: prothost + '/activities/crime/', onload:function(responseDetails) {
  5398. var content = responseDetails.responseText;
  5399. var buttons = content.split("plunder_crime/");
  5400. for (var i = 1; i < buttons.length; i++) {
  5401. var crimep = buttons[i].split('"')[0];
  5402. if (crimePic == crimep) {
  5403. crimeNr = buttons[i].split("start_crime(")[1].split(")")[0];
  5404. PGu_setValue("AutoCrimeNr", crimeNr);
  5405. reload("Submit1");
  5406. break;
  5407. }
  5408. }
  5409. }});
  5410. }
  5411. else {
  5412. PGu_setValue("AutoCrimePic", "");
  5413. PGu_setValue("AutoCrime", false);
  5414. setTimeout(reload, 1000, "Submit2");
  5415. }
  5416. }
  5417. if (crimeTO != "")
  5418. setTimeout("if (document.getElementById('SCCheckbox'))" + crimeTO + ";", 2000); // fails often if to fast
  5419. else {
  5420. if (autoSubmit && PGu_getValue("AutoCollect", false)) {
  5421. var befDist = PGu_getValue("befDistrict", "0" + ";" + district).split(";");
  5422. var homeDist = PGu_getValue("homeDistrict", "0" + ";" + district).split(";");
  5423. if (PGu_getValue("chooseDistrict", true) && befDist[1] != district) {
  5424. PG_log("Ziehe nach " + befDist[1]);
  5425. moveTo (befDist[0], "", "");
  5426. return;
  5427. }
  5428. if (PGu_getValue("chooseDistrict", true) && homeDist[1] != district)
  5429. PGu_setValue("homeDist", homeDist[0]);
  5430. PG_log("Starte Sammeln für " + timeOptions.options[lastCollectTime].value + " Minuten in 3 Sekunden", 1);
  5431. setTimeout("if (document.getElementById('BCCheckbox')) if (document.getElementById('BCCheckbox').checked) document.getElementsByName('Submit2')[0].click();", 3000); // fails often if to fast
  5432. }
  5433. }
  5434. }
  5435. else {
  5436. PG_log("setInterval");
  5437. PGu_setValue(nameTime, time); //store time for each domain to prevent multiple run in same domain
  5438. checkInterval = window.setInterval(check,intervalTime);
  5439. }
  5440. }
  5441.  
  5442. function getTimers() {
  5443. var c=1;
  5444. var posci = document.getElementById("enemy_info")?0:-1;
  5445. if (posci != -1)
  5446. posci = document.getElementById("enemy_info").innerHTML.indexOf('enemy_counter_info');
  5447. if (posci != -1)
  5448. posci = document.getElementById("enemy_info").innerHTML.substr(posci+20,200).indexOf("counter");
  5449. if (posci != -1)
  5450. c=2;
  5451. crime = false;
  5452. try{
  5453. fcounter = document.getElementById("counter"+c).innerHTML;
  5454. counter = document.getElementById("counter"+(c+1)).innerHTML;
  5455. crime = document.getElementById("counter"+(c+1)).parentNode.innerHTML.split("counter(")[1].split(")")[0].split('"')[1].indexOf("crime") != -1;
  5456. if (counter.trim() == done0) // is the time 00:00 ?
  5457. counter = done;
  5458. }
  5459. catch(err){
  5460. }
  5461. trace("counter = " + counter + ", fcounter = " + fcounter, 9);
  5462. }
  5463.  
  5464. var RefreshTimer=0;
  5465. function check(){
  5466.  
  5467. PG_log("check");
  5468. var today = new Date();
  5469. if (document.getElementById("display"))
  5470. if (document.getElementById("display").getElementsByClassName("gamefield").length > 0)
  5471. if (PGu_getValue("memory", "") != "")
  5472. DoMemory(true);
  5473. if (today.getTime() < Number(PGu_getValue("checkNewMinigame", "0")) + 15000)
  5474. return;
  5475. function setPetCollectDay(day, status) {
  5476. var val = PGu_getValue("AutoPetCollectDay", "0000000");
  5477. if (val.length < 7)
  5478. val += "0000000".substr(val.length - 7);
  5479. day = Number(day);
  5480. val = val.substr(0, day) + (status?"1":"0") + val.substr(day + 1);
  5481. PGu_setValue("AutoPetCollectDay", val);
  5482. PGu_setValue("AutoPetCollect", val != "0000000");
  5483. return;
  5484. }
  5485.  
  5486. if (window.location.pathname.indexOf("/pet/") != -1) {
  5487. if (document.getElementById("submit_sets") && !document.getElementById("Checkbox1")) {
  5488. var divs = document.getElementsByClassName("pet_tab_help");
  5489. var newdiv = divs[divs.length-1].cloneNode(true);
  5490. newdiv.innerHTML = "<h1>Automatisches Einlösen</h1><span>Hier kannst Du einstellen, wann Deine Gegenstände automatisch eingelöst werden sollen.</span><div> </div>";
  5491. var newtdMo = document.createElement("td");
  5492. newtdMo.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  5493. newtdMo.innerHTML = '<input name="CheckboxMo" id="Checkbox1" type="checkbox"><span style="vertical-align: bottom">&nbsp;Montag&nbsp;</span>';
  5494. newdiv.appendChild(newtdMo);
  5495. var newtdDi = document.createElement("td");
  5496. newtdDi.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  5497. newtdDi.innerHTML = '<input name="CheckboxDi" id="Checkbox2" type="checkbox"><span style="vertical-align: bottom">&nbsp;Dienstag&nbsp;</span>';
  5498. newdiv.appendChild(newtdDi);
  5499. var newtdMi = document.createElement("td");
  5500. newtdMi.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  5501. newtdMi.innerHTML = '<input name="CheckboxMi" id="Checkbox3" type="checkbox"><span style="vertical-align: bottom">&nbsp;Mittwoch&nbsp;</span>';
  5502. newdiv.appendChild(newtdMi);
  5503. var newtdDo = document.createElement("td");
  5504. newtdDo.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  5505. newtdDo.innerHTML = '<input name="CheckboxDo" id="Checkbox4" type="checkbox"><span style="vertical-align: bottom">&nbsp;Donnerstag&nbsp;</span>';
  5506. newdiv.appendChild(newtdDo);
  5507. var newtdFr = document.createElement("td");
  5508. newtdFr.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  5509. newtdFr.innerHTML = '<input name="CheckboxFr" id="Checkbox5" type="checkbox"><span style="vertical-align: bottom">&nbsp;Freitag&nbsp;</span>';
  5510. newdiv.appendChild(newtdFr);
  5511. var newtdSa = document.createElement("td");
  5512. newtdSa.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  5513. newtdSa.innerHTML = '<input name="CheckboxSa" id="Checkbox6" type="checkbox"><span style="vertical-align: bottom">&nbsp;Samstag&nbsp;</span>';
  5514. newdiv.appendChild(newtdSa);
  5515. var newtdSo = document.createElement("td");
  5516. newtdSo.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  5517. newtdSo.innerHTML = '<input name="CheckboxSo" id="Checkbox0" type="checkbox"><span style="vertical-align: bottom">&nbsp;Sonntag&nbsp;</span>';
  5518. newdiv.appendChild(newtdSo);
  5519. var newtdvon = document.createElement("td");
  5520. newtdvon.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  5521. newtdvon.innerHTML = '<span style="vertical-align: top">&nbsp;von&nbsp;</span><input name="vonZeit" id="vonZeit" type="text" style="width:15px;">';
  5522. newdiv.appendChild(newtdvon);
  5523. var newtdbis = document.createElement("td");
  5524. newtdbis.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px');
  5525. newtdbis.innerHTML = '<span style="vertical-align: top">&nbsp;bis&nbsp;</span><input name="vonZeit" id="bisZeit" type="text" style="width:15px;"><span style="vertical-align: top">&nbsp;Uhr&nbsp;</span>';
  5526. newdiv.appendChild(newtdbis);
  5527. divs[divs.length-1].parentNode.appendChild(newdiv);
  5528. // Status setzen und Click-Handler hinzufügen
  5529. var val = PGu_getValue("AutoPetCollectDay", "0000000");
  5530. if (val.length < 7)
  5531. val += "0000000".substr(val.length - 7);
  5532. for (var i = 0; i < 7; i++) {
  5533. document.getElementById("Checkbox"+i).checked = (val[i] == "1");
  5534. document.getElementById("Checkbox"+i).addEventListener("click", function(event) {
  5535. setPetCollectDay(this.id.substr(-1), this.checked);
  5536. }, false);
  5537. }
  5538. document.getElementById("vonZeit").value = PGu_getValue("AutoPetCollectBegH", 11);
  5539. document.getElementById("vonZeit").addEventListener("change", function(event) {
  5540. var val = document.getElementById(this.id).value;
  5541. if (isNaN(val) || parseInt(val) < 0 || parseInt(val) > 23) {
  5542. alert("Bitte eine Zahl von 0 bis 23 eingeben");
  5543. document.getElementById(this.id).value = PGu_getValue("AutoCollectBegH", 11);
  5544. return false;
  5545. }
  5546. else
  5547. PGu_setValue("AutoPetCollectBegH", parseInt(val));
  5548. }, true);
  5549. document.getElementById("bisZeit").value = PGu_getValue("AutoPetCollectEndH", 12);
  5550. document.getElementById("bisZeit").addEventListener("change", function(event) {
  5551. var val = document.getElementById(this.id).value;
  5552. if (isNaN(val) || parseInt(val) < 0 || parseInt(val) > 23) {
  5553. alert("Bitte eine Zahl von 0 bis 23 eingeben");
  5554. document.getElementById(this.id).value = PGu_getValue("AutoCollectEndH", 12);
  5555. return false;
  5556. }
  5557. else
  5558. PGu_setValue("AutoPetCollectEndH", parseInt(val));
  5559. }, false);
  5560. }
  5561. }
  5562.  
  5563. if (RefreshTimer == 0) {
  5564. PG_log("set Timeout reload return 2");
  5565. fallback(0);
  5566. RefreshTimer = setTimeout(reload, PGu_getValue("RefreshInterval", 0) * 60000, "return 2");
  5567. }
  5568. else
  5569. PG_log("RefreshTimer aktiv: " + RefreshTimer);
  5570.  
  5571. if(PGu_getValue(nameTime) != time){ //script started somewhere else
  5572. clearInterval(checkInterval);
  5573. return 0;
  5574. }
  5575.  
  5576. getTimers();
  5577. var promille = GetPromille(document);
  5578. if (fcounter == done && counter == done && PGu_getValue("AutoCollect", false) || counter == done && PGu_getValue("AutoCrime", false) && PGu_getValue("AutoCrimeFkt", 0) > 0) {
  5579. if(window.location.pathname.indexOf("/activities/") != -1 && window.location.pathname.indexOf("/crime/") == -1){
  5580. if (document.getElementsByClassName("chest_key_on").length > 0) {
  5581. var href = document.getElementsByClassName("chest_menu")[0].getElementsByClassName("chest_button")[0].href;
  5582. window.location.href = href;
  5583. }
  5584.  
  5585. if (getvcounter() != 0) {
  5586. if (RefreshTimer == 0) {
  5587. PG_log("set Timeout reload return 3");
  5588. fallback(0);
  5589. RefreshTimer = setTimeout(reload, PGu_getValue("RefreshInterval", 0) * 60000, "return 3");
  5590. }
  5591. else
  5592. PG_log("RefreshTimer aktiv: " + RefreshTimer);
  5593. return; // do nothing, if a crime is planned
  5594. }
  5595.  
  5596. clearInterval(checkInterval); // stop script
  5597. trace("set timeout reload check1", 8);
  5598. setTimeout(reload, 2000, "check1");
  5599. } else {
  5600. trace('Get ' + prothost + '/activities/', 2);
  5601. GM_xmlhttpRequest({method:"GET", url: prothost + '/activities/', onload:function(responseDetails) {
  5602. var content = responseDetails.responseText;
  5603.  
  5604. var text = content.split("setupForm('/activities/bottle/'");
  5605. if (text.length > 1) {
  5606. text = text[1].split('>')[0].split(' ');
  5607. text = text[text.length-1];
  5608. if (text == "disabled") {
  5609. clearInterval(checkInterval); // stop script
  5610. checkInterval = window.setInterval(check,intervalTime*5);
  5611. }
  5612. else {
  5613. clearInterval(checkInterval); // stop script
  5614. setTimeout(refer, 1000);
  5615. }
  5616. }
  5617. /* deaktiviert !!
  5618. else if (PGu_getValue("AutoCollect", false)) {
  5619. var lastCollectTime = PGu_getValue(nameLastCollectTime, 0);
  5620. var timesplit = content.split('name="time"')[1].split("<option");
  5621. if (timesplit.length > lastCollectTime + 1)
  5622. var dauer = timesplit[lastCollectTime+1].split('value="')[1].split('"')[0];
  5623. else
  5624. var dauer = 10;
  5625. GM_xmlhttpRequest({method:'POST',
  5626. url: prothost + '/activities/bottle/',
  5627. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  5628. data: encodeURI('bottlecollect_pending=True'),
  5629. onload:function(responseDetails) {
  5630. var content = responseDetails.responseText;
  5631.  
  5632. GM_xmlhttpRequest({method:'POST',
  5633. url: prothost + '/activities/bottle/',
  5634. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  5635. data: encodeURI('sammeln='+dauer),
  5636. onload:function(responseDetails) {
  5637. var content = responseDetails.responseText;
  5638. var text = content.split("setupForm('/activities/bottle/'");
  5639. if (text.length > 1) {
  5640. text = text[1].split('>')[0].split(' ');
  5641. text = text[text.length-1];
  5642. }
  5643. if (text == "disabled") {
  5644. clearInterval(checkInterval); // stop script
  5645. checkInterval = window.setInterval(check,intervalTime*5);
  5646. }
  5647. }});
  5648. }});
  5649. } */
  5650. else {
  5651. clearInterval(checkInterval); // stop script
  5652. trace("set timeout to refer at 10000 secs", 8);
  5653. setTimeout(refer, 10000);
  5654. }
  5655. }});
  5656. }
  5657. }
  5658. else if (crime && getSeks(counter) < 60 && promille > 0) {
  5659. if (PGu_getValue("AutoCrimeURL", "") == "")
  5660. PGu_setValue ("AutoCrimeURL", location.toString());
  5661. if (!location.toString().endsWith("food/"))
  5662. window.location.href = prothost + "/stock/foodstuffs/food/";
  5663. else {
  5664. var breads = 0;
  5665. var items = document.getElementsByClassName("item_list");
  5666. for (var i = items.length - 1; i >= 0; i--) {
  5667. breads = Number(items[i].getElementsByTagName("tr")[0].getElementsByTagName("td")[1].innerHTML.split(">")[1].split(" ")[0]);
  5668. var effect = -Number(document.getElementsByName("promille")[i].value)/100;
  5669. if (i > 0 && effect > promille)
  5670. continue;
  5671. var id = document.getElementsByName("id")[i].value;
  5672. if (i == 0)
  5673. var nrofbreads = Math.min(Math.ceil(promille/effect), breads);
  5674. else
  5675. var nrofbreads = Math.min(Math.floor(promille/effect), breads);
  5676. // **********************************************************************************
  5677. // *** GM_XMLHTTPREQUEST *** POSTEN der Essensnutzung
  5678. // **********************************************************************************
  5679. trace("Post essen: " + id + "/" + nrofbreads, 2);
  5680. GM_xmlhttpRequest({method: 'POST',
  5681. url: prothost + '/stock/foodstuffs/use/',
  5682. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  5683. data: encodeURI('item=&promille=&id='+id+'&menge=' + nrofbreads),
  5684. onload: function(responseDetails) {
  5685. window.location.href = PGu_getValue("AutoCrimeURL", "");
  5686. PGu_setValue ("AutoCrimeURL", "");
  5687. }
  5688. });
  5689. break;
  5690. }
  5691. }
  5692. }
  5693. else if (PGu_getValue("RefreshInterval", 0) > 0) {
  5694. if (RefreshTimer == 0) {
  5695. PG_log("set Timeout reload check2");
  5696. fallback(0);
  5697. RefreshTimer = setTimeout(reload, PGu_getValue("RefreshInterval", 0) * 60000, "check2: reload nach " + PGu_getValue("RefreshInterval", 0) + " Minuten");
  5698. }
  5699. else
  5700. PG_log("RefreshTimer aktiv: " + RefreshTimer);
  5701. }
  5702. }
  5703.  
  5704. var msgDone1 = "Das " + pflaschen + "sammeln wurde beendet."; // "Collecting done";
  5705. var msgDone2 = "Klicke auf OK um die Aktionsseite zu " + unescape("%F6") + "ffnen."; // "Click ok to open actions-page";
  5706. function refer(){
  5707. var box = PGu_getValue("AutoCollect", false) || PGu_getValue("AutoCrime", false) && PGu_getValue("AutoCrimeFkt", 0) > 0;
  5708. if (box) { // check input field in Mails and SB
  5709. var f_text = document.getElementById("f_text");
  5710. if (f_text)
  5711. box = f_text.value == "";
  5712. }
  5713.  
  5714. if (!box && PGu_getValue("AskedForCollect", 0) < 3 && !PGu_getValue("AutoCollectKW", false)) {
  5715. box = window.confirm( msgDone1 + "\n" + msgDone2 );
  5716. PGu_setValue("AskedForCollect", PGu_getValue("AskedForCollect", 0) + 1);
  5717. }
  5718. if (box) {
  5719. PGu_setValue("AutoCollURL", location.toString());
  5720. window.location.href = prothost + "/activities/";
  5721. }
  5722. }
  5723.  
  5724. function reload(msg, url){
  5725. trace("Reload-Message: " + msg + "/" + window.location.toString() + (typeof(url) == "string" ? "/url: " + url : ""), 8);
  5726. if ((oldVersion || !autoSubmit) && !PGu_getValue("AutoCollectKW", false))
  5727. alert(msgDone1);
  5728. if (window.location.toString().indexOf("event") != -1 || window.location.toString().indexOf("livegame") != -1)
  5729. window.location.href = window.location.toString();
  5730. else if (typeof(url) == "string")
  5731. window.location.href = prothost + url;
  5732. else
  5733. window.location.href = prothost + "/activities/";
  5734. }
  5735.  
  5736. function enemyreload(){
  5737. var box = true;
  5738. // check input field in Mails and SB
  5739. var f_text = document.getElementById("f_text");
  5740. if (f_text)
  5741. box = f_text.value == "";
  5742.  
  5743. if (!box) {
  5744. box = window.confirm( msgAttackEnemy );
  5745. }
  5746. if (box) {
  5747. window.location.href = location.toString();
  5748. }
  5749. }
  5750.  
  5751. function Enemyattack(){
  5752. GM_xmlhttpRequest({
  5753. method:"POST",
  5754. url: prothost + '/enemies/start_fight/',
  5755. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  5756. data: encodeURI(''),
  5757. onload:function(responseDetails) {
  5758. enemyreload();
  5759. }
  5760. });
  5761. }
  5762.  
  5763. function DoPetCollect() {
  5764. trace('Get ' + prothost + '/pet/tab/collections/', 2);
  5765. GM_xmlhttpRequest({method:"GET", url: prothost + '/pet/tab/collections/', onload:function(responseDetails) {
  5766. var content = responseDetails.responseText;
  5767. var ptArray = [];
  5768. var uls = content.split("tabcontainer").pop().split('id="ul_');
  5769. for (var i = 1; i < uls.length; i++) {
  5770. var set = uls[i].split('">')[0];
  5771. var spans = uls[i].split("trade_in")[0].split("</span>");
  5772. var trade = uls[i].split("trade_in")[1].split("</div>")[0].split(">")[0].split("value=").pop();
  5773. var points = parseInt(trade.split(")")[0].split("(").pop());
  5774. var codeset = [];
  5775. var minanz = 99999;
  5776. for (var j = 0; j < spans.length - 1; j++) {
  5777. var code = spans[j].split("item_count_")[1].split('">')[0];
  5778. var anz = Number(spans[j].split(">").pop());
  5779. codeset.push([code, anz]);
  5780. if (anz < minanz)
  5781. minanz = anz;
  5782. }
  5783. if (minanz == 0)
  5784. continue;
  5785. for (var j = 0; j < ptArray.length; j++)
  5786. if (ptArray[j][2] <= points)
  5787. break;
  5788.  
  5789. ptArray.splice(j, 0, [set, codeset, points]);
  5790. }
  5791. for (var i = 0; i < ptArray.length; i++) {
  5792. var rew = ptArray[i][0];
  5793. var special = "";
  5794. if (rew.startsWith("special_")) {
  5795. special = "?special=true";
  5796. rew = rew.substr(8);
  5797. }
  5798. var minanz = 99999;
  5799. for (var j = 0; j < ptArray[i][1].length; j++) {
  5800. if (ptArray[i][1][j][1] < minanz)
  5801. minanz = ptArray[i][1][j][1];
  5802. }
  5803. if (minanz == 0)
  5804. continue;
  5805. for (var j = i; j < ptArray.length; j++)
  5806. for (var k = 0; k < ptArray[i][1].length; k++)
  5807. for (var kk = 0; kk < ptArray[j][1].length; kk++)
  5808. if (ptArray[i][1][k][0] == ptArray[j][1][kk][0]) {
  5809. ptArray[j][1][kk][1] -= minanz;
  5810. break;
  5811. }
  5812. trace('Get ' + prothost + '/pet/get_collection_reward/'+rew+"/", 2);
  5813. GM_xmlhttpRequest({
  5814. method: 'GET', url: prothost + '/pet/get_collection_reward/'+rew+"/"+minanz+"/"+special,
  5815. onload: function(responseDetails) {
  5816. }
  5817. });
  5818.  
  5819. window.setTimeout("window.location.href = '" + location.toString() + "'", 2000);
  5820. return;
  5821. }
  5822. }});
  5823. return;
  5824. }
  5825.  
  5826. function trace(txt, level) {
  5827. if (m_ownuserid == 0)
  5828. return;
  5829. if (typeof(level) == "undefined")
  5830. level = 9;
  5831. if (level > tracelevel || tracing)
  5832. return;
  5833. tracing = 1;
  5834. var datetime = new Date();
  5835. datetime = FormatDateTime(datetime) + "." + (datetime.getTime().toString()).substr(-3);
  5836. PGu_setValue("call" + traceln, datetime + ": " + txt);
  5837. if (traceln < maxtraceln)
  5838. traceln++;
  5839. else
  5840. traceln = 1;
  5841. PGu_setValue("callnr", traceln);
  5842. if (level == 1) {
  5843. PGu_setValue("hlcall" + hltraceln, datetime + ": " + txt);
  5844. if (hltraceln < maxhltraceln)
  5845. hltraceln++;
  5846. else
  5847. hltraceln = 1;
  5848. PGu_setValue("hlcallnr", hltraceln);
  5849. }
  5850. tracing = 0;
  5851. return;
  5852. }
  5853.  
  5854. function DoPetStartCheck(content, pos, leap, swtch)
  5855. {
  5856. PG_log("DoPetStartCheck(pos="+pos+",leap="+leap+",swtch="+swtch+")");
  5857. var today = new Date();
  5858.  
  5859. if (pos == 0) {
  5860. var petlock = "";
  5861. var petid = "";
  5862. var lockflg = false;
  5863. var nightflg = false;
  5864. var minaus = 1000;
  5865. var pos = content.indexOf('id="pet_kader');
  5866. for (var loop = 0; loop <= 2; loop++) {
  5867. pos = content.indexOf('div id="pet', pos+10);
  5868. if (pos == -1)
  5869. break;
  5870. var pos3 = content.indexOf('class="pethpbar', pos);
  5871. if (pos3 == -1)
  5872. continue;
  5873. if (content.substring(pos, pos3).indexOf("pet_featured") != -1)
  5874. continue;
  5875. var pos4 = content.indexOf('<h1>Ausdauer', pos3);
  5876. if (pos4 == -1)
  5877. continue;
  5878. var pethps = content.substr(pos3).split("</div")[0].split(">").pop().trim().split("/");
  5879. var ausd = content.substr(pos4, 500).split("</div>");
  5880. var petads = Number(ausd[3].trim());
  5881. var petids = content.substr(pos+8).split('"')[0];
  5882. if (PGu_getValue(petids+"Chb", false)) {
  5883. if (!lockflg && pethps[0] != pethps[1]) {
  5884. lockflg = true;
  5885. minaus = 1000;
  5886. }
  5887. else if (!lockflg || lockflg && pethps[0] == pethps[1] && minaus > petads) {
  5888. minaus = petads;
  5889. petid = petids;
  5890. lockflg = true;
  5891. }
  5892. }
  5893. else if (!lockflg && pethps[0] == pethps[1]) {
  5894. var night = false;
  5895. if (PGu_getValue("speztierend", "") == FormatDateDMY(today)) {
  5896. var pos5 = content.indexOf('class="daytime_advantage', pos);
  5897. if (pos5 != -1) {
  5898. var pos6 = content.indexOf("</div", pos5);
  5899. if (pos6 != -1)
  5900. night = (content.substring(pos5, pos6).indexOf("NIGHT_") != -1);
  5901. if (night)
  5902. trace("Nachtaktives Tier erkannt: " + petids, 2);
  5903. }
  5904. }
  5905. if (night)
  5906. if (!nightflg) {
  5907. minaus = petads;
  5908. petid = petids;
  5909. nightflg = true;
  5910. }
  5911. else {
  5912. if (minaus > petads) {
  5913. minaus = petads;
  5914. petid = petids;
  5915. }
  5916. }
  5917. else if (minaus > petads) {
  5918. minaus = petads;
  5919. petid = petids;
  5920. }
  5921. }
  5922. }
  5923.  
  5924. if (swtch) {
  5925. if (PGu_getValue("speztierendchk", "") != FormatDateDMY(today) ||
  5926. PGu_getValue("speztierend", "") == FormatDateDMY(today)) {
  5927. var href = content.split('id="plundertab"')[1].split('href="')[6].split('"')[0];
  5928. trace('Get ' + prothost + href, 2);
  5929. GM_xmlhttpRequest({method:"GET", url: prothost + href, onload:function(responseDetails) {
  5930. var cont2 = responseDetails.responseText;
  5931. if (PGu_getValue("speztierendchk", "") != FormatDateDMY(today)) {
  5932. var pos = cont2.indexOf("Das aktuelle Spezialtier wechselt am ");
  5933. if (pos != -1) {
  5934. var wdate = cont2.substr(pos).split(".</i>")[0].split(" ").pop();
  5935. PGu_setValue("speztierend", wdate);
  5936. PGu_setValue("speztierendchk", FormatDateDMY(today));
  5937. trace("Spezialtier wechselt am " + wdate, 2);
  5938. }
  5939. }
  5940. var costpos = cont2.lastIndexOf("petbusybar");
  5941. var petcost = -1;
  5942. if (costpos != -1) {
  5943. var pos = cont2.indexOf('value="', costpos);
  5944. if (pos != -1)
  5945. petcost = cont2.substr(pos).split('"')[1];
  5946. if (petcost.indexOf("Leinen") != -1) {
  5947. petcost = Number(petcost.match(/\d+/)[0]);
  5948. trace("Spezialtier kostet " + petcost + " Leinen.", 4);
  5949. }
  5950. else
  5951. petcost = -1;
  5952. PGu_setValue("speztiercost", petcost);
  5953. }
  5954. }});
  5955. }
  5956.  
  5957. trace((petid==""?"Kein Tier":petid) + " kann getauscht werden.", 2);
  5958. if (petid != "") {
  5959. var href = content.split('id="plundertab"')[1].split('href="')[2].split('"')[0];
  5960. trace('Get ' + prothost + href, 2);
  5961. GM_xmlhttpRequest({method:"GET", url: prothost + href, onload:function(responseDetails) {
  5962. var cont2 = responseDetails.responseText;
  5963. var slotcost = -1;
  5964. var pos = cont2.indexOf("slot_disabled");
  5965. if (pos != -1)
  5966. pos = cont2.indexOf("</div", pos);
  5967. if (pos != -1 && cont2.substr(pos-1, 1) != "+")
  5968. slotcost = 0;
  5969. else if (pos != -1) {
  5970. var unlockpos = cont2.indexOf("unlockslot_submit", pos);
  5971. if (unlockpos != -1) {
  5972. pos = cont2.indexOf('value="', unlockpos);
  5973. if (pos != -1)
  5974. slotcost = Number(cont2.substr(pos).split('"')[1].match(/\d+/)[0]);
  5975. }
  5976. }
  5977. trace("Nächster Stallplatz kostet " + slotcost + " Leinen.", 4);
  5978. PGu_setValue("slotcost", slotcost);
  5979. var pfpos = cont2.indexOf('pet_featured');
  5980. if (pfpos != -1) {
  5981. var pos2 = cont2.lastIndexOf('id="pet', pfpos);
  5982. var petid2 = cont2.substr(pos2+4).split('"')[0];
  5983. var petname = cont2.substr(pos2).split('class="petnametooltip"')[0].split(">").pop().split("<")[0].trim();
  5984. if (PGu_getValue("speztier", "") != petname) {
  5985. trace("Spezialtier gewechselt auf " + petname, 1);
  5986. PGu_setValue(petid2+"Chb", false);
  5987. PGu_delete("speztierendchk");
  5988. PGu_setValue("speztier", petname);
  5989. }
  5990. if(!window.location.pathname.endsWith("/pet/")){
  5991. window.location.href = prothost + '/pet/';
  5992. return;
  5993. }
  5994. if (document.getElementById("plundertab").getElementsByTagName("a")[1].className != "selected") {
  5995. document.getElementById("plundertab").getElementsByTagName("a")[1].click();
  5996. window.setTimeout(DoPetStartCheck, 1000, content, 0, false, true);
  5997. return;
  5998. }
  5999. var pswitch = document.getElementById("petswitchmenu_" + petid2.substr(3));
  6000. if (!pswitch) {
  6001. window.setTimeout(DoPetStartCheck, 1000, content, 0, false, swtch);
  6002. return;
  6003. }
  6004. var td = pswitch.getElementsByTagName("a");
  6005. for (var i = 0; i < td.length; i++) {
  6006. if (td[i].href.indexOf("("+petid.substr(3)+","+petid2.substr(3)+")") == -1)
  6007. continue;
  6008. PGu_setValue(petid2+"Chb", false);
  6009. trace(petid + " --> Stall, " + petid2 + " --> Kader", 1);
  6010. td[i].click();
  6011. return;
  6012. }
  6013. }
  6014. else {
  6015. var lis = content.split('id="plundertab"')[1].split('<li');
  6016. for (var i = 8; i < lis.length; i++)
  6017. if (lis[i].indexOf("leine.png") != -1) {
  6018. var lines = Number(lis[i].split("<img")[1].split(">").pop().trim());
  6019. var petcost = PGu_getValue("speztiercost", -1);
  6020. var slotcost = PGu_getValue("slotcost", -1);
  6021. if (petcost > 0 && slotcost >= 0 && petcost + slotcost <= lines) {
  6022. trace("Spezialtier kann gekauft werden: " + petcost + "/" + slotcost + "/" + lines, 4);
  6023. if(!window.location.pathname.endsWith("/pet/")){
  6024. window.location.href = prothost + '/pet/';
  6025. return;
  6026. }
  6027. if (slotcost > 0) {
  6028. if (document.getElementById("plundertab").getElementsByTagName("a")[1].className != "selected") {
  6029. document.getElementById("plundertab").getElementsByTagName("a")[1].click();
  6030. window.setTimeout(DoPetStartCheck, 1000, content, 0, false, true);
  6031. return;
  6032. }
  6033. trace("Stallplatz wird gekauft.", 1);
  6034. document.getElementById("unlockslot_submit").click();
  6035. return;
  6036. }
  6037. if (document.getElementById("plundertab").getElementsByTagName("a")[5].className != "selected") {
  6038. document.getElementById("plundertab").getElementsByTagName("a")[5].click();
  6039. window.setTimeout(DoPetStartCheck, 1000, content, 0, false, true);
  6040. return;
  6041. }
  6042. trace("Spezialtier wird gekauft.", 1);
  6043. document.getElementById("tabcontainer").getElementsByClassName("petbutton")[0].click();
  6044. return;
  6045. break;
  6046. }
  6047. }
  6048. }
  6049. DoPetStartCheck(content, 0, false, false);
  6050. return;
  6051. }});
  6052. return;
  6053. }
  6054. }
  6055.  
  6056. pos = content.indexOf('class="plunder_boost"');
  6057. if (pos != -1) {
  6058. pos = content.lastIndexOf('class="petname', pos);
  6059. pos = content.lastIndexOf('id="pet', pos);
  6060. if (DoPetStartCheck(content, pos, true, swtch))
  6061. return;
  6062. }
  6063.  
  6064. pos = content.indexOf('pet_featured');
  6065. if (pos == -1 || PGu_getValue("speztierend", "") == FormatDateDMY(today))
  6066. petlock = petid;
  6067. trace((petlock == ""?"Kein Tier":petlock) + " ist gesperrt.", 2);
  6068.  
  6069. while (pos != -1) {
  6070. var pos2 = content.lastIndexOf('div id="pet', pos);
  6071. var pos3 = content.indexOf('div id="pet', pos);
  6072. if (pos3 == -1)
  6073. pos3 = content.length;
  6074. var contpet = content.substring(pos2, pos3);
  6075. pos3 = contpet.indexOf('class="petname');
  6076. var petname = contpet.substr(pos3).split('class="petnametooltip"')[0].split(">").pop().split("<")[0].trim();
  6077. if (PGu_getValue("speztier", "") != petname) {
  6078. //alert(">"+PGu_getValue("speztier", "")+"</>" + petname + "<");
  6079. trace("Spezialtier gewechselt auf " + petname, 1);
  6080. pos2 = contpet.indexOf('"', 8);
  6081. var petid = contpet.substring(8, pos2);
  6082. PGu_setValue(petid+"Chb", false);
  6083. PGu_delete("speztierendchk");
  6084. PGu_delete("speztierend");
  6085. PGu_setValue("speztier", petname);
  6086. }
  6087. pos2 = contpet.indexOf("daytime_advantage", pos3);
  6088. if (pos2 != -1) {
  6089. var adv = contpet.substr(pos2).split("</div")[0];
  6090. var pos3 = adv.indexOf("NIGHT_");
  6091. if (pos3 == -1)
  6092. pos3 = adv.indexOf("DAY_");
  6093. if (pos3 != -1)
  6094. pos3 = adv.indexOf("_", pos3) + 1;
  6095. var petstart = (pos3 == -1 || pos3 != -1 && adv.substr(pos3,4) == "True" || today.getHours() > 17);
  6096. if (!petstart && petname == PGu_getValue("speztier", "") && PGu_getValue("speztierend", "") == FormatDateDMY(today)) {
  6097. pos3 = contpet.indexOf('class="pethpbar');
  6098. var hp0 = 0;
  6099. if (pos3 != -1) {
  6100. var hp = contpet.substr(pos3).split("</div")[0].split(">").pop().split("/");
  6101. hp0 = Number(hp[0]);
  6102. }
  6103. if (hp0 > 10) {
  6104. trace("Start Spezialtier wegen Spezialtierwechsel", 1);
  6105. petstart = true;
  6106. }
  6107. }
  6108. if (petstart)
  6109. if (DoPetStartCheck(content, pos, true, swtch))
  6110. return;
  6111. }
  6112. pos = content.indexOf('pet_featured', pos+1);
  6113. }
  6114.  
  6115. var contupper = content.split('class="clearpet"')[0];
  6116. var dayfalse = 0;
  6117. var maxhp = 0;
  6118. for (loop = 0; loop <= 5; loop++) {
  6119. if (loop == 3) {
  6120. pos = contupper.indexOf('pet_featured');
  6121. while (pos != -1) {
  6122. pos = contupper.indexOf('class="petname', pos+1);
  6123. if (pos == -1)
  6124. break;
  6125. var pos2 = contupper.indexOf("daytime_advantage", pos);
  6126. if (pos2 != -1) {
  6127. var adv = contupper.substr(pos2).split("</div")[0];
  6128. var pos3 = adv.indexOf("NIGHT_");
  6129. if (pos3 == -1)
  6130. pos3 = adv.indexOf("DAY_");
  6131. if (pos3 != -1)
  6132. pos3 = adv.indexOf("_", pos3) + 1;
  6133. if (pos3 == -1 || pos3 != -1 && adv.substr(pos3,4) == "True" || today.getHours() > 17)
  6134. if (DoPetStartCheck(contupper, pos, false, swtch))
  6135. return;
  6136. }
  6137. pos = contupper.indexOf('pet_featured', pos + 1);
  6138. }
  6139. }
  6140. if (loop%3 == 2)
  6141. if (today.getHours() >= 5 && today.getHours() <= 17 || dayfalse == 0)
  6142. continue;
  6143. else
  6144. pos = dayfalse;
  6145. else
  6146. pos = contupper.indexOf('id="pet_kader');
  6147.  
  6148. while (true) {
  6149. var pos2 = contupper.indexOf('div id="pet', pos);
  6150. if (pos2 == -1)
  6151. break;
  6152. var petid = contupper.substr(pos2+8).split('"')[0];
  6153.  
  6154. pos = pos2 + 20;
  6155. if (PGu_getValue(petid+"Chb", false) || petid == petlock)
  6156. continue;
  6157.  
  6158. pos2 = contupper.indexOf("daytime_advantage", pos);
  6159. if (pos2 != -1) {
  6160. var pos3 = content.indexOf('class="pethpbar', pos);
  6161. if (pos3 == -1)
  6162. return false;
  6163. var hp = content.substr(pos3).split("</div")[0].split(">").pop().split("/");
  6164. var adv = contupper.substr(pos2).split("</div")[0];
  6165. if (dayfalse === 0 && adv.indexOf("DAY_False") != -1) {
  6166. dayfalse = pos - 20;
  6167. continue;
  6168. }
  6169. var pos3 = adv.indexOf("NIGHT_");
  6170. if (pos3 == -1)
  6171. pos3 = adv.indexOf("DAY_");
  6172. if (pos3 != -1)
  6173. pos3 = adv.indexOf("_", pos3) + 1;
  6174. if (loop == 0 && pos3 != -1 && adv.substr(pos3,4) == "True" || loop == 1 && pos3 == -1 || loop%3 == 2)
  6175. maxhp = Math.max(maxhp, Number(hp[0]));
  6176. else if (loop >= 3 && Number(hp[0]) != maxhp)
  6177. continue;
  6178. if (loop%3 == 0 && pos3 != -1 && adv.substr(pos3,4) == "True" || loop%3 == 1 && pos3 == -1 || loop%3 == 2)
  6179. if (DoPetStartCheck(content, pos, (loop >= 3), swtch))
  6180. return;
  6181. }
  6182. }
  6183. }
  6184. return;
  6185. }
  6186.  
  6187. var pos3 = content.lastIndexOf('div id="pet', pos);
  6188. if (pos3 == -1)
  6189. return false;
  6190. var petid = content.substr(pos3).split('id="')[1].split('"')[0];
  6191.  
  6192. var pos2 = content.indexOf('class="pethpbar', pos3);
  6193. if (pos2 == -1)
  6194. return false;
  6195.  
  6196. var contpet = content.substring(pos3, pos2);
  6197. if (PGu_getValue(petid+"Chb", false))
  6198. if (contpet.indexOf("pet_featured") == -1)
  6199. return false;
  6200.  
  6201. var hp = content.substr(pos2).split("</div")[0].split(">").pop().split("/");
  6202. var seks = 0;
  6203. var xpboost = 0;
  6204.  
  6205. pos2 = contpet.split('class="petimg')[0].indexOf('class="plunder_boost');
  6206. if (pos2 != -1) {
  6207. pos3 = contpet.indexOf(' % Erfahrung', pos2);
  6208. if (pos3 != -1) {
  6209. xpboost = Number(contpet.substring(pos2, pos3).match(/\d+/g).pop());
  6210. pos3 = contpet.indexOf('counter(', pos2);
  6211. var strseks = contpet.substr(pos3).match(/\d+/)[0];
  6212. if (!isNaN(strseks)) {
  6213. seks = Number(strseks);
  6214. if (seks < 603)
  6215. seks = 0;
  6216. }
  6217. }
  6218. }
  6219.  
  6220. var xpadd = 0;
  6221. pos2 = contpet.indexOf('class="plunder_equipped"');
  6222. if (pos2 != -1) {
  6223. pos3 = contpet.indexOf('class="padv"', pos2);
  6224. if (pos3 != -1) {
  6225. pos2 = pos3;
  6226. pos3 = contpet.indexOf('</ul>', pos2);
  6227. pos3 = contpet.substring(pos2, pos3).indexOf(' Erfahrung');
  6228. if (pos3 != -1)
  6229. xpadd = Number(contpet.substr(pos2, pos3).match(/\d+/g).pop());
  6230. }
  6231. }
  6232. pos2 = contpet.indexOf('class="petxpbar"');
  6233. if (pos2 == -1)
  6234. return false;
  6235. var hp0 = Number(hp[0]);
  6236. if (xpboost > 0)
  6237. if (seks == 0)
  6238. xpboost = 0;
  6239. else if (seks < hp0 * 30)
  6240. hp0 = Math.floor(seks / 30);
  6241.  
  6242. if (hp0 <= 10)
  6243. return false;
  6244.  
  6245. var maxTime = 10;
  6246. pos3 = contpet.indexOf('Max. Level', pos2);
  6247. if (pos3 == -1) {
  6248. pos3 = contpet.indexOf(' Erfahrung', pos2);
  6249. if (pos3 == -1)
  6250. return false;
  6251. var xp = contpet.substring(pos2, pos3).match(/\d+/g);
  6252.  
  6253. pos3 = contpet.lastIndexOf('Level', pos2);
  6254. if (pos3 == -1)
  6255. return false;
  6256.  
  6257. var lvl = Number(contpet.substring(pos3, pos2).match(/\d+/g).pop());
  6258. var pts10 = Math.floor((lvl + 4) * 30 * ((xpboost + xpadd) / 100 + 1.2) + 0.5);
  6259. if (hp0 < 70)
  6260. maxTime = 10;
  6261. else {
  6262. maxTime = Math.floor((hp0 - 10) / 60) * 30;
  6263. if (maxTime == 150)
  6264. maxTime = 120;
  6265. }
  6266. var ptsNL = (lvl >= 49 ? 0 : (lvl + 1) * (300 + (lvl + 1) * 20));
  6267. var ptsMaxT = Math.floor((lvl + 4) * 3 * maxTime * ((xpboost + xpadd) / 100 + 1.2) + 0.5) - (Number(xp[1]) - Number(xp[0]));
  6268. //alert(hp+"/"+ptsNL+"/"+maxTime+"/"+xp);
  6269.  
  6270. //var ptshp = Math.floor((lvl + 4) * 3 * Number(hp[0]) / 2 * ((1.1 + xpadd) / 100 + 1.2) + 0.5);
  6271. //if (Number(xp[0]) + pts10 >= Number(xp[1]) || Number(xp[0]) + ptshp >= Number(xp[1]) && xpboost == 0)
  6272. if (Number(xp[0]) + pts10 < Number(xp[1]))
  6273. maxTime = 10;
  6274. else if (!leap && contpet.indexOf("pet_featured") == -1)
  6275. if (ptsMaxT < ptsNL / 2 && xpboost == 0)
  6276. return false;
  6277. }
  6278.  
  6279. var id = Number(content.substr(pos).split('class="petspec')[1].split('id="')[1].split('"')[0]);
  6280.  
  6281. if(!window.location.pathname.endsWith("/pet/")){
  6282. window.location.href = prothost + '/pet/';
  6283. return true;
  6284. }
  6285.  
  6286. if (document.getElementById("plundertab").getElementsByTagName("a")[0].className != "selected") {
  6287. document.getElementById("plundertab").getElementsByTagName("a")[0].click();
  6288. window.setTimeout('window.location.href = ' + prothost + '/pet/";', 3000);
  6289. return true;
  6290. }
  6291.  
  6292. pos2 = content.indexOf('id="start_form"', pos);
  6293. if (pos2 == -1) {
  6294. window.setTimeout(DoPetStartCheck, 1000, content, pos, false, swtch);
  6295. return true;
  6296. }
  6297.  
  6298. pos = pos2 - 20;
  6299. pos2 = content.indexOf("</form", pos);
  6300. if (pos2 == -1)
  6301. return false;
  6302. var form = content.substring(pos, pos2);
  6303.  
  6304. var pethp = Number(form.split('id="s_' + petid)[1].split("choose_pet(")[1].split(")")[0].split(",").pop().trim());
  6305. if (pethp <= maxTime)
  6306. return false;
  6307.  
  6308. var areas = form.split('id="area_id"')[1].split("</select")[0].split('option value="');
  6309. var g = nb = 0;
  6310. var good = [3, 1, 2];
  6311. var often = [0];
  6312. for (var k = 2; k < areas.length; k++) {
  6313. var areadata = areas[k].split('"')[0].split(",");
  6314. if (areadata[2] == good[id-1])
  6315. g = areadata[0];
  6316. else if (areadata[2] == id)
  6317. nb = areadata[0];
  6318. often[areadata[0]] = areadata[2];
  6319. }
  6320. if (g == 0)
  6321. g = nb;
  6322. if (g == 0 && xpboost > 0)
  6323. g = 3;
  6324. if (g > 0) {
  6325. unsafeWindow.selectMap(g);
  6326. unsafeWindow.change_path(maxTime);
  6327. document.getElementsByName("route_length")[0].value = maxTime;
  6328. document.getElementById("s_"+petid).click();
  6329. savePetStart();
  6330. HttpPost(document.getElementById("content").innerHTML, "start_form", [], function() {
  6331. reload ("PetStart", "/pet/");
  6332. return;
  6333. });
  6334. return true;
  6335. }
  6336.  
  6337. return false;
  6338. }
  6339.  
  6340. function Leckerli(params, petid, leckerli, petname) {
  6341. params[1] = params[1].trim();
  6342. params.push(params.shift().split("'")[1]);
  6343. params.push(petid.substr(3));
  6344. trace("Leckerli " + leckerli + " für Haustier " + petname + (params[1] == 'equip'?" angelegt":" benutzt"), 1);
  6345. GM_xmlhttpRequest({method:"GET", url: prothost + '/pet/plunder/' + params.join("/") + '/', onload:function(responseDetails) {
  6346. reload ("Leckerli", "/pet/");
  6347. }});
  6348. };
  6349.  
  6350. function DoPetFinishCheck(content, swtch)
  6351. {
  6352. PG_log("DoPetFinishCheck(swtch="+swtch+")");
  6353. var pos2 = content.indexOf('id="pet_roam_time"');
  6354. if (pos2 != -1) {
  6355. var count = content.substr(pos2).split("</script")[0].split('counter(');
  6356. if (count.length > 1) {
  6357. count = Number(count[1].split(",")[0]);
  6358. if (count < 2)
  6359. count = 2;
  6360. trace("Timeout is " + count + " seconds", 8);
  6361. window.setTimeout(reload, count*1000, "DoPetFinishCheck1", "/pet/");
  6362. return;
  6363. }
  6364.  
  6365. if (content.substr(pos2+19, 6) == "Fertig") {
  6366. var pos = content.lastIndexOf('div id="pet', pos2);
  6367. var pos4 = content.indexOf('class="ov_container"', pos);
  6368. if (pos4 < 0) {
  6369. reload("DoPetFinishCheck", "/pet/");
  6370. return;
  6371. }
  6372. var pos3 = content.substring(pos, pos2).indexOf('class="plunder_equipped"');
  6373. var leckerlist = ['diamant', 'gold', 'silber', 'bronze'];
  6374. var fnplunder = "";
  6375. if (pos3 != -1) {
  6376. pos3 += pos;
  6377. var fnpos = content.substr(pos3).split('class="petimg"')[0].indexOf("fressnapf_");
  6378. fnplunder = content.substr(pos3+fnpos+10).split(".")[0];
  6379. pos3 = leckerlist.indexOf(fnplunder);
  6380. }
  6381. if (swtch) {
  6382. var href = content.split('id="plundertab"')[1].split('href="')[4].split('"')[0];
  6383. trace('Get ' + prothost + href, 2);
  6384. GM_xmlhttpRequest({method:"GET", url: prothost + href, onload:function(responseDetails) {
  6385. var cont2 = responseDetails.responseText;
  6386. for (var fnpos = 0; fnpos < leckerlist.length; fnpos++)
  6387. if (cont2.indexOf("fressnapf_"+leckerlist[fnpos]) != -1)
  6388. break;
  6389. if (fnpos < leckerlist.length && (pos3 == -1 || fnpos < pos3)) {
  6390. var petid = content.substr(pos).split('id="')[1].split('"')[0];
  6391. var petname = content.substr(pos).split('class="petnametooltip"')[0].split(">").pop().split("<")[0].trim();
  6392. var params = cont2.substr(cont2.indexOf("fressnapf_"+leckerlist[fnpos])).split("showTargetSelector(")[1].split(')')[0].split(", ");
  6393. Leckerli(params, petid, "fressnapf_"+leckerlist[fnpos], petname);
  6394. return;
  6395. }
  6396. DoPetFinishCheck(content, false);
  6397. }});
  6398. return;
  6399. }
  6400. var pos5 = content.indexOf("Dein Tier hat au", pos4);
  6401. if (pos5 < 0)
  6402. if (expertMode)
  6403. alert(content.substr(pos4));
  6404. else
  6405. return;
  6406. var beute = Number(content.substr(pos5).match(/[\d,.]+/)[0].replace(/[.,]/g, "")) / 100;
  6407. trace("Haustier Beute: " + beute, 1);
  6408. if (content.substr(pos, pos2-pos).indexOf('class="plunder_boost"') != -1 ||
  6409. content.substr(pos, pos2-pos).indexOf('Max. Level') != -1) {
  6410. trace('Get ' + prothost + '/pet/get_roam_award/', 2);
  6411. GM_xmlhttpRequest({method:"GET", url: prothost + '/pet/get_roam_reward/', onload:function(responseDetails) {
  6412. reload("pet_reward", "/pet/");
  6413. }});
  6414. }
  6415. else {
  6416. if (GetMoney(document) + beute > maxFass) {
  6417. trace("Beute passt nicht in Behälter", 1);
  6418. return;
  6419. }
  6420. pos2 = content.substr(pos).indexOf('class="pethpbar');
  6421. if (pos2 != -1) {
  6422. var hp = content.substr(pos+pos2).split("</div")[0].split(">").pop().split("/");
  6423. var hp0 = Number(hp[0]);
  6424. var maxTime = 10;
  6425. if (hp0 >= 70) {
  6426. maxTime = Math.floor((hp0 - 10) / 60) * 30;
  6427. if (maxTime == 150)
  6428. maxTime = 120;
  6429. }
  6430. pos2 = content.substr(pos).indexOf('class="petxpbar"');
  6431. if (pos2 != -1) {
  6432. var pos3 = content.substr(pos+pos2).indexOf(' Erfahrung');
  6433. if (pos3 != -1) {
  6434. var xp = content.substr(pos+pos2, pos3).match(/\d+/g);
  6435. pos3 = content.lastIndexOf('Level', pos+pos2);
  6436. if (pos3 != -1) {
  6437. var lvl = Number(content.substr(pos3, pos+pos2-pos3).match(/\d+/g).pop());
  6438. var pts = Math.floor((lvl + 4) * 3 * 1.2 * maxTime + 0.5);
  6439. trace('Get ' + prothost + '/pet/tab/action/', 2);
  6440. GM_xmlhttpRequest({method:"GET", url: prothost + '/pet/tab/action/', onload:function(responseDetails) {
  6441. var actcont = responseDetails.responseText;
  6442. var hs = actcont.indexOf('class="hs_shell"');
  6443. var trs = actcont.substr(hs).split("<tr");
  6444. var xp1 = Number(trs[2].split("<td>")[1].split("<")[0].split(" ").pop());
  6445. if (trs[4].split("<td>").length > 1)
  6446. var xp2 = Number(trs[4].split("<td>")[1].split("<")[0].split(" ").pop());
  6447. else
  6448. var xp2 = 0;
  6449. for (var k = 5; k < trs.length; k++)
  6450. if (trs[k].indexOf("roam_value_xp") != -1)
  6451. var xpg = Number(trs[k].split('roam_value_xp')[1].split("</td")[0].split(" ").pop());
  6452. else if (trs[k].indexOf("(Basis)") != -1) {
  6453. var ti = Number(trs[k].split("</td")[0].split(" ").pop());
  6454. break;
  6455. }
  6456. var ptsNL = (lvl + 1) * (300 + (lvl + 1) * 20);
  6457. var ptsMaxT = Math.floor((lvl + 4) * 3 * maxTime * 1.2 + 0.5);
  6458. var pts2 = xpg - (Number(xp[1]) - Number(xp[0]));
  6459. var timNL = Math.ceil((ptsNL - pts2) / ((lvl + 4 ) * 3 * 1.2) / 10) * 10;
  6460. trace("Zeit für nächstes Level: " + timNL + " Minuten", 2);
  6461. var pospf = content.indexOf("pet_featured");
  6462. if (pospf != -1) {
  6463. var poshp = content.substr(pospf).indexOf('class="pethpbar');
  6464. if (poshp != -1) {
  6465. var hp2 = content.substr(pospf+poshp).split("</div")[0].split(">").pop().split("/");
  6466. if (Number(hp2[0]) > 10 && ti < 60)
  6467. PGu_setValue("noleckerli", 1);
  6468. }
  6469. }
  6470. var petid = content.substr(pos).split('id="')[1].split('"')[0];
  6471. if (PGu_getValue("noleckerli", 0) == 0 && (ti >= 60 && lvl >= 30 || timNL >= Math.floor(Number(hp[1]) / 2 / 10) * 10) && lvl < 50 && !PGu_getValue(petid+"Chb", false)) {
  6472. trace('Get ' + prothost + '/pet/tab/items/', 2);
  6473. GM_xmlhttpRequest({method:"GET", url: prothost + '/pet/tab/items/', onload:function(responseDetails) {
  6474. var itemtable = responseDetails.responseText.split("<table")[1].split("</table")[0].split("<tr");
  6475. var maxxpboost = 0;
  6476. for (var k = 1; k < itemtable.length; k++) {
  6477. var xppos = itemtable[k].indexOf("% Erfahrung");
  6478. if (xppos == -1)
  6479. continue;
  6480. var xpplus = Number(itemtable[k].substr(0, xppos).split(" ").pop());
  6481. if (xpplus > maxxpboost && xp1 * xpplus / 100 + pts2 < ptsNL) {
  6482. var kmerk = k;
  6483. var xpposmax = xppos;
  6484. maxxpboost = xpplus;
  6485. }
  6486. }
  6487. /*if (maxxpboost == 0 || Number(xp[0]) + xpg + xp1 * maxxpboost/100 < Number(xp[1]) && Number(xp[0]) + xpg + xp1 * 1.1 >= Number(xp[1]) || Number(xp[0]) + xpg + xp1 * maxxpboost/100 + Math.floor((lvl + 4) * 3 * maxTime * (1.2 + maxxpboost/100) + 0.5) < Number(xp[1])) {
  6488. trace("noleckerli: " + maxxpboost + "/" + xp + "/" + xp1 + "/" + xpg + "/" + lvl + "/" + maxTime, 8);
  6489. PGu_setValue("noleckerli", 1);
  6490. reload ("NoLeckerli", "/pet/");
  6491. return;
  6492. }*/
  6493. var leckerli = itemtable[kmerk].split("</strong")[0].split('">').pop();
  6494. var params = itemtable[kmerk].substr(xpposmax).split("showTargetSelector(")[1].split(")")[0].split(",");
  6495. var petname = content.substr(pos).split('class="petnametooltip"')[0].split(">").pop().split("<")[0].trim();
  6496. PGu_setValue("noleckerli", 1);
  6497. window.setTimeout(Leckerli, (PGu_getValue("PetStart", "") == ""?5000:500), params, petid, leckerli, petname);
  6498. }});
  6499. return;
  6500. }
  6501. if (ti == 10 || lvl == 50 || pts2 + ptsMaxT > ptsNL / 2 || Number(xp[0]) + xpg + pts >= Number(xp[1]))
  6502. if (Number(xp[0]) + xpg + xp1 * 1.1 < Number(xp[1]) || lvl == 50 || Number(xp[0]) + xpg >= Number(xp[1]) || Number(hp[0]) >= 30)
  6503. trace("Haustier XP: " + xpg, 2);
  6504. trace('Get ' + prothost + '/pet/get_roam_award/', 2);
  6505. GM_xmlhttpRequest({method:"GET", url: prothost + '/pet/get_roam_reward/', onload:function(responseDetails) {
  6506. reload("pet_reward2", "/pet/");
  6507. }});
  6508. }});
  6509. }
  6510. }
  6511. }
  6512. }
  6513. }
  6514. return;
  6515. }
  6516. }
  6517.  
  6518. DoPetStartCheck(content, 0, false, true);
  6519. }
  6520.  
  6521. function savePetStart() {
  6522. var petid = document.getElementById("pet_id").value;
  6523. var petname = document.getElementById("pet"+petid).getElementsByClassName("petname")[0].innerHTML.split('class="petnametool')[0].split(">").pop().split("<")[0].trim();
  6524. var kader = document.getElementById("pet_kader").getElementsByClassName("petshell");
  6525. for (var i = 0; i < kader.length; )
  6526. if (kader[i++].id == "pet"+petid)
  6527. break;
  6528. var dd = document.getElementById('area_id');
  6529. var area = dd.value.split(",");
  6530. var areaname = dd.options[dd.selectedIndex].innerHTML;
  6531. var dauer = document.getElementsByName("route_length")[0].value;
  6532. var now = new Date();
  6533. PGu_setValue("PetStart", String(now.getTime()) + ";" + dauer + ";" + areaname + ";" + area[1].toLowerCase());
  6534. PGu_setValue("noleckerli", 0);
  6535. trace("Start " + petname + " (" + i + ") in Gebiet " + areaname + " für " + dauer + " Minuten gegen " + area[1].toLowerCase() + "e Tiere", 1);
  6536. }
  6537.  
  6538. var lsnrset = 0;
  6539. function setEventListener() {
  6540. if (lsnrset == 2)
  6541. return;
  6542.  
  6543. if (lsnrset == 0) {
  6544. document.getElementById("plundertab").getElementsByTagName("a")[0].addEventListener('click', function(event) {
  6545. lsnrset = 1;
  6546. window.setTimeout(setEventListener, 500);
  6547. }, false);
  6548. if (PGu_getValue("AutoPet", false))
  6549. document.getElementById("plundertab").getElementsByTagName("a")[1].addEventListener('click', function(event) {
  6550. lsnrset = 1;
  6551. window.setTimeout(showPetBox, 500);
  6552. }, false);
  6553. }
  6554.  
  6555. if (document.getElementById("plundertab").getElementsByTagName("a")[0].className == "selected") {
  6556. if (!document.getElementById("petstartloader")) {
  6557. window.setTimeout(setEventListener, 500);
  6558. return;
  6559. }
  6560.  
  6561. var ti = document.getElementById("pet_roam_time");
  6562. var to = 500;
  6563. if (ti) {
  6564. var count = ti.innerHTML.split("</span")[0].split('>').pop();
  6565. if (ti.innerHTML.indexOf("Fertig") != -1)
  6566. count = done0;
  6567. count = count.split(":");
  6568. if (count.length > 1) {
  6569. count = Number(count[0]) * 60 + Number(count[1]);
  6570. to = count * 1000;
  6571. }
  6572. else
  6573. to = 500;
  6574. }
  6575. var psl = document.getElementById("petstartloader").getElementsByClassName("r_cornered_strong");
  6576. if (psl.length > 0 && psl[0].innerHTML.indexOf("gestartet am") == -1) {
  6577. var data = PGu_getValue("PetStart", "").split(";");
  6578. if (data.length == 4) {
  6579. var ti = document.getElementById("pet_roam_time");
  6580. if (ti && ti.innerHTML.indexOf("Fertig") == -1) {
  6581. var count = ti.innerHTML.split("</span")[0].split('>').pop().split(":");
  6582. if (count.length > 1) {
  6583. count = Number(count[0]) * 60 + Number(count[1]);
  6584. var mseks = Number(data[0]);
  6585. var now = new Date().getTime();
  6586. if (mseks + Number(data[1]) * 60000 + 5000 >= now + count*1000) {
  6587. var newcent = document.createElement("center");
  6588. newcent.innerHTML = "gestartet am " + FormatDateTime(new Date(mseks), "um") + " für " + data[1] + " Minuten in Gebiet " + data[2] + " gegen " + data[3] + "e Tiere";
  6589. psl[0].appendChild(newcent, psl[0]);
  6590. }
  6591. }
  6592. else
  6593. PGu_delete("PetStart");
  6594. }
  6595. }
  6596. }
  6597. if (!document.getElementById("action_start_button"))
  6598. window.setTimeout(setEventListener, to);
  6599. else {
  6600. document.getElementById("action_start_button").addEventListener('click', function(event) {
  6601. savePetStart();
  6602. return true;
  6603. }, false);
  6604. lsnrset = 2;
  6605. }
  6606. }
  6607. }
  6608.  
  6609. function showPetBox() {
  6610. if (document.getElementById("plundertab").getElementsByTagName("a")[1].className == "selected")
  6611. var pets = document.getElementsByClassName("petname");
  6612. else
  6613. var pets = document.getElementById("pet_kader").getElementsByClassName("petname");
  6614. for (var i = 0; i < pets.length; i++) {
  6615. var id = pets[i].parentNode.id;
  6616. if (document.getElementById(id + "Chb"))
  6617. continue;
  6618. pets[i].innerHTML = " " + pets[i].innerHTML;
  6619. var inp = document.createElement("input");
  6620. inp.id = id + "Chb";
  6621. inp.name = id + "Chb";
  6622. inp.type = "checkbox";
  6623. inp.title = "Streunverbot";
  6624. pets[i].insertBefore(inp, pets[i].childNodes[0]);
  6625. inp.checked = PGu_getValue(id+"Chb", false);
  6626. document.getElementById(id+"Chb").addEventListener("click", function(event) {
  6627. // Klickstatus speichern
  6628. if (this.checked)
  6629. PGu_setValue(event.target.id, true);
  6630. else
  6631. PGu_delete(event.target.id);
  6632. }, false);
  6633. }
  6634. if (i <= 3 && document.getElementById("plundertab").getElementsByTagName("a")[1].className == "selected" && !document.getElementById("meadow_click"))
  6635. window.setTimeout(showPetBox, 1000);
  6636.  
  6637. return;
  6638. }
  6639.  
  6640. function DoPetCheck(first)
  6641. {
  6642. PG_log("DoPetCheck(first="+first+")");
  6643. if (maxFass == 0 && first) {
  6644. trace("maxFass = 0, setze Timeout", 8);
  6645. window.setTimeout(DoPetCheck, 500, true);
  6646. return;
  6647. }
  6648.  
  6649. if(window.location.pathname.endsWith("/pet/")){
  6650. setEventListener();
  6651. if (PGu_getValue("AutoPet", false)) {
  6652. if (first)
  6653. window.setTimeout(showPetBox, 1000);
  6654. var content = document.getElementById("content").innerHTML;
  6655. var pos = content.search(/>\d* *freie Punkte|>\d* *freier Punkt/);
  6656. var skillPlan = [["Ausdauer", "max"],
  6657. ["Spürnase", (TOWNEXTENSION == "ML"?"-38":"-75")],
  6658. ["Kampfkraft", "+20"],
  6659. ["Spürnase", (TOWNEXTENSION == "ML"?"-33":"-65")],
  6660. ["Spürnase", (TOWNEXTENSION == "ML"?"-30":"-60")],
  6661. ["Spürnase", (TOWNEXTENSION == "ML"?"-28":"-55")],
  6662. ["Wachsamkeit", "max"],
  6663. ["Kampfkraft", "max"]];
  6664. while (pos != -1) {
  6665. var fp = parseInt(content.substr(pos+1));
  6666. var petname = content.substr(content.lastIndexOf('class="petnametooltip', pos)-100, 100).split(">").pop().split("<")[0].trim();
  6667. trace(fp + " freie Punkte für " + petname, 3);
  6668. pos2 = content.indexOf('class="petxpbar', pos);
  6669. var lvl = Number(content.substr(pos2-100, 100).split('Level">').pop().split("<")[0].trim());
  6670. var hchst = content.substr(pos).split("chstwert: ");
  6671. for (var l = 0; l < skillPlan.length; l++) {
  6672. var skill = "";
  6673. for (var hwi = 1; hwi < hchst.length; hwi++) {
  6674. var pp = hchst[hwi-1].lastIndexOf("<h1>");
  6675. if (pp == -1)
  6676. continue;
  6677. skill = hchst[hwi-1].substr(pp+4).split("</h1>")[0];
  6678. if (skill == skillPlan[l][0])
  6679. break;
  6680. }
  6681. if (hwi == hchst.length)
  6682. continue;
  6683. if (skill == "")
  6684. break;
  6685. trace("Skill gefunden: " + skill, 8);
  6686. var divs = hchst[hwi].split("</div>");
  6687. var hw = Number(divs[0].trim());
  6688. var aw = 1;
  6689. while (!divs[aw].trim().match(/^\d+\+$/))
  6690. aw++;
  6691. aw = parseInt(divs[aw].trim());
  6692. var zw = hw;
  6693. if (skillPlan[l][1] == "max")
  6694. if (aw >= hw)
  6695. continue;
  6696. else
  6697. zw = hw;
  6698. else {
  6699. zw = Number(skillPlan[l][1]);
  6700. if (skillPlan[l][1].substr(0,1) == "+")
  6701. zw = zw + aw % 2;
  6702. }
  6703. var abbr = (zw < 0);
  6704. if (abbr)
  6705. zw = -zw;
  6706. trace ("Zielwert für Skill " + skill + ": " + zw + ", Abbruch: " + (abbr?"true":"false"), 8);
  6707.  
  6708. if (hw < zw || aw + fp + (lvl==50?0:(51-lvl)*2) < zw)
  6709. if (abbr) {
  6710. trace("Zielwert nicht erreichbar, nächster Skill", 8);
  6711. continue;
  6712. }
  6713. else
  6714. zw = hw;
  6715.  
  6716. if (aw < zw) {
  6717. var upg = Math.min(zw - aw, fp);
  6718. var sc = hchst[hwi-1].split("statcontainer");
  6719. var ablty = hchst[hwi-1].split("<h1>")[1].split("</h1>")[0];
  6720. var href = sc[upg+1].split('href="')[1].split('"')[0];
  6721. trace("Fähigkeit " + ablty + " von Tier " + petname + " um " + upg + " erhöht.", 1);
  6722. GM_xmlhttpRequest({method:"GET", url: prothost + href, onload:function(responseDetails) {
  6723. reload("pet_upgrade", "/pet/");
  6724. }});
  6725. return;
  6726. }
  6727. }
  6728. pos2 = content.substr(pos+50).search(/> *\d* *freie Punkte|>\d* *freier Punkt/);
  6729. if (pos2 == -1)
  6730. break;
  6731. pos += pos2 + 50;
  6732. }
  6733. DoPetFinishCheck(content, true);
  6734. }
  6735. }
  6736. else if (PGu_getValue("AutoPet", false)) {
  6737. trace('Get ' + prothost + '/pet/', 2);
  6738. GM_xmlhttpRequest({method:"GET", url: prothost + '/pet/', onload:function(responseDetails) {
  6739. DoPetFinishCheck(responseDetails.responseText, true);
  6740. }});
  6741. }
  6742. }
  6743.  
  6744. function sellBottles(menge, price, src)
  6745. {
  6746. function sell(menge, price, src) {
  6747. var content = src.split('id="content"')[1];
  6748. var pos = content.indexOf('id="max"');
  6749. if (pos < 0)
  6750. return;
  6751. var text = content.substr(0, pos + content.substr(pos).indexOf(">"));
  6752. var anz = Number(text.substr(text.lastIndexOf("<input")).split('value="').pop().split('"')[0].trim());
  6753. var bprice = price;
  6754. if (menge == 0 || bprice == 0) {
  6755. pos = text.indexOf('id="chkval"');
  6756. if (pos < 0)
  6757. return;
  6758. text = content.substr(0, pos + content.substr(pos).indexOf(">"));
  6759. bprice = Number(text.substr(text.lastIndexOf("<input")).split('value="').pop().split('"')[0].trim());
  6760. if (menge == 0)
  6761. menge = Math.ceil(price * 100 / bprice);
  6762. }
  6763. if (anz >= menge)
  6764. HttpPost(content, 1, ["chkval", bprice, "sum", menge], function() { reload("sellBottles: " + menge + " zu " + bprice); });
  6765. }
  6766.  
  6767. if (menge <= 0)
  6768. return;
  6769.  
  6770. if (src == "")
  6771. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/bottle/', onload:function(responseDetails) {
  6772. sell (menge, price, responseDetails.responseText);
  6773. }});
  6774. else
  6775. sell (menge, price, src);
  6776. }
  6777.  
  6778. function checkGhostPages() {
  6779. function testGhost(i) {
  6780. if (i >= ghostPages.length) {
  6781. PGu_setValue("ghostIndex", i);
  6782. return;
  6783. }
  6784.  
  6785. GM_xmlhttpRequest({
  6786. method: 'GET', url: prothost + '/' + ghostPages[i] + '/',
  6787. onload: function(responseDetails) {
  6788. var content = responseDetails.responseText;
  6789. var ghosts = content.split('class="ghost_container"');
  6790. if (ghosts.length > 1) {
  6791. PGu_setValue("ghostIndex", i + 1);
  6792. window.location.href = prothost + '/' + ghostPages[i] + '/';
  6793. }
  6794. else
  6795. testGhost(i+1);
  6796. }
  6797. });
  6798. return;
  6799. }
  6800.  
  6801. var today = new Date();
  6802. var tagesdatum = FormatDate(today);
  6803. var gi = PGu_getValue("ghostIndex", 0);
  6804. if (gi >= ghostPages.length) {
  6805. if (PGu_getValue("ghostTest", "") != tagesdatum && today.getTime() % 86400000 > 300000) {
  6806. gi = 0;
  6807. PGu_setValue("ghostTest", tagesdatum);
  6808. PGu_setValue("ghostTestNoon", "");
  6809. }
  6810. else if (PGu_getValue("ghostTestNoon", "") != tagesdatum && today.getHours() > 12) {
  6811. gi = 0;
  6812. PGu_setValue("ghostTestNoon", tagesdatum);
  6813. }
  6814. }
  6815.  
  6816. testGhost(gi);
  6817. }
  6818.  
  6819. function WashMe(id, cnt) {
  6820. // **********************************************************************************
  6821. // *** GM_XMLHTTPREQUEST *** POSTEN des Kommandos zum Waschen
  6822. // **********************************************************************************
  6823. GM_xmlhttpRequest({method: 'POST', url: prothost + '/city/washhouse/buy/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  6824. data: encodeURI('id=' + id),
  6825. onload: function(responseDetails) {
  6826. if (cnt > 1)
  6827. WashMe(id, cnt-1);
  6828. else
  6829. reload("WashMe: " + id);
  6830. }
  6831. });
  6832. }
  6833.  
  6834. function CheckPresent(content) {
  6835. PG_log("CheckPresent");
  6836. var offers = content.split('href="/offers/');
  6837. var aktoffers = [];
  6838. for (var i = 1; i < offers.length; i++)
  6839. aktoffers.push("/offers/" + offers[i].split('"')[0]);
  6840.  
  6841. var sploffers = PGu_getValue("offers", "");
  6842. if (sploffers != "") {
  6843. sploffers = sploffers.split(";");
  6844. for (var i = sploffers.length - 1; i >= 0; i--) {
  6845. if (aktoffers.indexOf(sploffers[i].split(":")[0]) == -1)
  6846. sploffers.splice(i, 1);
  6847. }
  6848. }
  6849. else
  6850. sploffers = [];
  6851.  
  6852. for (var i = 0; i < aktoffers.length; i++) {
  6853. for (var j = 0; j < sploffers.length; j++)
  6854. if (sploffers[j].split(":")[0] == aktoffers[i])
  6855. break;
  6856. if (j == sploffers.length)
  6857. sploffers.push(aktoffers[i] + ":0");
  6858. }
  6859.  
  6860. PGu_setValue("offers", sploffers.join(";"));
  6861.  
  6862. for (var i = 0; i < sploffers.length; i++) {
  6863. var offer = sploffers[i].split(":");
  6864. if (offer[1] > 0 || offer[1].length > 1)
  6865. continue;
  6866. sploffers[i] = offer[0] + ":1";
  6867. GM_xmlhttpRequest({method:"GET", url: prothost + offer[0], onload:function(responseDetails) {
  6868. var content = responseDetails.responseText.split('id="content"')[1];
  6869. var pos = content.search("1 mal abholen");
  6870. if (pos == -1 || content.indexOf('id="postrequest') == -1) {
  6871. PGu_setValue("offers", sploffers.join(";"));
  6872. return;
  6873. }
  6874. sploffers[i] = offer[0] + ":" + FormatDateTime(new Date());
  6875. HttpPost(content, "postrequest", [], function() { PGu_setValue("offers", sploffers.join(";")); reload("CheckPresent"); });
  6876. }});
  6877. break;
  6878. }
  6879. }
  6880.  
  6881. function gangCredit(payin, min) {
  6882. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/credit/', onload:function(responseDetails) {
  6883. var content = responseDetails.responseText.split('id="content"')[1];
  6884. var gesamt = content.match(/Gesamt:.*[\d.,]+[^<]+/);
  6885. if (gesamt == null)
  6886. return;
  6887. gesamt = gesamt[0].split(">")[1].replace(/[,.]/g, "").match(/\d+/g);
  6888. if (gesamt.length > 1 && Number(gesamt[0]) + payin * 100 > Number(gesamt[1]))
  6889. payin = (Number(gesamt[1]) - Number(gesamt[0])) / 100;
  6890. if (payin >= min)
  6891. HttpPost(content, 1, ["f_money", payin, "f_comment", ""], function(responseDetails) {
  6892. var money = GetMoney(document);
  6893. var money2 = responseDetails.responseText.split('id="options"')[1].split("</a")[0].split(">").pop().match(/[.,\d]+/)[0].replace(/[.,]/g,"") / 100;
  6894. if (money2 != money)
  6895. reload ("gangCredit: " + payin, "/gang/credit/");
  6896. });
  6897. }});
  6898. }
  6899.  
  6900. function CheckSalary() {
  6901. PG_log("CheckSalary");
  6902. getOverviewPage(mainFunc5);
  6903. }
  6904.  
  6905. function mainFunc5() {
  6906. trace("mainFunc5", 8);
  6907. var fass = overviewcontent.split('class="first"')[1].split("Fassungsverm")[1].match(/[\d.,]+/);
  6908. var maxmoney = Number(fass[0].replace(/[.,]/g,''));
  6909. var time = document.getElementById("counter0").innerHTML.trim();
  6910. var seks = 0;
  6911. if (time.indexOf(" ") == -1) {
  6912. seks = getSeks(time);
  6913. }
  6914. else
  6915. seks = 3600;
  6916. if (seks < 30 && seks > 0)
  6917. return;
  6918. var money = GetMoney(document);
  6919. if (TOWNEXTENSION == "ML" && expertMode) {
  6920. var kk = Number(overviewcontent.split('class="icon crowncap"')[1].split("</a>")[0].split(">").pop());
  6921. if (kk >= 100 && (maxmoney < 10000 && money < 5 || maxmoney == 10000 && money < 20))
  6922. if (overviewcontent.indexOf('id="starter_popup') != -1) {
  6923. GM_xmlhttpRequest({
  6924. method: 'POST', url: prothost + '/itemsale/starter/gold/',
  6925. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  6926. data: encodeURI("dummy=Spezial"),
  6927. onload: function(responseDetails) {
  6928. trace("Starterpaket Gold gekauft", 1);
  6929. }
  6930. });
  6931. }
  6932. else {
  6933. var pos = overviewcontent.search(/\/offers\/event_.*Starter\/view/);
  6934. if (pos != -1) {
  6935. var href = overviewcontent.substr(pos).split('"')[0].replace('/view/', '/buy/');
  6936. GM_xmlhttpRequest({
  6937. method: 'POST', url: prothost + href,
  6938. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  6939. data: encodeURI("postrequest=1"),
  6940. onload: function(responseDetails) {
  6941. trace("Starterpaket Silber gekauft", 1);
  6942. }
  6943. });
  6944. }
  6945. }
  6946. else if (kk >= 100 && maxmoney < 10000 && money > 15) {
  6947. GM_xmlhttpRequest({method:"GET", url: prothost + '/city/stuff/', onload:function(responseDetails) {
  6948. var content = responseDetails.responseText.split('id="content"')[1];
  6949. HttpPost(content.substr(content.indexOf('id="1"')-20), 1, [], function() { trace("Behälter 1 gekauft", 1); });
  6950. }});
  6951. return;
  6952. }
  6953. else if (maxmoney == 10000 && money > 80) {
  6954. GM_xmlhttpRequest({method:"GET", url: prothost + '/city/stuff/', onload:function(responseDetails) {
  6955. var content = responseDetails.responseText.split('id="content"')[1];
  6956. HttpPost(content.substr(content.indexOf('id="2"')-20), 1, [], function() { trace("Behälter 2 gekauft", 1); });
  6957. }});
  6958. return;
  6959. }
  6960. else if (maxmoney == 100000 && money > 800) {
  6961. GM_xmlhttpRequest({method:"GET", url: prothost + '/city/stuff/', onload:function(responseDetails) {
  6962. var content = responseDetails.responseText.split('id="content"')[1];
  6963. HttpPost(content.substr(content.indexOf('id="3"')-20), 1, [], function() { trace("Behälter 3 gekauft", 1); });
  6964. }});
  6965. return;
  6966. }
  6967. else if (maxmoney == 1000000 && money > 9000) {
  6968. GM_xmlhttpRequest({method:"GET", url: prothost + '/city/stuff/', onload:function(responseDetails) {
  6969. var content = responseDetails.responseText.split('id="content"')[1];
  6970. HttpPost(content.substr(content.indexOf('id="4"')-20), 1, [], function() { trace("Behälter 3 gekauft", 1); });
  6971. }});
  6972. return;
  6973. }
  6974. }
  6975. if (!PGu_getValue("getSalary", false))
  6976. return;
  6977. var mon = overviewcontent.split('class="icon money"')[1].split("</a>")[0];
  6978. var salary = 0;
  6979. money = Number(mon.split(">").pop().match(/[\d,.]+/)[0].replace(/[.,]/g, ''));
  6980. if (overviewcontent.indexOf(" jetzt einsacken") != -1)
  6981. salary = Number(overviewcontent.split(" jetzt einsacken")[0].match(/[\d,.]+/g).pop().replace(/[.,]/g, ''));
  6982. if (overviewcontent.indexOf("Lohn abholen") != -1 || salary > 0 && (money + salary > maxmoney && money < 100000 || salary > maxmoney - 200000)) {
  6983. if (money + salary < maxmoney) {
  6984. var text = overviewcontent.split("music_payout")[1];
  6985. var val = text.split('value="')[1].split('"')[0];
  6986. var name = text.split('name="')[1].split('"')[0];
  6987. GM_xmlhttpRequest({
  6988. method: 'POST', url: prothost + '/overview/music_payout/',
  6989. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  6990. data: encodeURI(name+"="+val),
  6991. onload: function(responseDetails) {
  6992. trace("Lohn abgeholt: " + salary, 1);
  6993. }
  6994. });
  6995. }
  6996. else if (money % 100000 + salary <= maxmoney){
  6997. gangCredit(Math.floor(money / 100000) * 1000, 1000);
  6998. return;
  6999. }
  7000. }
  7001.  
  7002. var pos = overviewcontent.indexOf('name="reflink"');
  7003. if (pos == -1)
  7004. return;
  7005. pos = overviewcontent.lastIndexOf(">", pos);
  7006. var link = TOWNEXTENSION + ";" + overviewcontent.substr(pos).split('value="')[1].split('"')[0];
  7007. if (money == maxmoney) {
  7008. trace("kein freier Platz für Geld", 1);
  7009. return;
  7010. }
  7011. var today = new Date();
  7012. PG_log("now: " + today.getTime() + ", wait bis: " + PGu_getValue("spendenwait", 0));
  7013. if (today.getTime() < PGu_getValue("spendenwait", 0)) {
  7014. trace("warten für Spenden", 2);
  7015. return;
  7016. }
  7017. pos = overviewcontent.search(/Du hast heute \d* Spenden erhalten/);
  7018. if (pos <= 0) {
  7019. trace("Spendentext nicht gefunden", 2);
  7020. return;
  7021. }
  7022. var spenden = overviewcontent.substr(pos).match(/Du hast heute \d* Spenden erhalten[^\d]*\d*/);
  7023. if (spenden.length < 1) {
  7024. trace("Spendentext nicht gefunden2", 2);
  7025. return;
  7026. }
  7027. pos = overviewcontent.lastIndexOf("<table", pos);
  7028. var table = overviewcontent.substr(pos).split("<table")[1].split("</table>")[0];
  7029. while (table.indexOf("unarm") == -1) {
  7030. pos = overviewcontent.lastIndexOf("<table", pos-1);
  7031. table = overviewcontent.substr(pos).split("<table")[1].split("</table>")[0];
  7032. }
  7033. var tabs = table.split("<tr")[2].split("<td");
  7034. var pltab = 3;
  7035. if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" || TOWNEXTENSION == "MU")
  7036. pltab = 1;
  7037. var aktPlunder = tabs[pltab].split('src="')[1].split('"')[0];
  7038. var rest = Number(spenden[0].split(" ").pop());
  7039. if (rest <= 0 || rest == PGu_getValue("spendenrest", -1)) {
  7040. if (rest == PGu_getValue("spendenrest", -1)) {
  7041. PGu_setValue("spendenwait", String(today.getTime()+30*60000));
  7042. PGu_delete("spendenrest");
  7043. }
  7044. else {
  7045. PGu_delete("spendenwait");
  7046. PGu_delete("spendenrest");
  7047. }
  7048. var stuff = PGu_getValue("aktPlunder", "");
  7049. if (stuff != "") {
  7050. if (stuff.split(";").pop() == aktPlunder)
  7051. PGu_setValue("aktPlunder", "");
  7052. else {
  7053. // **********************************************************************************
  7054. // *** GM_XMLHTTPREQUEST *** POSTEN des Plunderwechsels
  7055. // **********************************************************************************
  7056. GM_xmlhttpRequest({method: 'POST', url: prothost + '/stock/plunder/change/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  7057. data: encodeURI('from_f=0&f_plunder=' + stuff.split(";")[0]),
  7058. onload: function(responseDetails) {
  7059. trace("Plunder gewechselt: " + stuff.split(";")[0], 1);
  7060. }
  7061. });
  7062. }
  7063. }
  7064. return;
  7065. }
  7066. var time = Number(overviewcontent.split('class="icon fight')[1].split("counter(")[1].split(",")[0]);
  7067. if (time > 0 && time < 60) {
  7068. trace("Kampf endet bald", 2);
  7069. return;
  7070. }
  7071. time = overviewcontent.split('class="icon rank');
  7072. if (time.length < 2)
  7073. time = overviewcontent.split('class="icon crime');
  7074. time = Number(time[1].split("counter(")[1].split(",")[0]);
  7075. if (time > 0 && time < 60) {
  7076. trace("Verbrechen endet bald", 2);
  7077. return;
  7078. }
  7079. var clean = overviewcontent.match(/Sauberkeit:[^\d]*\d*/);
  7080. if (clean.length < 1) {
  7081. trace("Sauberkeit-Text nicht gefunden", 2);
  7082. return;
  7083. }
  7084. clean = Number(clean[0].split(">")[1]);
  7085. if (clean < 100) {
  7086. var id = 2;
  7087. var cnt = 1;
  7088. var cost = 25;
  7089. if (clean >= 20) {
  7090. id = 1;
  7091. cnt = Math.ceil((100 - clean) / 20);
  7092. cost = cnt * 6;
  7093. }
  7094. money = GetMoney(document);
  7095. if (cost > money) {
  7096. var pid = PGu_getValue("sellPlunder1", "0");
  7097. if (pid != "0")
  7098. sellPlunder (pid, 1, "sellPlunder1");
  7099. else {
  7100. sellBottles(0, cost - money, "");
  7101. }
  7102. }
  7103. else
  7104. WashMe(id, cnt);
  7105. return;
  7106. }
  7107. pos = overviewcontent.search("Angelegte Plunder");
  7108. if (pos <= 0) {
  7109. trace("Angelegten Plunder nicht gefunden", 2);
  7110. return;
  7111. }
  7112.  
  7113. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
  7114. var content = responseDetails.responseText;
  7115. var bonus = content.match(/ Einnahmen durch Spenden um \d*%/g);
  7116. var maxp = -1;
  7117. if (bonus != null)
  7118. for (var i = 0; i < bonus.length; i++)
  7119. if (maxp < 0)
  7120. maxp = i;
  7121. else if (bonus[i] > bonus[maxp])
  7122. maxp = i;
  7123. var trs = content.split("<table")[1].split("</table")[0].split("<tr");
  7124. var zp = aktPlunder;
  7125. var aktstuff = -1;
  7126. for (var i = 1; i < trs.length && maxp >= 0; i++)
  7127. if (trs[i].indexOf(aktPlunder) != -1) {
  7128. aktstuff = trs[i].split("change_stuff('")[1].split("'")[0];
  7129. break;
  7130. }
  7131. var stuff = -1;
  7132. for (var i = 1; i < trs.length && maxp >= 0; i++)
  7133. if (trs[i].indexOf(bonus[maxp]) != -1) {
  7134. zp = trs[i].split('src="')[1].split('"')[0];
  7135. stuff = trs[i].split("change_stuff('")[1].split("'")[0];
  7136. break;
  7137. }
  7138. if (zp != aktPlunder) {
  7139. PGu_setValue("aktPlunder", aktstuff + ";" + aktPlunder);
  7140. // **********************************************************************************
  7141. // *** GM_XMLHTTPREQUEST *** POSTEN des Plunderwechsels
  7142. // **********************************************************************************
  7143. GM_xmlhttpRequest({method: 'POST', url: prothost + '/stock/plunder/change/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  7144. data: encodeURI('from_f=0&f_plunder=' + stuff),
  7145. onload: function(responseDetails) {
  7146. trace("Plunder gewechselt: " + stuff, 1);
  7147. }
  7148. });
  7149. return;
  7150. }
  7151. trace("Hole Spenden: " + PG_getValue("spendensammler", "xxx"), 1);
  7152. if (PG_getValue("spendensammler", "xxx") == "4everproxy")
  7153. {
  7154. if (GM_getValue("4everproxylink", "xxx") == "xxx") {
  7155. GM_setValue("4everproxylink", link);
  7156. setTimeout(startProxysite, 2000, link, prothost, m_ownuserid, TOWNEXTENSION, rest);
  7157. }
  7158. else if (GM_getValue("4everproxylink", "xxx") == link)
  7159. startProxysite(link, prothost, m_ownuserid, TOWNEXTENSION, rest);
  7160. return;
  7161. }
  7162. }
  7163. });
  7164. }
  7165.  
  7166. function startProxysite(link, prothost, userid, town, rest) {
  7167. if (GM_getValue("4everproxylink", "xxx") == link) {
  7168. var today = new Date();
  7169. GM_setValue("4everproxyhost", prothost + ";" + today.getTime());
  7170. GM_setValue(town + "spendenrest" + userid, rest);
  7171. window.location.href = "https://www.4everproxy.com";
  7172. }
  7173. else if (GM_getValue("4everproxylink", "xxx") == "xxx") {
  7174. GM_setValue("4everproxylink", link);
  7175. setTimeout(startProxysite, 2000, link, prothost, userid, town, rest);
  7176. }
  7177. else
  7178. setTimeout(startProxysite, 10000, link, prothost, userid, town, rest);
  7179. return;
  7180. }
  7181.  
  7182. function CheckGhosts() {
  7183. PG_log("CheckGhosts");
  7184. var today = new Date();
  7185. var tagesdatum = FormatDate(today);
  7186. var to = 10;
  7187. var ghosts = document.getElementsByClassName("ghost_container");
  7188. if (ghosts.length > 0) {
  7189. for (var gi = 0; gi < ghostPages.length; gi++)
  7190. if (window.location.pathname.substr(1, ghostPages[gi].length) == ghostPages[gi])
  7191. break;
  7192. if (gi >= ghostPages.length)
  7193. gi = window.location.pathname;
  7194. var ghostsfound = PGu_getValue("ghostsfound", "");
  7195. if (ghostsfound == "")
  7196. ghostsfound = tagesdatum;
  7197. else if (ghostsfound.indexOf(tagesdatum) == -1)
  7198. ghostsfound += ";" + tagesdatum;
  7199. ghostsfound += ":" + ghosts.length + ":" + gi;
  7200. PGu_setValue("ghostsfound", ghostsfound);
  7201.  
  7202. to = 3;
  7203. if (PGu_getValue("ghostTest", "") != tagesdatum) {
  7204. PGu_setValue("ghostIndex", 0);
  7205. PGu_setValue("ghostTest", tagesdatum);
  7206. PGu_setValue("ghostTestNoon", tagesdatum);
  7207. }
  7208. }
  7209.  
  7210. for (var i = 0; i < ghosts.length; i++)
  7211. setTimeout('document.getElementsByClassName("ghost_container")['+i+'].click();', 1000);
  7212.  
  7213. setTimeout (checkGhostPages, to * 1000);
  7214. return;
  7215. }
  7216.  
  7217. function CheckPlunder() {
  7218. PG_log("CheckPlunder");
  7219. GM_xmlhttpRequest({method:"GET", url: prothost + '/city/plundershop/', onload:function(responseDetails) {
  7220. var goods = responseDetails.responseText.split("/stock/plunder/craft/details/");
  7221. var buyable = PG_getValue("buyablegoods", "");
  7222. if (buyable == "") {
  7223. buyableP = [];
  7224. buyable = [];
  7225. }
  7226. else {
  7227. buyableP = buyable.replace(/[^#]+=/g, "").split("#");
  7228. buyable = buyable.replace(/=[^#]+/g, "").split("#");
  7229. if (buyableP[0].indexOf(":") != -1)
  7230. for (var i = 0; i < buyableP.length; i++) {
  7231. var chg = buyableP[i].split(":");
  7232. buyableP[i] = chg[1] + "*" + chg[0];
  7233. }
  7234. }
  7235. var count = buyable.length-1;
  7236. var lastpid = 0;
  7237. for (var i = 1; i < goods.length; i++) {
  7238. var pid = goods[i].split("/")[0];
  7239. var cost = goods[i].split("<br")[1].split("<")[0].split(">")[1].replace("\n", "").trim();
  7240. if (pid == lastpid || cost == "")
  7241. continue;
  7242. lastpid = pid;
  7243. var plnd = goods[i].split("</strong")[0].split(">").pop().trim();
  7244. var indx = buyable.indexOf(pid);
  7245. if (indx == -1) {
  7246. buyable.push(pid);
  7247. buyableP.push(plnd + "*" + cost);
  7248. }
  7249. else if (buyableP[indx] != plnd + "*" + cost) {
  7250. buyableP[indx] = plnd + "*" + cost;
  7251. count = 0;
  7252. }
  7253. }
  7254. if (buyable.length != count) {
  7255. for (var i = 0; i < buyable.length; i++)
  7256. buyable[i] = [buyable[i], buyableP[i]];
  7257. buyable = buyable.sort(function(a, b){return a[0]-b[0];});
  7258. for (var i = 0; i < buyable.length; i++)
  7259. buyable[i] = buyable[i][0] + "=" + buyable[i][1];
  7260. PG_setValue("buyablegoods", buyable.join("#"));
  7261. }
  7262. var alwaysbuy = PGu_getValue("alwaysbuy", "");
  7263. if (alwaysbuy == "")
  7264. return;
  7265. alwaysbuy = alwaysbuy.split(";");
  7266. var money = GetMoney(document);
  7267. var bought = PGu_getValue("bought", "");
  7268. var boughtnow = "";
  7269. var today = new Date();
  7270. for (var i = 1; i < goods.length; i++) {
  7271. var pid = goods[i].split("/")[0];
  7272. var indx = alwaysbuy.indexOf(pid);
  7273. if (indx == -1 && alwaysbuy[0] != "0")
  7274. continue;
  7275. if (goods[i].indexOf("<form") == -1 && i < goods.length - 1)
  7276. goods.splice(i, 1, goods[i] + goods[i + 1]);
  7277. var cost = goods[i].split("<br")[1].split("<")[0].split(">")[1].replace("\n", "").trim();
  7278. if (cost == "")
  7279. continue;
  7280. cost = Number(cost.match(/[\d,.]+/)[0].replace(/[.,]/g, ""))/100;
  7281. if (cost > money)
  7282. continue;
  7283. money -= cost;
  7284. if (boughtnow == "")
  7285. boughtnow = String(today.getTime()) + ":" + pid;
  7286. else
  7287. boughtnow += "," + pid;
  7288. trace("buy " + pid + " for " + cost, 1);
  7289. HttpPost(goods[i], 1, [], function() { });
  7290. }
  7291. if (boughtnow != "") {
  7292. if (bought == "")
  7293. bought = [];
  7294. else
  7295. bought = bought.split(";");
  7296. bought.push(boughtnow);
  7297. if (bought.length > 10)
  7298. bought.splice(0, 1);
  7299. PGu_setValue("bought", bought.join(";"));
  7300. }
  7301. }});
  7302. }
  7303.  
  7304. function doBuy(id, anz) {
  7305. PG_log("doBuy(" + id + ", " + anz + ")");
  7306. if (GetMoney(document) < 10) {
  7307. var id = PGu_getValue("sellPlunder1", "0");
  7308. if (id != "0")
  7309. sellPlunder(id, 1, "sellPlunder1");
  7310. return;
  7311. }
  7312.  
  7313. var food = "";
  7314. if (id == 2 || id == 3 || id == 4)
  7315. food = "food/";
  7316.  
  7317. GM_xmlhttpRequest({method:"GET", url: prothost + '/city/supermarket/'+food, onload:function(responseDetails) {
  7318. var content = responseDetails.responseText.split('id="content"')[1];
  7319. var inputs = content.split("<input");
  7320. var fnum = 1;
  7321. for (var i = 1; i < inputs.length; i++) {
  7322. if (inputs[i].indexOf('<form') != -1)
  7323. fnum++;
  7324. if (inputs[i].indexOf('name="id"') != -1) {
  7325. if (inputs[i].split('value="')[1].split('"')[0] == id) {
  7326. trace("buy " + anz + " x " + id, 1);
  7327. HttpPost(content, fnum, ["menge", anz], function() { reload("doBuy"); });
  7328. break;
  7329. }
  7330. }
  7331. }
  7332. }});
  7333. }
  7334.  
  7335. function doEatDrink(id, anz) {
  7336. PG_log("doEatDrink(" + id + ", " + anz + ")");
  7337. var food = "";
  7338. if (id == 2 || id == 3 || id == 4)
  7339. food = "food/";
  7340.  
  7341. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/foodstuffs/'+food, onload:function(responseDetails) {
  7342. var content = responseDetails.responseText.split('id="content"')[1];
  7343. var inputs = content.split("<input");
  7344. var fnum = 1;
  7345. var pos = inputs[0].length;
  7346. var menge = 0;
  7347. for (var i = 1; i < inputs.length; i++) {
  7348. if (inputs[i].indexOf('<form') != -1)
  7349. fnum++;
  7350. if (inputs[i].indexOf('name="id"') != -1) {
  7351. if (inputs[i].split('value="')[1].split('"')[0] == id) {
  7352. var menge = content.substr(pos).split("<span>")[1].match(/\d+/)[0];
  7353. if (menge >= anz) {
  7354. trace(id == 2 || id == 3 || id == 4?"eat":"drink " + anz + " x " + id, 1);
  7355. HttpPost(content, fnum, ["menge", anz], function() { reload("doEatDrink"); });
  7356. }
  7357. break;
  7358. }
  7359. }
  7360. pos += inputs[i].length + 6;
  7361. }
  7362. if (menge < anz) {
  7363. var eatDrink = PGu_getValue("eatDrink", "");
  7364. if (eatDrink != "")
  7365. eatDrink = (id != 1?"-":"") + anz + "," + eatDrink;
  7366. else
  7367. eatDrink = (id != 1?"-":"") + anz;
  7368. PGu_setValue("eatDrink", eatDrink);
  7369. doBuy(id, anz - menge);
  7370. }
  7371. }});
  7372. }
  7373.  
  7374. function gangpayin(plunder, anz) {
  7375. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/stuff/', onload:function(responseDetails) {
  7376. var content = responseDetails.responseText;
  7377. var payin = content.split('Plunder einzahlen');
  7378. if (payin.length > 1) {
  7379. var form = payin[1].split("<form")[1].split('name="')[1].split('"')[0];
  7380. var select = payin[1].split("<select")[1].split("</select")[0];
  7381. var id = select.split('name="')[1].split('"')[0];
  7382. var options = select.replace(/ */g, " ").split("<option ");
  7383. for (var i = 1; i < options.length; i++) {
  7384. if (options[i].indexOf(plunder + " [x") != -1) {
  7385. var pid = options[i].split('value="')[1].split('"')[0];
  7386. var menge = Number(options[i].split(" [x")[1].split(']</option')[0].trim());
  7387. if (menge > anz)
  7388. menge = anz;
  7389. trace("pay in gang: " + menge + " x " + pid, 1);
  7390. HttpPost(payin[1], form, [id, pid, "f_count", menge], function() { reload("gangpayin"); });
  7391. break;
  7392. }
  7393. }
  7394. }
  7395. }});
  7396. }
  7397.  
  7398. function sellManyPlunder(data) {
  7399. function sellSinglePlunder(sell, data, i) {
  7400. if (i >= data.length)
  7401. return;
  7402. HttpPost(sell, 1, ["plunderid", data[0][2], "count", data[0][1]], function(responseDetails) {
  7403. sellSinglePlunder (sell, data, i+1);
  7404. });
  7405. }
  7406. if (data.length < 1)
  7407. return;
  7408. GM_xmlhttpRequest({method: 'GET', url: prothost + '/stock/plunder/', onload: function(responseDetails) {
  7409. var sell = responseDetails.responseText.split("Plunder verkaufen")[1];
  7410. sellSinglePlunder (sell, data, 0);
  7411. }});
  7412. }
  7413.  
  7414. function sellPlunder(pid, anz, varname) {
  7415. PG_log("sellPlunder(" + pid + ", " + anz + ")");
  7416. GM_xmlhttpRequest({method: 'GET', url: prothost + '/stock/plunder/', onload: function(responseDetails) {
  7417. var sell = responseDetails.responseText.split("Plunder verkaufen")[1];
  7418. HttpPost(sell, 1, ["plunderid", pid, "count", anz], function(responseDetails) {
  7419. if (varname != "") {
  7420. var antwort = responseDetails.responseText.split("<title")[1].split("</title")[0].split(">")[1];
  7421. if (antwort.indexOf("Server Error") != -1)
  7422. PGu_setValue(varname, "0");
  7423. }
  7424. reload("sellPlunder: " + anz + " " + pid);
  7425. });
  7426. }});
  7427. }
  7428.  
  7429. function sellWeapon(id) {
  7430. GM_xmlhttpRequest({method: 'POST', url: prothost + '/stock/armoury/sell/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  7431. data: encodeURI('id='+id),
  7432. onload: function(responseDetails) {
  7433. reload("sellWeapon");
  7434. }
  7435. });
  7436. }
  7437.  
  7438. function useWeapon() {
  7439. var selWeapon = PGu_getValue("selWeapon");
  7440. if (selWeapon == "")
  7441. reload("useWeapon1");
  7442. else {
  7443. GM_xmlhttpRequest({method: 'POST', url: prothost + '/stock/armoury/use/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  7444. data: encodeURI('id=' + selWeapon),
  7445. onload: function(responseDetails) {
  7446. PGu_setValue("selWeapon", "");
  7447. reload("useWeapon2 " + selWeapon);
  7448. }
  7449. });
  7450. }
  7451. }
  7452.  
  7453. function buyWeapon(id) {
  7454. if (id == "0") {
  7455. useWeapon();
  7456. }
  7457. else {
  7458. GM_xmlhttpRequest({method: 'POST', url: prothost + '/city/weapon_store/buy/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  7459. data: encodeURI('id='+id),
  7460. onload: function(responseDetails) {
  7461. useWeapon();
  7462. }
  7463. });
  7464. }
  7465. }
  7466.  
  7467. function moveTo(target, home, mode) {
  7468. if (home != "")
  7469. PGu_setValue("homeDist", home);
  7470. else
  7471. PGu_setValue("homeDist", "");
  7472.  
  7473. GM_xmlhttpRequest({method: 'POST', url: prothost + '/city/district/buy/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  7474. data: encodeURI("id="+target+"&SubmitForm="+(mode==""?"Einziehen":"Kaufen")),
  7475. onload: function(responseDetails) {
  7476. reload("moveTo");
  7477. }
  7478. });
  7479. }
  7480.  
  7481. function incrDailyTry(tagesdatum, tries) {
  7482. PGu_setValue("tryDailyTask", tagesdatum + ";" + (tries+1).toString());
  7483. return;
  7484. }
  7485.  
  7486. function doDailyTask(t) {
  7487. PG_log("doDailyTask(" + t + ")");
  7488. if (t < 0)
  7489. return false;
  7490. var today = new Date();
  7491. var tagesdatum = FormatDate(today);
  7492. tryDaily = PGu_getValue("tryDailyTask", ";0").split(";");
  7493. if (tryDaily[0] != tagesdatum) {
  7494. var tries = 0;
  7495. PGu_delete("tryDailyTask");
  7496. }
  7497. else
  7498. var tries = Number(tryDaily[1]);
  7499. trace("Tägliche Aufgabe " + t + ", Versuche bisher: " + tries, (tries > 0?1:2));
  7500.  
  7501. switch (t) {
  7502. // Jetzt eine PN an einen Freund versenden
  7503. case 0: var friend = PGu_getValue("friendid", "0");
  7504. if (friend == "0")
  7505. return false;
  7506. GM_xmlhttpRequest({method:"GET", url: prothost + '/friendlist/', onload:function(responseDetails) {
  7507. var content = responseDetails.responseText;
  7508. // Wenn die Seite abgerufen werden konnte (kein Seitenladefehler)
  7509. if (content.indexOf("<strong>Mein Penner</strong>") != -1) {
  7510. if (content.indexOf("/profil/id:"+friend+"/") == -1)
  7511. PGu_setValue("friendid", "0");
  7512. else {
  7513. GM_xmlhttpRequest({method:"GET", url: prothost + '/messages/write/', onload:function(responseDetails) {
  7514. var content = responseDetails.responseText.split('id="content"')[1];
  7515. incrDailyTry(tagesdatum, tries);
  7516. trace("Send mail to " + friend, 1);
  7517. HttpPost(content, 1, ["f_toname", "id:"+friend, "f_subject", "", "f_text", ""], function() { reload("doDailyTask0"); });
  7518. }});
  7519. }
  7520. }
  7521. }});
  7522. break;
  7523. // Ein Verbrechen/eine Sünde erfolgreich begehen
  7524. case 1: if (document.getElementById("options").innerHTML.indexOf("crime") != -1)
  7525. return false;
  7526. var time = document.getElementById("options").innerHTML.split("rank")[1].split("counter(")[1].split(",")[0];
  7527. if (time < 0) {
  7528. incrDailyTry(tagesdatum, tries);
  7529. GM_xmlhttpRequest({method:"GET", url: prothost + '/activities/', onload:function(responseDetails) {
  7530. var actbottle = responseDetails.responseText.split('/activities/bottle/')[1].split("</form")[0];
  7531. var inputs = actbottle.split("<input ");
  7532. var data = "";
  7533. for (var j = 1; j < inputs.length; j++) {
  7534. var name = inputs[j].split('name="')[1].split('"')[0];
  7535. data += "&" + name + "=" + inputs[j].split('value="')[1].split('"')[0];
  7536. }
  7537. GM_xmlhttpRequest({method: 'POST', url: prothost + '/activities/bottle/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  7538. data: encodeURI(data.substr(1)),
  7539. onload: function(responseDetails) {
  7540. reload("doDailyTask1");
  7541. }
  7542. });
  7543. }});
  7544. return true;
  7545. }
  7546. else if (time == 0) {
  7547. GM_xmlhttpRequest({method: 'GET', url: prothost + '/activities/crime/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  7548. onload: function(responseDetails) {
  7549. var crimes = responseDetails.responseText.split('name="plundercrime"')[1].split("start_crime(");
  7550. if (crimes.length == 1)
  7551. PG_log("Verbrechen starten nicht möglich !!");
  7552. else
  7553. GM_xmlhttpRequest({method: 'GET', url: prothost + '/activities/crime/?start_crime=' + crimes[1].split(")")[0], headers: {'Content-type': 'application/x-www-form-urlencoded'},
  7554. onload: function(responseDetails) {
  7555. reload("start crime " + crimes[1].split(")")[0]);
  7556. }});
  7557. }});
  7558. return true;
  7559. }
  7560. return false;
  7561. break;
  7562. // Einen Kampf gewinnen
  7563. case 2: //alert(2);
  7564. break;
  7565. // Jetzt Lose kaufen
  7566. case 3: if (today.getTime() < Number(PGu_getValue("KeineLoseWait", "0")))
  7567. return false;
  7568. var time = Math.ceil(today.getTime() / 1000 - today.getTimezoneOffset()*60) % 86400;
  7569. if (PGu_getValue("losemiss_wait", 0) > time && !PGu_getValue("LoseKaufSofort", false))
  7570. return false;
  7571. GM_xmlhttpRequest({method:"GET",
  7572. url: prothost + '/city/games/',
  7573. onload:function(responseDetails) {
  7574. var losecont = responseDetails.responseText.split('id="content"')[1];
  7575. var nochlose = losecont.split("Du kannst heute noch ").pop();
  7576. if (nochlose.indexOf("lose_remaining") != -1)
  7577. nochlose = nochlose.split("</span>")[0].split(">").pop();
  7578. if (nochlose == 0)
  7579. PGu_setValue("KeineLoseWait", String(today.getTime() + 3600000));
  7580. else if (PGu_getValue("LoseKaufSofort", false)) {
  7581. trace("Lose kaufen: 1", 3);
  7582. incrDailyTry(tagesdatum, tries);
  7583. LoseKaufen(losecont, 1);
  7584. }
  7585. else {
  7586. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/missions/', onload:function(responseDetails) {
  7587. var missions = responseDetails.responseText.split('class="gang_mission"');
  7588. var losemiss = false;
  7589. for (var i = 1; i < missions.length; i++) {
  7590. var missspl = missions[i].split("stage_area");
  7591. if (missspl[2].indexOf("Rubbellose") != -1) {
  7592. var counter = 0;
  7593. var pos2 = missspl[1].indexOf("counter(");
  7594. if (pos2 != -1) {
  7595. counter = missspl[1].substr(pos2).split("counter(")[1].split(")")[0].trim();
  7596. if (counter == done)
  7597. counter = "0";
  7598. counter = Number(counter);
  7599. }
  7600. losemiss = (time + counter < 83000);
  7601. if (losemiss)
  7602. PGu_setValue("losemiss_wait", (time+counter));
  7603. break;
  7604. }
  7605. }
  7606. if (!losemiss) {
  7607. PGu_setValue("losemiss_wait", 0);
  7608. var pos = losecont.indexOf('name="preis_cent"');
  7609. if (pos < 0)
  7610. return;
  7611. var val = Number(losecont.substr(losecont.lastIndexOf("<input", pos)).split('value="')[1].split('"')[0]) / 100;
  7612. var money = GetMoney(document);
  7613. if (val > money) {
  7614. var pid = PGu_getValue("sellPlunder1", "0");
  7615. if (pid != "0")
  7616. sellPlunder (pid, 1, "sellPlunder1");
  7617. else
  7618. sellBottles(0, val - money, "");
  7619. }
  7620. else {
  7621. trace("Lose kaufen: 1", 3);
  7622. incrDailyTry(tagesdatum, tries);
  7623. LoseKaufen(losecont, 1);
  7624. }
  7625. return;
  7626. }
  7627. }});
  7628. }
  7629. }
  7630. });
  7631. return false;
  7632. break;
  7633. // Jetzt in der SB posten
  7634. case 4: GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/shoutbox_ajax/', onload:function(responseDetails) {
  7635. var chatadd = responseDetails.responseText;
  7636. var textid = chatadd.split("<textarea ")[1].split('name="')[1].split('"')[0];
  7637. incrDailyTry(tagesdatum, tries);
  7638. HttpPost(chatadd, 1, [textid, " "], function() {
  7639. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/shoutbox_ajax/', onload:function(responseDetails) {
  7640. var divs = responseDetails.responseText.split("<div");
  7641. for (var i = 1; i < divs.length; i += 2) {
  7642. if (divs[i].indexOf("/profil/id:"+m_ownuserid) == -1)
  7643. continue;
  7644. var text = divs[i+1].match(/<p>.*<\/p>/);
  7645. if (text.length == 0)
  7646. continue;
  7647. if (text[0].split("<p>")[1].split("<")[0].trim().length > 0)
  7648. continue;
  7649. var pos = divs[i].indexOf("/delete/");
  7650. if (pos == -1)
  7651. continue;
  7652. pos = divs[i].lastIndexOf("'", pos);
  7653. var href = divs[i].substr(pos+1).split("'")[0];
  7654. GM_xmlhttpRequest({method:"GET", url: prothost + href, onload:function(responseDetails) {
  7655. reload("doDailyTask4");
  7656. }});
  7657. break;
  7658. }
  7659. }});
  7660. });
  7661. }});
  7662. break;
  7663. // Jetzt im Supermarkt Getränke kaufen.
  7664. case 5: incrDailyTry(tagesdatum, tries);
  7665. doBuy(1, 1);
  7666. break;
  7667. // Jetzt einen Begleiterkampf aktivieren
  7668. case 6: var money = Math.floor(GetMoney(document));
  7669. if (money == 0) {
  7670. var id = PGu_getValue("sellPlunder1", "0");
  7671. if (id != "0")
  7672. sellPlunder(id, 1, "sellPlunder1");
  7673. return (id != 0);
  7674. }
  7675. GM_xmlhttpRequest({method:"GET", url: prothost + '/fight/pet/', onload:function(responseDetails) {
  7676. var fightpet = responseDetails.responseText.split('action="/fight/pet/')[1].split("</form")[0];
  7677. var inputs = fightpet.replace(/<select/g, "<input").replace(/'/g,'"').split("<input ");
  7678. var data = "";
  7679. for (var j = 1; j < inputs.length; j++) {
  7680. if (inputs[j].indexOf('name="') == -1)
  7681. continue;
  7682. var name = inputs[j].split('name="')[1].split('"')[0];
  7683. if (name == "einsatz") {
  7684. var val = inputs[j].split('value="')[1].split('"')[0];
  7685. if (val == 0)
  7686. val = 1;
  7687. }
  7688. else if (name == "ttl" || name == "verhalten" || name == "risiko") {
  7689. var options = inputs[j].split("<option ");
  7690. for (var k=1; k < options.length; k++) {
  7691. if (options[k].indexOf("selected") != -1) {
  7692. var val = options[k].split('value="')[1].split('"')[0];
  7693. break;
  7694. }
  7695. else if (k == 1)
  7696. var val = options[k].split('value="')[1].split('"')[0];
  7697. }
  7698. }
  7699. data += "&" + name + "=" + val;
  7700. }
  7701. incrDailyTry(tagesdatum, tries);
  7702. GM_xmlhttpRequest({method: 'POST', url: prothost + '/fight/pet/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  7703. data: encodeURI(data.substr(1)),
  7704. onload: function(responseDetails) {
  7705. reload("doDailyTask6");
  7706. }
  7707. });
  7708. }});
  7709. return true;
  7710. break;
  7711. // Jetzt einmal 100% sauber werden
  7712. case 7: GM_xmlhttpRequest({method:"GET", url: prothost + '/overview/', onload:function(responseDetails) {
  7713. var content = responseDetails.responseText.split('id="content"')[1];
  7714. var clean = content.match(/Sauberkeit:[^\d]*\d*/);
  7715. if (clean.length < 1)
  7716. return;
  7717. clean = Number(clean[0].split(">")[1]);
  7718. if (clean < 100) {
  7719. var id = 2;
  7720. var cnt = 1;
  7721. var cost = 25;
  7722. if (clean >= 20) {
  7723. id = 1;
  7724. cnt = Math.ceil((100 - clean) / 20);
  7725. cost = cnt * 6;
  7726. }
  7727. var money = GetMoney(document);
  7728. if (cost > money) {
  7729. var pid = PGu_getValue("sellPlunder1", "0");
  7730. if (pid != "0")
  7731. sellPlunder (pid, 1, "sellPlunder1");
  7732. else
  7733. sellBottles(0, cost - money, "");
  7734. return;
  7735. }
  7736. incrDailyTry(tagesdatum, tries);
  7737. WashMe(id, cnt);
  7738. }
  7739. else {
  7740. // Seife benutzen
  7741. var pltab = 4;
  7742. if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" || TOWNEXTENSION == "MU")
  7743. pltab = 3;
  7744. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
  7745. var content = responseDetails.responseText;
  7746. var trs = content.split("<tr ");
  7747. var fnum = 1;
  7748. for (var i = 1; i < trs.length; i++) {
  7749. if (trs[i].indexOf('seife.png') != -1 || trs[i].indexOf('p_spender.png') != -1) {
  7750. var pid = trs[i].split('pm_')[1].split("'")[0].trim();
  7751. incrDailyTry(tagesdatum, tries);
  7752. HttpPost(content, fnum, ["f_plunder", pid], function() { reload("doDailyTask7"); });
  7753. break;
  7754. }
  7755. fnum += trs[i].split("<form").length - 1;
  7756. }
  7757. if (i == trs.length) {
  7758. incrDailyTry(tagesdatum, tries);
  7759. GM_xmlhttpRequest({method:"GET", url: prothost + '/city/medicine/', onload:function(responseDetails) {
  7760. var content = responseDetails.responseText;
  7761. var money = GetMoney(document);
  7762. var forms = content.split("<form ");
  7763. for (var i = 1; i < forms.length; i++) {
  7764. if (forms[i].indexOf('/medicine/help/') != -1) {
  7765. var cost = Number(forms[i].split('class="formbutton"')[1].match(/[\d.,]+/)[0].replace(/[.,]/g,""))/100;
  7766. if (cost <= money)
  7767. HttpPost(content, i, [], function() { reload("doDailyTask7b"); });
  7768. else {
  7769. var pid = PGu_getValue("sellPlunder1", "0");
  7770. if (pid != "0")
  7771. sellPlunder (pid, 1, "sellPlunder1");
  7772. else
  7773. sellBottles(0, cost - money, "");
  7774. return;
  7775. }
  7776. break;
  7777. }
  7778. }
  7779. }});
  7780. }
  7781. }});
  7782. }
  7783. }});
  7784. break;
  7785. // Geld in deine Bandenkasse einzahlen
  7786. case 8: var money = Math.floor(GetMoney(document));
  7787. if (money == 0) {
  7788. var id = PGu_getValue("sellPlunder1", "0");
  7789. if (id != "0")
  7790. sellPlunder(id, 1, "sellPlunder1");
  7791. return;
  7792. }
  7793. incrDailyTry(tagesdatum, tries);
  7794. gangCredit(money < 1000?1:1000, 1);
  7795. break;
  7796. // Plunder in die Plunderbank deiner Bande einzahlen
  7797. case 9: GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/missions/', onload:function(responseDetails) {
  7798. var missions = responseDetails.responseText.split('class="gang_mission"');
  7799. var neededPlunder = [];
  7800. var pAnz = 0;
  7801. for (var i = 1; i < missions.length; i++) {
  7802. var lis = missions[i].split("stage_area")[1].split("<li>");
  7803. for (var j = 1; j < lis.length; j++) {
  7804. var beg = lis[j].split('"amount"');
  7805. if (beg.length > 1)
  7806. neededPlunder[pAnz++] = beg[0].split("<span>")[1].split("<")[0];
  7807. }
  7808. }
  7809. var pltab = 6;
  7810. if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" ||TOWNEXTENSION == "MU")
  7811. pltab = 1;
  7812. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
  7813. var content = responseDetails.responseText;
  7814. var trs = content.split("<tr ");
  7815. var misspl = [];
  7816. for (var i = 1; i < trs.length; i++) {
  7817. if (trs[i].indexOf('"pinfo2"') == -1)
  7818. continue;
  7819. var pinfo2 = trs[i].split('"pinfo2"')[1];
  7820. if (pinfo2.indexOf("Missionsplunder") != -1 || pinfo2.indexOf("Bandenmission") != -1) {
  7821. var plname = trs[i].split(">x ")[0].split("</strong")[0].split(">").pop().trim();
  7822. var plAnz = trs[i].split(">x ")[1].split("<")[0].trim();
  7823. misspl.push([plname, Number(plAnz)]);
  7824. }
  7825. }
  7826. var inpaid = false;
  7827. for (var i = 0; i < misspl.length; i++)
  7828. if (neededPlunder.indexOf(misspl[i][0]) == -1) {
  7829. gangpayin(misspl[i][0], misspl[i][1]);
  7830. inpaid = true;
  7831. break;
  7832. }
  7833. if (!inpaid && misspl.length > 0) {
  7834. incrDailyTry(tagesdatum, tries);
  7835. gangpayin(misspl[0][0], misspl[0][1]%100!=0?misspl[0][1]%100:100);
  7836. }
  7837. }});
  7838. }});
  7839. break;
  7840. // Eine Begleiterweiterbildung starten
  7841. case 10: //alert(10);
  7842. break;
  7843. // Einen Plunder basteln
  7844. case 11: var indx = PGu_getValue("craftindex", 0);
  7845. if (indx < 0)
  7846. return -1;
  7847. var craftlist = PGu_getValue("craftlist", "").split(";");
  7848. var craftid = indx >= craftlist.length?"":craftlist[indx];
  7849. if (craftid == "") {
  7850. if (document.getElementById("options").innerHTML.indexOf("crime") != -1)
  7851. var time = 9999999999;
  7852. else
  7853. var time = Number(document.getElementById("options").innerHTML.split("rank")[1].split("counter(")[1].split(",")[0]);
  7854. PGu_setValue("craftindex", -1);
  7855. PGu_setValue("bottletime", time);
  7856. return -1;
  7857. }
  7858. PGu_setValue("craftindex", indx+1);
  7859. if (craftid == "0")
  7860. return -1;
  7861. GM_xmlhttpRequest({method: 'GET', url: prothost + '/stock/plunder/craft/details/'+craftid+"/", onload: function(responseDetails) {
  7862. var content = responseDetails.responseText;
  7863. if (content.indexOf("start_craft") != -1) {
  7864. HttpPost(content, "craftform", ["plunder", craftid], function() { reload("doDailyTask11"); });
  7865. incrDailyTry(tagesdatum, tries);
  7866. }
  7867. }});
  7868. break;
  7869. // Jetzt einen kleinen Snack essen
  7870. case 12: var promille = GetPromille(document);
  7871. incrDailyTry(tagesdatum, tries);
  7872. if (promille >= 2.5 && promille < 2.9) {
  7873. PGu_setValue("eatDrink", "-1");
  7874. doEatDrink(1, 1);
  7875. }
  7876. else if (promille < 0.8)
  7877. doEatDrink(2, 1);
  7878. else {
  7879. PGu_setValue("eatDrink", "1");
  7880. doEatDrink(2, 1);
  7881. }
  7882. break;
  7883. // Promillepegel über 2‰
  7884. case 13: var promille = GetPromille(document);
  7885. incrDailyTry(tagesdatum, tries);
  7886. if (promille >= 3.15) {
  7887. PGu_setValue("eatDrink", "1");
  7888. doEatDrink(2, 1);
  7889. }
  7890. else if (promille > 2.0) {
  7891. PGu_setValue("eatDrink", "-1");
  7892. doEatDrink(1, 1);
  7893. }
  7894. else {
  7895. var drinks = Math.ceil((2.05 - promille) / 0.35);
  7896. if (drinks < 1)
  7897. drinks = 1;
  7898. if (promille < 0.8)
  7899. var eats = Math.ceil((promille + drinks*0.35 - 0.75) / 0.35);
  7900. else
  7901. var eats = drinks;
  7902. PGu_setValue("eatDrink", "-" + eats);
  7903. doEatDrink(1, drinks);
  7904. }
  7905. break;
  7906. // Einmal Flaschensammeln starten
  7907. case 14: if (document.getElementById("options").innerHTML.indexOf("crime") != -1)
  7908. return false;
  7909. var time = document.getElementById("options").innerHTML.split("/fight/")[1].split("counter(")[1].split(",")[0];
  7910. if (time > 0)
  7911. return false;
  7912. time = document.getElementById("options").innerHTML.split("rank")[1].split("counter(")[1].split(",")[0];
  7913. if (time > 0)
  7914. return false;
  7915. if (!window.location.pathname.endsWith("/activities/")) {
  7916. reload("doDailyTask14b");
  7917. }
  7918. else {
  7919. if (time == 0) {
  7920. var lastCollectTime = PGu_getValue(nameLastCollectTime,0);
  7921. if (PGu_getValue("KiezTourAct", 0) == 1 || !PGu_getValue("AutoCollect", false))
  7922. lastCollectTime = 0;
  7923. var timeOptions = document.getElementsByName("time")[0];
  7924. timeOptions.selectedIndex = lastCollectTime;
  7925. if (!PGu_getValue("AutoCollect", false))
  7926. PGu_setValue("BottleCollectAbort", true);
  7927. }
  7928. trace("Starte Sammeln für " + timeOptions.options[lastCollectTime].value + " Minuten", 2);
  7929. incrDailyTry(tagesdatum, tries);
  7930. document.getElementsByName('Submit2')[0].click();
  7931. }
  7932. break;
  7933. // Jetzt Flaschen verkaufen
  7934. case 15: incrDailyTry(tagesdatum, tries);
  7935. sellBottles(1, 0, "");
  7936. break;
  7937. // Jetzt Plunder verkaufen
  7938. case 16: var pid = PGu_getValue("sellPlunder", "0");
  7939. if (pid == "0")
  7940. return false;
  7941. incrDailyTry(tagesdatum, tries);
  7942. sellPlunder (pid, 1, "sellPlunder");
  7943. break;
  7944. // Jetzt den Stadtteil/das Gebiet wechseln.
  7945. case 17: GM_xmlhttpRequest({method: 'GET', url: prothost + '/city/district/', onload: function(responseDetails) {
  7946. var districts = responseDetails.responseText.split("/city/district/buy/");
  7947. var inDist = "";
  7948. var toDist = "";
  7949. var kauf = [];
  7950. for (var i = 1; i < districts.length; i++) {
  7951. if (districts[i].indexOf('name="id') != -1) {
  7952. var inputs = districts[i].split("</tr")[0].split("<input ");
  7953. var id = "";
  7954. for (var j = 1; j < inputs.length; j++) {
  7955. var name = inputs[j].split('name="')[1].split('"')[0];
  7956. var val = inputs[j].split('value="')[1].split('"')[0];
  7957. if (name == "id")
  7958. id = val;
  7959. else if (name == "submitForm") {
  7960. if (val == "Bewohnt")
  7961. inDist = id;
  7962. else if (val == "Einziehen")
  7963. toDist = id;
  7964. else if (inputs[1].indexOf('title="Preis"') != -1) {
  7965. var preis = inputs[1].split('title="Preis"')[1].split(">")[1].split("<")[0].match(/[\d.,]+/)[0].replace(/[.,]/g,"");
  7966. if (Number(preis) == 0)
  7967. kauf.push(id);
  7968. }
  7969. }
  7970. }
  7971. if (inDist != "" && toDist != "")
  7972. break;
  7973. }
  7974. }
  7975. var modus = "";
  7976. if (toDist == "" && kauf.length > 0) {
  7977. toDist = kauf[0];
  7978. modus = "x";
  7979. }
  7980. if (toDist != "") {
  7981. incrDailyTry(tagesdatum, tries);
  7982. moveTo(toDist, inDist, modus);
  7983. }
  7984. }});
  7985. break;
  7986. // Jetzt eine Waffe verkaufen.
  7987. case 18: GM_xmlhttpRequest({method: 'GET', url: prothost + '/stock/armoury/', onload: function(responseDetails) {
  7988. var sell = responseDetails.responseText.split("/armoury/sell/");
  7989. var selWeapon = "";
  7990. var found = false;
  7991. for (var i = 1; i < sell.length; i++) {
  7992. if (sell[i].indexOf('name="id') != -1) {
  7993. var id = sell[i].split("value=");
  7994. if (id.length > 1) {
  7995. var weaponid = id[1].split('"')[1];
  7996. if (sell[i-1].split("<input ").pop().indexOf("disabled") != -1)
  7997. selWeapon = weaponid;
  7998. if (id[1].split('"')[1] == "1")
  7999. found = true;
  8000. if (found && selWeapon != "")
  8001. break;
  8002. }
  8003. }
  8004. }
  8005. if (found) {
  8006. incrDailyTry(tagesdatum, tries);
  8007. sellWeapon("1");
  8008. }
  8009. else {
  8010. if (GetMoney(document) < 2) {
  8011. var pid = PGu_getValue("sellPlunder1", "0");
  8012. if (pid != "0")
  8013. sellPlunder (pid, 1, "sellPlunder1");
  8014. }
  8015. else {
  8016. PGu_setValue("selWeapon", selWeapon);
  8017. buyWeapon("1");
  8018. }
  8019. }
  8020. }
  8021. });
  8022. break;
  8023. // Jetzt einem anderen Penner spenden.
  8024. case 19: if (PGu_getValue("donationlink", "") == "")
  8025. return false;
  8026. incrDailyTry(tagesdatum, tries);
  8027. GM_xmlhttpRequest({method: 'GET', url: PGu_getValue("donationlink", ""), onload: function(responseDetails) {
  8028. reload("doDailyTask19");
  8029. }});
  8030. break;
  8031. // Jetzt Zahnstocher/Distel/Weihrauch/Kieselsteine kaufen.
  8032. case 20: GM_xmlhttpRequest({method: 'GET', url: prothost + '/stock/armoury/', onload: function(responseDetails) {
  8033. var sell = responseDetails.responseText.split("/armoury/sell/");
  8034. var selWeapon = "";
  8035. var found = false;
  8036. for (var i = 1; i < sell.length; i++) {
  8037. if (sell[i].indexOf('name="id') != -1) {
  8038. var id = sell[i].split("value=");
  8039. if (id.length > 1) {
  8040. var weaponid = id[1].split('"')[1];
  8041. if (sell[i-1].split("<input ").pop().indexOf("disabled") != -1)
  8042. selWeapon = weaponid;
  8043. if (id[1].split('"')[1] == "1")
  8044. found = true;
  8045. if (found && selWeapon != "")
  8046. break;
  8047. }
  8048. }
  8049. }
  8050. if (PGu_getValue("selWeapon", "") == "")
  8051. PGu_setValue("selWeapon", selWeapon);
  8052. if (!found) {
  8053. if (GetMoney(document) < 2) {
  8054. var pid = PGu_getValue("sellPlunder1", "0");
  8055. if (pid == "0")
  8056. return;
  8057. sellPlunder (pid, 1, "sellPlunder1");
  8058. }
  8059. else {
  8060. incrDailyTry(tagesdatum, tries);
  8061. buyWeapon("1");
  8062. }
  8063. }
  8064. else
  8065. sellWeapon("1");
  8066. }
  8067. });
  8068. break;
  8069. // Tierische Weihnachten
  8070. // Einkaufen in letzter Sekunde
  8071. default: return false;
  8072. break;
  8073. }
  8074. return true;
  8075. }
  8076.  
  8077. function doLogout() {
  8078. GM_xmlhttpRequest({method: 'GET', url: prothost + '/logout/', onload: function(responseDetails) {
  8079. window.location.href = prothost + "/logout/";
  8080. }});
  8081. }
  8082.  
  8083. function CheckDaily() {
  8084. PG_log("CheckDaily");
  8085. if (!PGu_getValue("autoDaily", false))
  8086. return false;
  8087.  
  8088. var town = ["HH", "B", "MU", "HR", "K", "SY", "ML", "VT", "AT"];
  8089. if (town.indexOf(TOWNEXTENSION) == -1)
  8090. return;
  8091.  
  8092. if (PGu_getValue("BottleCollectAbort", false)) {
  8093. if (document.getElementById("options").innerHTML.indexOf("crime") != -1)
  8094. return;
  8095. var time = Number(document.getElementById("options").innerHTML.split("rank")[1].split("counter(")[1].split(",")[0]);
  8096. if (time == 0) {
  8097. PGu_setValue("BottleCollectAbort", false);
  8098. return;
  8099. }
  8100. if(window.location.pathname.indexOf("/activities/") == -1)
  8101. reload("CheckDaily");
  8102. else
  8103. document.getElementsByName('Submit2')[0].click();
  8104. }
  8105.  
  8106. if (PGu_getValue("chooseDistrict", true) && PGu_getValue("homeDist", "") != "") {
  8107. moveTo(PGu_getValue("homeDist"), "", "");
  8108. return true;
  8109. }
  8110.  
  8111. if (PGu_getValue("craftindex", 0) < 0) {
  8112. if (document.getElementById("options").innerHTML.indexOf("crime") != -1) {
  8113. var time = PGu_getValue("bottletime", 0) + 1;
  8114. if (time > 9999999999)
  8115. time = 0;
  8116. }
  8117. else
  8118. var time = Number(document.getElementById("options").innerHTML.split("rank")[1].split("counter(")[1].split(",")[0]);
  8119. if (time > PGu_getValue("bottletime", 0)) {
  8120. PGu_setValue("craftindex", 0); // Flaschen wurden gesammelt, Plunder basteln wieder testen
  8121. PGu_setValue("bottletime", 0);
  8122. }
  8123. }
  8124.  
  8125. var today = new Date();
  8126. var tagesdatum = FormatDate(today);
  8127. if (PGu_getValue("dailyTaskDone", "xxx") == tagesdatum) {
  8128. var selWeapon = PGu_getValue("selWeapon", "");
  8129. if (selWeapon != "")
  8130. buyWeapon(selWeapon == "1"?selWeapon:"0");
  8131. return;
  8132. }
  8133.  
  8134. tryDaily = PGu_getValue("tryDailyTask", ";0").split(";");
  8135. if (tryDaily[0] != tagesdatum) {
  8136. var tries = 0;
  8137. PGu_delete("tryDailyTask");
  8138. }
  8139. else
  8140. var tries = Number(tryDaily[1]);
  8141. if (tryDaily[0] == tagesdatum && (tries >= 5 && today.getHours() < 23 || tries >= 10 && today.getHours() >= 23))
  8142. return;
  8143.  
  8144. if (PGu_getValue("dtsitting") && m_ownusername.toLowerCase() == GM_getValue(host + "_username", "").toLowerCase() && GM_getValue(host+"_trysitting", "") != tagesdatum) {
  8145. var dtsitttime = PGu_getValue("dtsitttime", latestDTtime).split(":");
  8146. if (Number(dtsitttime[0])*60 + Number(dtsitttime[1]) <= today.getHours()*60 + today.getMinutes()) {
  8147. if(!window.location.pathname.endsWith("/sitting/")){
  8148. window.location.href = prothost + "/sitting/";
  8149. return;
  8150. }
  8151. var trs = document.getElementById("content").getElementsByTagName("tr");
  8152. var rdays = Number(trs[3].getElementsByTagName("td")[1].innerHTML.split("</")[0].split(">")[1]);
  8153. var last = trs[5].getElementsByTagName("td")[1].innerHTML.split("</")[0].split(">")[1];
  8154. var lmth = Number(last.substr(3, 2));
  8155. var lday = Number(last.substr(0, 2));
  8156. var ltime = last.split(" ")[1];
  8157. var year = today.getFullYear();
  8158. if (today.getMonth() == 11 && lmth == 1)
  8159. year++;
  8160. var ldate = new Date(year, lmth-1, lday, Number(ltime.substr(0, 2)), Number(ltime.substr(3, 2)), 59);
  8161. var pwsitting = document.getElementsByName("sitting_password")[0].value;
  8162. if (ldate.getTime() < today.getTime() || ldate.getTime() > today.getTime() + (30 - rdays) * 864000000 || GM_getValue(host+"_trysitting", "") == tagesdatum || pwsitting == "") {
  8163. if (rdays == 0) {
  8164. GM_setValue(host+"_trysitting", tagesdatum);
  8165. trace("Keine Sitting-Tage mehr übrig!!", 1);
  8166. return;
  8167. }
  8168. pwsitting = "heute" + today.getDate();
  8169. GM_setValue(host+"_trysitting", "set" + tagesdatum);
  8170. HttpPost(document.getElementById("content").innerHTML, 1, ["sitting_password", pwsitting, "pw_days", "1"],
  8171. function() { trace("Sittingpasswort gesetzt", 1); reload("Sitting", "/sitting/"); });
  8172. return;
  8173. }
  8174. else if (GM_getValue(host+"_trysitting", "") != tagesdatum) {
  8175. GM_setValue(host+"_trysitting", tagesdatum);
  8176. GM_setValue(host+"_pwsitting", pwsitting);
  8177. GM_deleteValue(host + "_pwsitting_count");
  8178. trace("Ausloggen für Sitting", 1);
  8179. incrDailyTry(tagesdatum, tries);
  8180. doLogout();
  8181. return;
  8182. }
  8183. }
  8184. }
  8185.  
  8186. var taskTexts = [];
  8187. taskTexts[0] = 'Jetzt eine PN an einen Freund versenden';
  8188. if (TOWNEXTENSION == 'AT' || TOWNEXTENSION == 'VT')
  8189. taskTexts[1] = 'Eine ';
  8190. else
  8191. taskTexts[1] = 'Ein ';
  8192. taskTexts[1] += crimetxt + ' erfolgreich begehen';
  8193. taskTexts[2] = 'Einen Kampf gewinnen';
  8194. taskTexts[3] = 'Jetzt Lose kaufen';
  8195. taskTexts[4] = 'Jetzt in der SB posten';
  8196. taskTexts[5] = 'Jetzt im Supermarkt Getränke kaufen.';
  8197. taskTexts[6] = 'Jetzt einen Begleiterkampf aktivieren';
  8198. taskTexts[7] = 'Jetzt einmal 100% sauber werden';
  8199. taskTexts[8] = 'Geld in deine Bandenkasse einzahlen';
  8200. taskTexts[9] = 'Plunder in die Plunderbank deiner Bande einzahlen';
  8201. taskTexts[10] = 'Eine Begleiterweiterbildung starten';
  8202. taskTexts[11] = 'Einen Plunder basteln';
  8203. taskTexts[12] = 'Jetzt einen kleinen Snack essen';
  8204. taskTexts[13] = 'Promillepegel über 2‰';
  8205. taskTexts[14] = 'Einmal ' + flaschentxt + 'sammeln starten';
  8206. taskTexts[15] = 'Jetzt ' + flaschentxt + ' verkaufen';
  8207. taskTexts[16] = 'Jetzt Plunder verkaufen';
  8208. if (TOWNEXTENSION == 'SY' || TOWNEXTENSION == 'ML' || TOWNEXTENSION == 'VT' || TOWNEXTENSION == 'AT')
  8209. taskTexts[17] = 'Jetzt das Gebiet wechseln.';
  8210. else
  8211. taskTexts[17] = 'Jetzt den Stadtteil wechseln.';
  8212. taskTexts[18] = 'Jetzt eine Waffe verkaufen.';
  8213. taskTexts[19] = 'Jetzt einem anderen Penner spenden.';
  8214. if (TOWNEXTENSION == 'SY' || TOWNEXTENSION == 'ML')
  8215. taskTexts[20] = 'Jetzt Distel kaufen.';
  8216. else if (TOWNEXTENSION == 'VT')
  8217. taskTexts[20] = 'Jetzt Weihrauch kaufen.';
  8218. else if (TOWNEXTENSION == 'AT')
  8219. taskTexts[20] = 'Jetzt Kieselsteine kaufen.';
  8220. else
  8221. taskTexts[20] = 'Jetzt Zahnstocher kaufen.';
  8222. taskTexts[21] = 'Tierische Weihnachten';
  8223. taskTexts[22] = 'Einkaufen in letzter Sekunde';
  8224. GM_xmlhttpRequest({method: 'GET', url: prothost + '/daily/', onload: function(responseDetails) {
  8225. var content = responseDetails.responseText;
  8226. // Wenn die Seite abgerufen werden konnte (kein Seitenladefehler)
  8227. if (content.indexOf("<strong>Mein Penner</strong>") != -1) {
  8228. var task = content.split('min-height:40px;">')[1];
  8229. if (task.indexOf("<strong>") != -1) {
  8230. task = task.split('<strong>')[1].split('</strong>')[0];
  8231. PG_log ("Aufgabe: " + task);
  8232. doDailyTask(taskTexts.indexOf(task));
  8233. }
  8234. else {
  8235. PGu_setValue("dailyTaskDone", tagesdatum);
  8236. PGu_setValue("losemiss_wait", 0);
  8237. PGu_setValue("craftindex", 0);
  8238. if (PGu_getValue("AutoCrimePicMerk", "") != "") {
  8239. PGu_setValue("AutoCrimePic", PGu_getValue("AutoCrimePicMerk", ""));
  8240. PGu_setValue("AutoCrimePicMerk", "");
  8241. }
  8242. }
  8243. }
  8244. }});
  8245. return;
  8246. }
  8247.  
  8248. function HttpPost(src, fname, vals, fkt) {
  8249. if (isNaN(fname)) {
  8250. var pos = src.indexOf('name="'+fname);
  8251. if (pos == -1)
  8252. pos = src.indexOf('id="'+fname);
  8253. if (pos == -1)
  8254. return;
  8255. pos = src.lastIndexOf("<form", pos);
  8256. }
  8257. else {
  8258. var fnum = Number(fname);
  8259. var pos = -1;
  8260. for (var i = 1; i <= fnum; i++) {
  8261. pos = src.indexOf("<form", pos+1);
  8262. if (pos == -1)
  8263. return;
  8264. }
  8265. }
  8266. var form = src.substr(pos).split("</form");
  8267. while (form[0].lastIndexOf("<form") != 0) {
  8268. form[0] = form[0].substr(0, form[0].lastIndexOf("<form")) + form[1].substr(1);
  8269. form.splice(1, 1);
  8270. }
  8271.  
  8272. var addr = form[0].split('action="')[1].split('"')[0];
  8273. if (addr == "")
  8274. addr = "/" + src.substr(pos).split("setupForm('/")[1].split("'")[0];
  8275. if (addr.startsWith("/"))
  8276. addr = prothost + addr;
  8277. var inputs = form[0].replace(/<select/g, "<input").split("<input");
  8278. var data = "";
  8279. for (var i = 1; i < inputs.length; i++) {
  8280. var name = inputs[i].split('name="');
  8281. if (name.length > 1)
  8282. name = name[1].split('"')[0];
  8283. else
  8284. continue;
  8285. var value = "";
  8286. for (var j = 0; j < vals.length; j+=2)
  8287. if (vals[j] == name)
  8288. break;
  8289. if (j < vals.length) {
  8290. value = vals[j+1];
  8291. vals.splice(j, 2);
  8292. }
  8293. else {
  8294. if (inputs[i].indexOf("<option") != -1) {
  8295. value = document.getElementsByName(name)[0].value;
  8296. }
  8297. else {
  8298. value = inputs[i].split('value="');
  8299. if (value.length > 1)
  8300. value = value[1].split('"')[0];
  8301. else {
  8302. continue;
  8303. }
  8304. }
  8305. }
  8306. data += "&" + name + "=" + value;
  8307. }
  8308. var predata = "";
  8309. for (var j = 0; j < vals.length; j+=2)
  8310. predata += "&" + vals[j] + "=" + vals[j+1];
  8311. data = predata + data;
  8312. trace("Post: " + addr + "?" + data.substr(1), 2);
  8313. GM_xmlhttpRequest({method: 'POST',
  8314. url: addr,
  8315. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  8316. data: encodeURI(data.substr(1)),
  8317. onload: function(responseDetails) {
  8318. fkt(responseDetails);
  8319. }
  8320. });
  8321. }
  8322.  
  8323. function getOverviewPage(callfkt, par1, par2) {
  8324. function getOverviewData() {
  8325. trace("GetOverviewData", 8);
  8326. myATT = overviewcontent.split('class="att"')[1].split("<")[0].split(">")[1];
  8327. myDEF = overviewcontent.split('class="def"')[1].split("<")[0].split(">")[1];
  8328. getTimers();
  8329. if (expertMode && PGu_getValue("downfightauto", false) && getSeks(counter) + getSeks(fcounter) < 60)
  8330. updDFList();
  8331. var fass = overviewcontent.split('class="first"')[1].split("Fassungsverm")[1].match(/[\d.,]+/);
  8332. maxFass = Number(fass[0].replace(/[.,]/g,'')) / 100;
  8333. if (overviewcontent.indexOf("Ende der Runde") != -1) {
  8334. var rende = getSeks(overviewcontent.split("Ende der Runde")[1].split("</strong")[0].split(">").pop());
  8335. var today = new Date();
  8336. rende = rende * 1000 + today.getTime() + 60000;
  8337. rende = rende - rende % 3600000;
  8338. var rundenende = Number(PG_getValue("rundenende", "0"));
  8339. if (rende != rundenende) {
  8340. if (rundenende > 0 && today.getTime() > rundenende)
  8341. PG_setValue("lastrestart", (rundenende + 30 * 3600000).toString());
  8342. PG_setValue("rundenende", rende.toString());
  8343. }
  8344. }
  8345. var today = new Date();
  8346. var tagesdatum = FormatDate(today);
  8347. var icons = overviewcontent.split('class="icons"');
  8348. for (var i = 0; i < icons.length; i++)
  8349. if (icons[i].indexOf("tagesaufgabe") != -1) {
  8350. if (icons[i].split("</tr>")[0].split("<a ")[0].trim().endsWith("<!--"))
  8351. PGu_setValue("dailyTaskDone", tagesdatum);
  8352. else
  8353. PGu_delete("dailyTaskDone");
  8354. break;
  8355. }
  8356. if (i >= icons.length) {
  8357. var lis = overviewcontent.split('id="summary"')[1].split('class="status"')[1].split('class="settings"')[0].split("<li>");
  8358. if (lis[lis.length-1].indexOf("korkenhaken") == -1)
  8359. PGu_delete("dailyTaskDone");
  8360. else
  8361. PGu_setValue("dailyTaskDone", tagesdatum);
  8362. }
  8363. return;
  8364. }
  8365.  
  8366. trace("GetOverviewPage", 8);
  8367. if (overviewcontent == "" && window.location.pathname.endsWith("/overview/") && document.getElementById("wrap")) {
  8368. overviewcontent = document.getElementById("wrap").innerHTML;
  8369. getOverviewData();
  8370. }
  8371.  
  8372. if (overviewcontent != "") {
  8373. trace("GetOverviewPage: " + (callfkt != undefined?"callfkt":"return"), 8);
  8374. if (callfkt != undefined)
  8375. callfkt(par1, par2);
  8376. return;
  8377. }
  8378.  
  8379. trace("GetOverviewPage: get overview page", 8);
  8380. GM_xmlhttpRequest({method:"GET", url: prothost + '/overview/', onload:function(responseDetails) {
  8381. // Wenn die Übersichtsseite abgerufen werden konnte (kein Seitenladefehler)
  8382. if (responseDetails.responseText.indexOf('id="wrap"') != -1) {
  8383. // Content der Übersichtsseite speichern
  8384. overviewcontent = responseDetails.responseText.split('id="wrap')[1];
  8385. getOverviewData();
  8386. trace("GetOverviewPage: " + (callfkt != undefined?"callfkt2":"return"), 8);
  8387. if (callfkt != undefined)
  8388. callfkt();
  8389. return;
  8390. }
  8391. setTimeout(getOverviewPage, 500);
  8392. }});
  8393. }
  8394. function checksum(s, trenn)
  8395. {
  8396. var chk = 0;
  8397. var m = 1;
  8398. var t = trenn.charCodeAt(0);
  8399. for (var j = 0; j < s.length; j++) {
  8400. for (var i = 0; i < s[j].length; i++) {
  8401. chk += s[j].charCodeAt(i) * m;
  8402. m++;
  8403. }
  8404. chk += t * m;
  8405. m++;
  8406. }
  8407.  
  8408. return chk.toString();
  8409. }
  8410.  
  8411. function exportVars(expert, quiet) {
  8412. trace("exportVars", 1);
  8413. var vars = ["Script", THISSCRIPTNAME];
  8414. var gm_vars = GM_listValues().sort();
  8415. var deleted = 0;
  8416. var count = 0;
  8417. for (var i = 0; i < gm_vars.length; i++) {
  8418. if (gm_vars.indexOf(gm_vars[i]) < i)
  8419. continue;
  8420. if (gm_vars[i] == "" || gm_vars[i].match(new RegExp(/[^\d]0$/)) || gm_vars[i].match(new RegExp(/[\r\f\n\t<>\"\']/))) {
  8421. GM_deleteValue(gm_vars[i]);
  8422. deleted++;
  8423. }
  8424. else {
  8425. if (gm_vars[i].length > 50) {
  8426. if (expert && !quiet)
  8427. var conf = confirm("Variable löschen: " + gm_vars[i]);
  8428. else
  8429. var conf = true;
  8430. if (conf) {
  8431. GM_deleteValue(gm_vars[i]);
  8432. deleted++;
  8433. continue;
  8434. }
  8435. }
  8436. var val = GM_getValue(gm_vars[i], "xyzundefinedzyx");
  8437. if (val == "xyzundefinedzyx" || val == null)
  8438. continue;
  8439. if (typeof(val) == "number")
  8440. val = "N" + val;
  8441. else if (typeof(val) == "boolean")
  8442. val = "B" + (val?1:0);
  8443. else if (typeof(val) == "string") {
  8444. if (val.indexOf("§") != -1) {
  8445. if (expert && !quiet)
  8446. alert("Trennzeichen in " + gm_vars[i]);
  8447. break;
  8448. }
  8449. val = "S" + val.replace(String.fromCharCode(0), "");
  8450. }
  8451. else {
  8452. if (expert && !quiet)
  8453. alert(gm_vars[i] + " vom Typ " + typeof(val) + ": " + val);
  8454. break;
  8455. }
  8456. vars.push(gm_vars[i]);
  8457. vars.push(val);
  8458. count++;
  8459. }
  8460. }
  8461. if (i < gm_vars.length)
  8462. if (quiet)
  8463. GM_setClipboard("Fehler!!");
  8464. else
  8465. alert('Export wegen Fehler abgebrochen');
  8466. else {
  8467. vars.push(checksum(vars, "§"));
  8468. GM_setClipboard(vars.join("§"));
  8469. if (!quiet)
  8470. if (deleted > 0)
  8471. alert (count + " Variablen in Zwischenablage exportiert, " + deleted + " Variablen gelöscht.");
  8472. else
  8473. alert (count + " Variablen in Zwischenablage exportiert");
  8474. }
  8475. return;
  8476. }
  8477.  
  8478. // Die eigentliche Funktion
  8479. function doTheAction () {
  8480. if (document.getElementsByClassName('zleft profile-data').length > 0)
  8481. oldVersion = 0;
  8482. if (GM_getValue(host + "_pwsitting", "x") == "")
  8483. GM_deleteValue(host + "_pwsitting");
  8484.  
  8485. var refrInt = 10;
  8486. var languages = ["bl_DE", "mu_DE", "kl_DE", "de_DE", "hr_DE", "s6_DE", "s7_DE", "sy_DE",
  8487. "ml_DE", "vt_DE", "at_DE", "us_EN", "kr_PL", "pl_PL", "wr_PL", "ma_FR",
  8488. "fr_FR", "cr_FR", "ba_ES", "es_ES", "er_ES", "sp_BR", "pt_BR", "ru_RU", "en_EN"];
  8489. var townext = ['B', 'MU', 'K', 'HH', 'HR', 'OP', 'ATH', 'SY',
  8490. 'ML', 'VT', 'AT', 'NY', 'KR', 'WA', 'WA', 'MS',
  8491. 'PA', 'PA', 'BA', 'MD', 'MD', 'SP', 'RJ', 'MO', 'LO'];
  8492. var indx = languages.indexOf(language);
  8493. if (indx >= 0)
  8494. TOWNEXTENSION = townext[indx];
  8495. if (TOWNEXTENSION == "AT") {
  8496. refrInt = 5;
  8497. pflaschen = "Perlen";
  8498. flaschentxt = "Perlen";
  8499. crimetxt = "Sabotage";
  8500. }
  8501. else if (TOWNEXTENSION == "VT")
  8502. crimetxt = "Sünde";
  8503.  
  8504. PGu_setValue("RefreshInterval", refrInt);
  8505. trace("DoTheAction: " + m_ownuserid + "/" + TOWNEXTENSION + "/" + refrInt, 2);
  8506.  
  8507. /*-*/
  8508. if (GM_getValue(host + "_autologin", "xxx") == "xxx") {
  8509. GM_setValue(host + "_autologin", GM_getValue("www." + host + "_autologin", false));
  8510. GM_setValue(host + "_username", GM_getValue("www." + host + "_username", ""));
  8511. GM_setValue(host + "_password", GM_getValue("www." + host + "_password", ""));
  8512. GM_deleteValue("www." + host + "_autologin");
  8513. GM_deleteValue("www." + host + "_username");
  8514. GM_deleteValue("www." + host + "_password");
  8515. GM_deleteValue("change." + host + "_autologin");
  8516. GM_deleteValue("change." + host + "_username");
  8517. GM_deleteValue("change." + host + "_password");
  8518. }
  8519.  
  8520. var login = document.getElementById("loginform");
  8521. if (login) {
  8522. login.addEventListener('submit', function(event) {
  8523. var input = document.getElementById("loginform").getElementsByTagName("input");
  8524. for (var i = 0; i < input.length; i++) {
  8525. if (input[i].name == "username" || input[i].name == "password" && GM_getValue(host + "_pwsitting", "") == "")
  8526. GM_setValue(host + "_" + input[i].name, input[i].value);
  8527. }
  8528. GM_setValue(host + "_autologin", true);
  8529. return true;
  8530. }, false);
  8531. }
  8532.  
  8533. var myprof = document.getElementById("my-profile-new");
  8534. if (!myprof)
  8535. myprof = document.getElementById("my-profile");
  8536. if (!myprof) {
  8537. function doLogin() {
  8538.  
  8539. var login = document.getElementById("loginform");
  8540. var input = login.getElementsByTagName("input");
  8541. var i = input.length - 1;
  8542. if (GM_getValue(host + "_username", "") != "" && (GM_getValue(host + "_password", "") != "" || GM_getValue(host + "_pwsitting", "") != "")) {
  8543. document.getElementById("login_username").value = GM_getValue(host + "_username", "");
  8544. if (GM_getValue(host + "_pwsitting", "x") == "x")
  8545. document.getElementById("password").value = GM_getValue(host + "_password", "");
  8546. else {
  8547. document.getElementById("password").value = GM_getValue(host + "_pwsitting", "");
  8548. GM_setValue(host + "_pwsitting", "x");
  8549. }
  8550. input[i].click();
  8551. }
  8552. else if (document.getElementById("login_username").value != "" &&
  8553. document.getElementById("password").value != "") {
  8554. input[i].click();
  8555. }
  8556. }
  8557. var user = document.getElementById("login_username");
  8558. /* if (user) {
  8559. var chb = document.createElement("input");
  8560. chb.type="checkbox";
  8561. chb.id="autologin";
  8562. chb.title="Auto-Login";
  8563. user.parentNode.appendChild(chb, user);
  8564. document.getElementById("autologin").checked = GM_getValue(host + "_autologin", false);
  8565. // Click-Handler hinzufügen
  8566. document.getElementById("autologin").addEventListener("click", function(event) {
  8567. // Klickstatus speichern
  8568. GM_setValue(host + "_autologin", this.checked);
  8569. }, false);
  8570. }*/
  8571. if (GM_getValue(host + "_pwsitting", "") != "") {
  8572. if (GM_getValue(host + "_pwsitting", "") == "x")
  8573. GM_deleteValue(host + "_pwsitting");
  8574. window.setTimeout(doLogin, 2000);
  8575. }
  8576. else if (GM_getValue(host + "_autologin", false))
  8577. window.setTimeout(doLogin, 10000);
  8578. return;
  8579. }
  8580. else if (myprof.getElementsByTagName("form").length > 0) {
  8581. var input = myprof.getElementsByTagName("input");
  8582. if (input.length > 0) {
  8583. myprof.getElementsByTagName("form")[0].addEventListener('mouseup', function(event) {
  8584. GM_setValue(host + "_autologin", false);
  8585. }, false);
  8586. }
  8587. }
  8588. var mobBut = document.getElementById("mobile_button");
  8589. if (mobBut)
  8590. if (mobBut.innerHTML == "Logout") {
  8591. mobBut.getElementsByTagName("form")[0].addEventListener('mouseup', function(event) {
  8592. GM_setValue(host + "_autologin", false);
  8593. }, false);
  8594. }
  8595.  
  8596. // ***********************************************************************************************
  8597. // ***********************************************************************************************
  8598. // -------- Start of program--------------
  8599. // ***********************************************************************************************
  8600. // ***********************************************************************************************
  8601.  
  8602. trace("Start", 8);
  8603. if (document.getElementById("ntext")) {
  8604. var menge = document.getElementById("ntext").innerHTML.split("<p>")[1].split("<")[0];
  8605. var pos = menge.indexOf(" gefunden");
  8606. if (pos != -1) {
  8607. var pos2 = menge.lastIndexOf(" ", pos-1) + 1;
  8608. trace(menge.substr(pos2, pos-pos2) + " gefunden: " + menge.match(/\d+/) + "/" + menge, 1);
  8609. }
  8610. else {
  8611. pos = menge.indexOf("suche gegangen");
  8612. if (pos != -1) {
  8613. var pos2 = menge.lastIndexOf(" ", pos) + 1;
  8614. trace(menge.substr(pos2, pos-pos2) + "suche gestartet: " + menge.match(/[\d.,]+/) + " Minuten" + "/" + menge, 1);
  8615. }
  8616. }
  8617. }
  8618.  
  8619. if(window.location.pathname.indexOf("/emergency/") != -1){
  8620. if (GetMoney(document) >= 1000)
  8621. document.getElementById("submitForm1").click();
  8622. return;
  8623. }
  8624. getOverviewPage(mainFunc1);
  8625. }
  8626.  
  8627. function mainFunc1() {
  8628. trace("mainFunc1", 8);
  8629. m_ownuserid = getOwnUserID();
  8630. if (document.getElementsByClassName('zleft profile-data')[0].getElementsByClassName("user_name").length > 0)
  8631. m_ownusername = document.getElementsByClassName('zleft profile-data')[0].getElementsByClassName("user_name")[0].innerHTML;
  8632. else
  8633. m_ownusername = document.getElementsByClassName('zleft profile-data')[0].getElementsByTagName("a")[0].getElementsByTagName("span")[0].innerHTML;
  8634.  
  8635. var today = new Date();
  8636. var tagesdatum = FormatDate(today);
  8637. // GM_deleteValue(host + "_pwsitting");
  8638.  
  8639. if(window.location.pathname.endsWith("/overview/")){
  8640. if (document.getElementsByClassName('zleft profile-data')[0].innerHTML.indexOf('Sittingmodus') != -1) {
  8641. trace("Sittingmodus !!!!", 1);
  8642. if (PGu_getValue("dailyTaskDone", "") != tagesdatum) {
  8643. var lis = document.getElementById("summary").getElementsByClassName("status")[0].getElementsByTagName("li");
  8644. if (lis.length == 8)
  8645. lis[lis.length-1].getElementsByTagName("a")[0].click();
  8646. else
  8647. document.getElementById("summary").parentNode.parentNode.parentNode.getElementsByTagName("h4")[1].parentNode.getElementsByTagName("a")[0].click();
  8648. }
  8649. else {
  8650. if (GM_getValue(host + "_pwsitting", "x") != "x")
  8651. GM_setValue(host + "_pwsitting", "x");
  8652. trace("Ausloggen aus Sittingmodus !!!!", 1);
  8653. doLogout();
  8654. }
  8655. return;
  8656. }
  8657. else if (GM_getValue(host + "_pwsitting", "x") != "x") {
  8658. tryDaily = PGu_getValue("tryDailyTask", ";0").split(";");
  8659. if (tryDaily[0] != tagesdatum) {
  8660. var tries = 0;
  8661. PGu_delete("tryDailyTask");
  8662. }
  8663. else
  8664. var tries = Number(tryDaily[1]);
  8665. if (tryDaily[0] == tagesdatum && (tries >= 5 && today.getHours() < 23 || tries >= 10 && today.getHours() >= 23)) {
  8666. GM_deleteValue(host + "_pwsitting");
  8667. GM_deleteValue(host + "_pwsitting_count");
  8668. }
  8669. else if (GM_getValue(host + "_pwsitting_count", 0) <= 5) {
  8670. GM_setValue(host + "_pwsitting_count", GM_getValue(host + "_pwsitting_count", 0) + 1);
  8671. trace("Ausloggen für Sittingmodus !!!!", 1);
  8672. incrDailyTry(tagesdatum, tries);
  8673. doLogout();
  8674. return;
  8675. }
  8676. else {
  8677. GM_deleteValue(host + "_pwsitting");
  8678. GM_deleteValue(host + "_pwsitting_count");
  8679. }
  8680. }
  8681. else {
  8682. GM_deleteValue(host + "_pwsitting");
  8683. GM_deleteValue(host + "_pwsitting_count");
  8684. }
  8685. }
  8686.  
  8687. if (window.location.href.endsWith("/fight/?to=" + PGu_getValue("nextDF", "")) && PGu_getValue("lastDF", "") != PGu_getValue("nextDF")) {
  8688. PGu_setValue("lastDF", PGu_getValue("nextDF", ""));
  8689. PGu_setValue("DFstarted", true);
  8690. trace("Starte Downfightangriff auf " + PGu_getValue("nextDF", ""), 2);
  8691. document.getElementsByName("Submit2")[0].click();
  8692. return;
  8693. }
  8694.  
  8695. if (expertMode)
  8696. GM_registerMenuCommand(THISSCRIPTNAME + ": Zeit für Variablenexport festlegen", function (event) {
  8697. var days = prompt("Tage: ", GM_getValue("exportDays", "")).replace(/[^\d]/g, ",");
  8698. if (days == null)
  8699. return;
  8700. if (days == "")
  8701. GM_deleteValue("exportDays");
  8702. else {
  8703. var dayarr = days.split(",");
  8704. for (var i = 0; i < dayarr.length; i++)
  8705. if (isNaN(dayarr[i]) || Number(dayarr[i]) < 1 || Number(dayarr[i]) > 7) {
  8706. alert("Bitte nur Zahlen von 1 (Mo) bis 7 (So) eingeben!!");
  8707. return;
  8708. }
  8709. GM_setValue("exportDays", days);
  8710. }
  8711. var times = prompt("Zeiten: ", GM_getValue("exportTimes", "")).replace(/[^\d]/g, ",");
  8712. if (times == null)
  8713. return;
  8714. if (times == "")
  8715. GM_deleteValue("exportTimes");
  8716. else {
  8717. var timarr = times.split(",");
  8718. for (var i = 0; i < timarr.length; i++)
  8719. if (isNaN(timarr[i]) || Number(timarr[i]) < 0 || Number(timarr[i]) > 23) {
  8720. alert("Bitte nur Zahlen von 0 bis 23 eingeben!!");
  8721. return;
  8722. }
  8723. GM_setValue("exportTimes", times);
  8724. }
  8725. });
  8726.  
  8727. GM_registerMenuCommand(THISSCRIPTNAME + ": alle Einstellungen exportieren", function (event) {
  8728. exportVars(expertMode, false);
  8729. });
  8730.  
  8731. GM_registerMenuCommand(THISSCRIPTNAME + ": alle Einstellungen importieren", function (event) {
  8732. var vars = prompt("Eingabe: ");
  8733. var gmvars = vars.split("§");
  8734. if (gmvars[0] != "Script" || gmvars[1] != THISSCRIPTNAME) {
  8735. alert("Eingabe ungültig!!");
  8736. return;
  8737. }
  8738. var chksum = gmvars.pop();
  8739. if (chksum != checksum(gmvars, "§")) {
  8740. alert("Importstring ist fehlerhaft. Kein Import möglich.");
  8741. return;
  8742. }
  8743.  
  8744. var gm_vars = GM_listValues();
  8745. for (var i = 0; i < gm_vars.length; i++)
  8746. GM_deleteValue(gm_vars[i]);
  8747. var count = 0;
  8748. for (var i = 2; i < gmvars.length; i+=2) {
  8749. var val = gmvars[i+1];
  8750. if (val.substr(0, 1) == "N")
  8751. val = Number(val.substr(1));
  8752. else if (val.substr(0, 1) == "B")
  8753. val = val.substr(1) == "1";
  8754. else if (val.substr(0, 1) == "S")
  8755. val = val.substr(1);
  8756. else {
  8757. alert("Fehler bei " + gmvars[i] + ": " + val);
  8758. continue;
  8759. }
  8760. GM_setValue(gmvars[i], val);
  8761. count++;
  8762. }
  8763. alert(count + " Variablen importiert.");
  8764. return;
  8765. });
  8766.  
  8767. if (typeof(Storage) !== "undefined") {
  8768. GM_registerMenuCommand(THISSCRIPTNAME + ": Einstellungen sichern", function (event) {
  8769. var c = true;
  8770. var savetime = Number(PG_getValue("saveTime", "0"));
  8771. if (savetime != 0)
  8772. c = confirm("Sollen die Einstellungen vom " + FormatDateTime(new Date(savetime)) + " überschrieben werden ?");
  8773. if (c) {
  8774. var time = String(today.getTime());
  8775. PG_setValue("saveTime", time);
  8776. var vars = [];
  8777. var gm_vars = [];
  8778. var gm_vars = GM_listValues();
  8779. for (var i = 0; i < gm_vars.length; i++)
  8780. if (gm_vars[i].startsWith(TOWNEXTENSION))
  8781. vars.push(gm_vars[i]);
  8782. for (var i = 0; i < vars.length; i++)
  8783. localStorage.setItem(vars[i], GM_getValue(vars[i]));
  8784. alert ("Es wurden " + vars.length + " Werte gesichert.");
  8785. }
  8786. });
  8787. var savetime = Number(PG_getValue("saveTime", "0"));
  8788. if (savetime != 0) {
  8789. GM_registerMenuCommand(THISSCRIPTNAME + ": Einstellungen wiederherstellen", function () {
  8790. var savetime = Number(PG_getValue("saveTime", "0"));
  8791. var now = (new Date(savetime));
  8792. if (confirm("Sollen die Einstellungen vom " + FormatDateTime(now) + " wiederhergestellt werden ?")) {
  8793. alert('Das dauert ein bisschen. Falls die Meldung "Nicht antwortendes Skript" angezeigt wird, bitte auf "Weiter ausführen" klicken');
  8794. var vars = [];
  8795. var gm_vars = [];
  8796. for (var i = 0; i < localStorage.length; i++)
  8797. if (localStorage.key(i).startsWith(TOWNEXTENSION))
  8798. vars.push(localStorage.key(i));
  8799. for (var i = 0; i < vars.length; i++)
  8800. GM_setValue(vars[i], localStorage.getItem(vars[i]));
  8801. alert ("Es wurden " + vars.length + " Werte wiederhergestellt.");
  8802. }
  8803. });
  8804. }
  8805. }
  8806.  
  8807. var maxfill = PGu_getValue("maxfillbottle", 90);
  8808. trace("maxfill = " + maxfill, 2);
  8809. if ((PGu_getValue("minMoney", 0) > 0 || maxfill > 0) && PGu_getValue("bottleprice", 0) > 0) {
  8810. var price = Number(document.getElementsByClassName("icon bottle")[0].innerHTML.split(">")[1].match(/\d+/));
  8811. if (price >= PGu_getValue("bottleprice", 0))
  8812. getOverviewPage(mainFunc2, maxfill, price);
  8813. }
  8814.  
  8815. trace("moneyOver = " + PGu_getValue("moneyOver", false), 2);
  8816. if (PGu_getValue("moneyOver", false) && PGu_getValue("maxMoney", -1) > 0 && PGu_getValue("maxMoneyPayIn", -1) > 0) {
  8817. var minMoney = 0;
  8818. if (PGu_getValue("minmoneychb", false))
  8819. minMoney = PGu_getValue("minMoney", 0);
  8820. var maxMoney = PGu_getValue("maxMoney", -1);
  8821. var payIn = PGu_getValue("maxMoneyPayIn", -1);
  8822. var money = GetMoney(document);
  8823. if (money > maxMoney && money - payIn >= minMoney) {
  8824. gangCredit(payIn, payIn);
  8825. }
  8826. }
  8827.  
  8828. var today = new Date();
  8829. var now = Math.floor(today.getTime()/1000);
  8830. CheckForUpdate(now, 86400);
  8831. var day = today.getDay();
  8832. var hour = today.getHours();
  8833.  
  8834. if (expertMode)
  8835. if (GM_getValue("exportDays", "").split(",").indexOf(((day+6) % 7 + 1).toString()) != -1 &&
  8836. GM_getValue("exportTimes", "").split(",").indexOf(((hour+1) % 24).toString()) != -1 && today.getMinutes() >= 50)
  8837. CheckForExport(now, 1000);
  8838.  
  8839. if (PGu_getValue("autoBuyNextHome", false))
  8840. CheckHomeBuy();
  8841.  
  8842. CheckSalary();
  8843.  
  8844. CheckMinigame();
  8845.  
  8846. CheckEnemygame();
  8847.  
  8848. CheckMission();
  8849.  
  8850. var eatDrink = PGu_getValue("eatDrink", "").toString();
  8851. if (eatDrink != "") {
  8852. var eatDrinkArr = eatDrink.split(",");
  8853. eatDrink = Number(eatDrinkArr[0]);
  8854. eatDrinkArr.splice(0, 1);
  8855. PGu_setValue("eatDrink", eatDrinkArr.join(","));
  8856. doEatDrink(eatDrink<0?2:1, eatDrink<0?-eatDrink:eatDrink);
  8857. }
  8858.  
  8859. if(window.location.pathname.endsWith("/daily/"))
  8860. window.setTimeout(CheckDaily, 5000);
  8861. else
  8862. CheckDaily();
  8863.  
  8864. CheckGhosts();
  8865.  
  8866. CheckPlunder();
  8867.  
  8868. /* var keys = GM_listValues();
  8869. for (var i = 0; i < keys.length; i++) {
  8870. var val = keys[i];
  8871. if (val.indexOf("ErrorCounter") != -1 && GM_getValue(val, "").length > 10) {
  8872. if (window.confirm(val + "(" + GM_getValue(val, "") + ") löschen ?"))
  8873. GM_deleteValue(val);
  8874. }
  8875. else if (val.indexOf("undefined") != -1 || val.indexOf("ErrorCounter") != -1)
  8876. if (window.confirm(val + " löschen ?"))
  8877. GM_deleteValue(val);
  8878. }
  8879. */
  8880.  
  8881. if (PGu_getValue(nameLastCollectTime, -1) == -1) {
  8882. var keys = GM_listValues();
  8883. for (var i = 0; i < keys.length; i++) {
  8884. var val = keys[i];
  8885. if (val.indexOf("-") != -1 || val.indexOf("pennersturm") != -1)
  8886. GM_deleteValue(val);
  8887. }
  8888. PGu_setValue(nameLastCollectTime, 0);
  8889. }
  8890.  
  8891. if (PGu_getValue("AutoPetCollect", false)) {
  8892. var cDay = PGu_getValue("AutoPetCollectDay", "0000000");
  8893. if (cDay.length < 7)
  8894. cDay += "0000000".substr(cDay.length - 7);
  8895. var cBeg = PGu_getValue("AutoPetCollectBegH", 11);
  8896. var cEnd = PGu_getValue("AutoPetCollectEndH", 12);
  8897. if (cDay[day] == "1" &&
  8898. ((cBeg < cEnd && hour >= cBeg && hour <= cEnd) ||
  8899. (cBeg >= cEnd && (hour >= cBeg || hour < cEnd))))
  8900. DoPetCollect();
  8901. }
  8902.  
  8903. if(window.location.pathname.indexOf("/activities/crime/") != -1){
  8904. var buttons = document.getElementsByClassName("button_area");
  8905. for (var i = 0; i < buttons.length; i++)
  8906. insertCheckBox3(buttons[i], i);
  8907. }
  8908. else if(window.location.pathname.indexOf("/activities/") != -1){
  8909. function insertBoxes (mode) {
  8910. PG_log("insertBoxes");
  8911. var loaded = (missionContent != "");
  8912. if (mode == 0) {
  8913. var timeOptions = document.getElementsByName("time")[0];
  8914. timeOptions.selectedIndex = PGu_getValue(nameLastCollectTime,0);
  8915. insertCheckBox(0, loaded);
  8916. insertCheckBox2();
  8917. }
  8918. else if (loaded)
  8919. insertCheckBox(1, loaded);
  8920.  
  8921. if (!loaded) {
  8922. PG_log("wait ...");
  8923. window.setTimeout(insertBoxes, 500, 1);
  8924. }
  8925. }
  8926. insertBoxes(0);
  8927. }
  8928. else if(window.location.pathname.indexOf("/overview/") != -1){
  8929. insertCheckBox4();
  8930. CheckPresent(document.getElementById("content").innerHTML);
  8931. }
  8932. else if(window.location.pathname.endsWith("/daily/")){
  8933. insertCheckBox5();
  8934. }
  8935. else if(window.location.pathname.endsWith("/missions/")){
  8936. // GM_setValue("showMissCtrl", 1);
  8937. insertCheckBox6(GM_getValue("showMissCtrl", 0));
  8938. }
  8939. else if(window.location.pathname.endsWith("/gang/credit/")){
  8940. insertCheckBox7();
  8941. }
  8942. else if(window.location.pathname.endsWith("/stock/bottle/")){
  8943. insertCheckBox8();
  8944. }
  8945. else if(window.location.pathname.endsWith("/gang/upgrades/")){
  8946. insertCheckBox9();
  8947. }
  8948. else if(window.location.pathname.endsWith("/event/xmas15/")){
  8949. insertCheckBox10();
  8950. }
  8951. else if(window.location.pathname.endsWith("/livegame/")){
  8952. // GM_setValue("doLiveGame", 1);
  8953. if (GM_getValue("doLiveGame", 0) == 1)
  8954. DoLiveGame(2);
  8955. }
  8956. else if(window.location.pathname.endsWith("/livegame/bb/") && PGu_getValue("junkfound", "") != ""){
  8957. insertCheckBox11();
  8958. }
  8959. else if(window.location.pathname.endsWith("/event/oktober15/"))
  8960. insertCheckBox12("Brezn");
  8961. else if(window.location.pathname.endsWith("/city/plundershop/"))
  8962. insertCheckBox13();
  8963. else if(window.location.pathname.endsWith("/event/halloween15/"))
  8964. insertCheckBox14();
  8965. else if(window.location.pathname.endsWith("/fight/"))
  8966. insertCheckBox15();
  8967.  
  8968. var wap = (PGu_getValue("WutActivePlunder", 0) + ";").split(";");
  8969. var wip = (PGu_getValue("WutInactivePlunder", 0) + ";").split(";");
  8970. var wwap = (PGu_getValue("WiWuActivePlunder", 0) + ";").split(";");
  8971. var wwip = (PGu_getValue("WiWuInactivePlunder", 0) + ";").split(";");
  8972.  
  8973. if ((Number(wap[0]) + Number(wip[0]) + Number(wwap[0]) + Number(wwip[0]) > 0 && PGu_getValue("aktPlunder", "") == "" && GetPromille(document) < 0.8) || PGu_getValue("DFstarted", false))
  8974. getOverviewPage(mainFunc3);
  8975.  
  8976. if (fcounter == done && counter == done || PGu_getValue("AutoCrime", false) && PGu_getValue("AutoCrimeFkt", 0) > 0 && counter == done) {
  8977. PGu_setValue(nameTime, time);
  8978. PGu_setValue("AskedForCollect", 0);
  8979. checkInterval = window.setInterval(check,intervalTime);
  8980. submit();
  8981. }
  8982. else {
  8983. var lastURL = PGu_getValue("AutoCollURL", "");
  8984. if (lastURL != "") {
  8985. PGu_setValue ("AutoCollURL", "");
  8986. window.location.replace( lastURL );
  8987. }
  8988. else {
  8989. PGu_setValue(nameTime, time);
  8990. PGu_setValue("AskedForCollect", 0);
  8991. checkInterval = window.setInterval(check,intervalTime);
  8992. }
  8993. }
  8994.  
  8995. if (fcounter != done || counter != done || !autoSubmit || !PGu_getValue("AutoCollect", false) && !(PGu_getValue("AutoCrime", false) && PGu_getValue("AutoCrimeFkt", 0) > 0)) {
  8996. CheckNewMinigame();
  8997. if (PGu_getValue("AutoPet", false))
  8998. DoPetCheck(true);
  8999. }
  9000. }
  9001.  
  9002. function mainFunc2(maxfill, bottle)
  9003. {
  9004. trace("mainFunc2", 8);
  9005. var fass = overviewcontent.split("Fassungsverm");
  9006. if (fass.length > 2)
  9007. fass = Number(fass[2].match(/[\d.,]+/));
  9008. else
  9009. fass = 0;
  9010. var mon = overviewcontent.split('class="icon money"')[1].split("</a>")[0];
  9011. var money = Number(mon.split(">").pop().match(/[\d,.]+/)[0].replace(/[.,]/g, ''));
  9012. var maxfill = PGu_getValue("maxfillbottle", 90);
  9013. if (money < maxFass*100 && (money/100 < PGu_getValue("minMoney", 0) || maxfill > 0)) {
  9014. trace('Get ' + prothost + '/stock/bottle/', 2);
  9015. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/bottle/', onload:function(responseDetails) {
  9016. var content = responseDetails.responseText;
  9017. var maxmenge = Math.floor((maxFass*100 - money)/price) + 1;
  9018. var menge = Number(content.split('id="max"')[1].split('value="')[1].split('"')[0]);
  9019. if (maxfill > 0 && fass > 0 && menge > fass * maxfill / 100)
  9020. var minmenge = Math.floor(menge - fass * maxfill / 100);
  9021. else
  9022. var minmenge = 0;
  9023. if (money/100 < PGu_getValue("minMoney", 0))
  9024. minmenge = Math.max(minmenge, Math.floor((PGu_getValue("minMoney", 0)*100 - money)/price) + 1);
  9025. if (minmenge > 0) {
  9026. menge = Math.min(minmenge, maxmenge);
  9027. sellBottles(menge, price, content);
  9028. }
  9029. }});
  9030. }
  9031. }
  9032.  
  9033. function mainFunc3()
  9034. {
  9035. trace("mainFunc3", 8);
  9036. pos = overviewcontent.search("Angelegte Plunder");
  9037. if (pos <= 0)
  9038. return;
  9039. var table = overviewcontent.substr(pos).split("<table")[1].split("</table>")[0];
  9040. var tabs = table.split("<tr")[2].split("<td");
  9041. var plname = tabs[1].split("</strong>")[0].split(">").pop();
  9042. trace('Get ' + prothost + '/gang/upgrades/', 2);
  9043. GM_xmlhttpRequest({method:"GET", url: prothost + '/gang/upgrades/', onload:function(responseDetails) {
  9044. var content = responseDetails.responseText;
  9045. var divs = content.split("<table")[1].split("</table")[0].split("<tr ")[2].split("<div");
  9046. var aktion = divs[divs.length-1].split('type="submit"')[1].split('value="')[1].split('"')[0];
  9047. if (aktion == "Upgrade")
  9048. return;
  9049. if (aktion == "Wechsel") {
  9050. aktion = divs[divs.length-2].split('type="submit"')[1].split('value="')[1].split('"')[0];
  9051. var upgr = "Wut";
  9052. }
  9053. else
  9054. var upgr = "WiWu";
  9055. if (aktion == "Aktiv")
  9056. aktion = "Active";
  9057. else
  9058. aktion = "Inactive";
  9059. if (fcounter == done && PGu_getValue("DFstarted", false))
  9060. PGu_delete("DFstarted");
  9061. else if (fcounter != done && upgr+aktion == "WutInactive") {
  9062. if (PGu_getValue("DFstarted", false)) {
  9063. var pltab = 4;
  9064. if (TOWNEXTENSION == "HH" || TOWNEXTENSION == "B" || TOWNEXTENSION == "MU")
  9065. pltab = 3;
  9066. GM_xmlhttpRequest({method:"GET", url: prothost + '/stock/plunder/ajax/?c='+pltab, onload:function(responseDetails) {
  9067. var content = responseDetails.responseText;
  9068. var tdpm = content.indexOf('id="pm_'+PGu_getValue("dfPlunder", "")+'"');
  9069. if (tdpm != -1) {
  9070. var href = content.substr(tdpm).split('<a href="')[3].split('"')[0];
  9071. if (href.substr(0,4) == "java") {
  9072. var pos = content.lastIndexOf("<strong", tdpm);
  9073. var pname = content.substr(pos).split("</strong")[0].split(">").pop().trim();
  9074. var effect = content.substr(pos).split('class="pinfo2"')[1].split("</p>")[0].split(">").pop().trim();
  9075. var prozp = effect.indexOf("%");
  9076. if (prozp == -1) {
  9077. var p = effect.indexOf("Minute");
  9078. if (p != -1) {
  9079. effect = effect.match(/[^ ]+ [^ ]+ Minute[n]*/)[0].replace(/folgenden |nächsten |auf /, "").replace("zwei", 2).trim();
  9080. var spar = parseInt(effect) * 60;
  9081. trace("Ersparnis durch Plunder: " + spar + " Sekunden; fcounter = " + fcounter, 2);
  9082. if (spar >= getSeks(fcounter)) {
  9083. PGu_delete("DFstarted");
  9084. return;
  9085. }
  9086. }
  9087. }
  9088. var anz = content.substr(pos).split("</span")[0].split(">x ")[1].trim();
  9089. trace("Plunder " + pname + " wird benutzt (noch " + anz + ")", 2);
  9090. PGu_delete("DFstarted");
  9091. HttpPost(content.substr(tdpm), "use_stuff_no_buff", [], function() {
  9092. reload("DFPlunder", "/fight/");
  9093. });
  9094. }
  9095. }
  9096. else
  9097. PGu_setValue("dfUsePlunder", false);
  9098. }});
  9099. }
  9100. return; // bei laufendem Kampf kein Plunderwechsel
  9101. }
  9102. var plnd = (PGu_getValue(upgr + aktion + "Plunder", 0) + ";").split(";");
  9103. if (plname == plnd[1] || plnd[0] <= 0)
  9104. return;
  9105. // **********************************************************************************
  9106. // *** GM_XMLHTTPREQUEST *** POSTEN des Plunderwechsels
  9107. // **********************************************************************************
  9108. trace("Post Plunderchange", 2);
  9109. GM_xmlhttpRequest({method: 'POST', url: prothost + '/stock/plunder/change/', headers: {'Content-type': 'application/x-www-form-urlencoded'},
  9110. data: encodeURI('from_f=0&f_plunder=' + plnd[0]),
  9111. onload: function(responseDetails) {
  9112. var content = responseDetails.responseText;
  9113. var pos = content.search("Angelegter Plunder");
  9114. if (pos > 0) {
  9115. var table = content.substr(pos).split("<table")[1].split("</table>")[0];
  9116. var tabs = table.split("<tr")[2].split("<td");
  9117. var plname = tabs[2].split("</strong>")[0].split(">").pop();
  9118. if (plname != plnd[1])
  9119. PGu_setValue(upgr + aktion + "Plunder", -1);
  9120. }
  9121. reload("PlunderChange");
  9122. }
  9123. });
  9124. }});
  9125. }
  9126.  
  9127. function mainFunc4(price, content) {
  9128. trace("mainFunc4", 8);
  9129. var fass = overviewcontent.split('class="first"')[1].split("Fassungsverm")[1].match(/[\d.,]+/);
  9130. var maxmoney = Number(fass[0].replace(/[.,]/g,''));
  9131. var mon = overviewcontent.split('class="icon money"')[1].split("</a>")[0];
  9132. var money = Number(mon.split(">").pop().match(/[\d,.]+/)[0].replace(/[.,]/g, ''));
  9133. var menge = Math.min(menge, Math.floor((maxmoney - money) / price));
  9134. sellBottles(menge, price, content);
  9135. }