Spendenbutton - PG4.0 - All Games

Zeigt einen Spenden Button direkt auf der Uebersichtsseite von Pennergame an. Fuer die Seite http://www.menelgame.com.pl/

  1. // ==UserScript==
  2. // @name Spendenbutton - PG4.0 - All Games
  3. // @namespace Script by MR. X and MR. Y
  4. // @description Zeigt einen Spenden Button direkt auf der Uebersichtsseite von Pennergame an. Fuer die Seite http://www.menelgame.com.pl/
  5. // @include *spenden.hitfaker.net*
  6. // @include http://www.pennergame.de/overview/
  7. // @include http://*berlin.pennergame.de/overview/
  8. // @include http://*muenchen.pennergame.de/overview/
  9. // @include http://*koeln.pennergame.de/overview/
  10. // @include http://*reloaded.pennergame.de/overview/
  11. // @include http://*pennersturm.pennergame.de/overview/
  12. // @include http://*dossergame.co.uk/overview/
  13. // @include http://*bumrise.com/overview/
  14. // @include http://*clodogame.fr/overview/
  15. // @include http://*faveladogame.com.br/overview/
  16. // @include http://*mendigogame.es/overview/
  17. // @include http://*menelgame.pl/overview/
  18. // @include http://*halloween.pennergame.de/overview/
  19. // @include http://*mendigogame.com/overview/
  20. // @include http://*bomzhuj.ru/overview/
  21. // @grant GM_getValue
  22. // @grant GM_setValue
  23. // @grant GM_xmlhttpRequest
  24. // @grant GM_deleteValue
  25. // @version 1.1.8 collect donations via spenden.hitfaker.net
  26. // ==/UserScript==
  27.  
  28. // ***********************************************************************************************
  29. // ***********************************************************************************************
  30. //--------Update Funktion by Sageo - natuerlich mit ihrer Erlaubniss--------------
  31. // ***********************************************************************************************
  32. // ***********************************************************************************************
  33. // Daten über das aktuelle Skript für den Update-Mechanismus
  34. var THISSCRIPTNAME = "Spendenbutton - PG4.0 - All Games";
  35. var THISSCRIPTVERSION = GM_info.script.version.split(" ")[0];
  36. var THISSCRIPTINSTALL_URL = 'https://greasyfork.org/de/scripts/2967-spendenbutton-pg4-0-all-games';
  37. // @version 1.1.7 update function corrected
  38. // @version 1.1.6 grants added
  39. // @version 1.1.5 correction
  40. // @version 1.1.4 update info because of change on greasyfork.org
  41. // @version 1.1.3 script did not work any more
  42. // @version 1.1.2 script did not work any more
  43. // @version 1.1.1 script did not work any more
  44. // @version 1.0.18 change links for donation pages
  45. // @version 1.0.17 Version for FF 17
  46. // @version 1.0.16 Operation Pennersturm added
  47. // @version 1.0.15 PG changed the donationsides because SHIFT sucks by MR X
  48. // @version 1.0.14 PG reloaded Hamburg added
  49. // @version 1.0.13 alternative site did not work any longer
  50. // @version 1.0.12 donations did not work because of www at the beginning of URL
  51. // @version 1.0.11 use alternative site with Shift+Click in case of problems with the original site
  52. // @version 1.0.10 now also runs in Köln
  53. // @version 1.0.9 now also runs in London
  54. // @version 1.0.8 now also runs in Russia
  55. // @version 1.0.7 now also runs in Buenos Aires
  56. // @version 1.0.6 now also runs on Halloween
  57. // @version 1.0.5 now also runs on Mallorca
  58. // @version 1.0.4 some more english texts
  59. // @version 1.0.3 update the progress bar of the money while receiving donations; english text for all foreign versions
  60. // @version 1.0.2 URL of donation page changed; countdown of donations
  61. // @version 1.0.1 some small modifications by Mr. Y
  62. // @version 1.0.0 Brand new Shit
  63. // $Id: spendenbutton_-_pg40_-_a.user.js 122 2015-09-02 12:12:41Z Mr. X $
  64.  
  65.  
  66. // ***********************************************************************************************
  67. // ***********************************************************************************************
  68. // Formatiert ein Datum um in das Format "YYYY-MM-DD"
  69. // ***********************************************************************************************
  70. // ***********************************************************************************************
  71. function FormatDate(DateToFormat) {
  72. var year = DateToFormat.getFullYear();
  73. var month = DateToFormat.getMonth() + 101 + "";
  74. var day = DateToFormat.getDate() + 100 + "";
  75.  
  76. return year + "-" + month.slice(1) + "-" + day.slice(1);
  77. }
  78.  
  79.  
  80. // ***********************************************************************************************
  81. // ***********************************************************************************************
  82. // Entfernt Leerraum aus einen String (Anfang und Ende)
  83. // ***********************************************************************************************
  84. // ***********************************************************************************************
  85. function trimString(s) {
  86. return s.replace(/^\s+|\s+$/g,'');
  87. }
  88.  
  89. // ***********************************************************************************************
  90. // ***********************************************************************************************
  91. // Funktion ueberprueft, ob es neue Skript-Versionen gibt (einmal pro Tag) und zeigt im positiven
  92. // Fall eine Meldung an.
  93. // ***********************************************************************************************
  94. // ***********************************************************************************************
  95. function CheckForUpdate(german) {
  96. // Aktuelles Tagesdatum erzeugen und formatieren
  97. var today = new Date();
  98. var tagesdatum = FormatDate(today);
  99.  
  100. if (GM_getValue("LastScriptUpdateCheckGF","") != tagesdatum) {
  101. // **********************************************************************************
  102. // *** GM_XMLHTTPREQUEST *** Abrufen der Skriptseite von greasyfork.org
  103. // **********************************************************************************
  104. GM_xmlhttpRequest({method: 'GET',
  105. url: THISSCRIPTINSTALL_URL,
  106. headers:{ "Accept":"text/javascript; charset=UTF-8" },
  107. overrideMimeType:"application/javascript; charset=UTF-8",
  108. onload:function(responseDetails) {
  109. // Wenn die Seite erfolgreich abgerufen werden konnte
  110. if (responseDetails.status == 200) {
  111. var content = responseDetails.responseText;
  112.  
  113. // Ermitteln der Skriptversion
  114. if (content.indexOf("@version") != -1)
  115. var scriptfullversion = trimString(content.split('@version')[1]).split('\n')[0];
  116. else
  117. var scriptfullversion = content.split('"script-show-version">').pop().split('</span')[0].split('<span>').pop();
  118. var scriptversion = scriptfullversion.split(' ')[0];
  119. scriptfullversion = scriptfullversion.substr(scriptversion.length+1);
  120. // Wenn dort eine neue Skriptversion vorliegt
  121. if (scriptversion != THISSCRIPTVERSION) {
  122. // Hinweistext zusammenbauen
  123. if (german)
  124. 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_URL + "\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."
  125. else
  126. var alerttext = "There is a new version of the script '" + THISSCRIPTNAME + "':\n\n" + scriptfullversion + "\n\nThe new version can contain bugfixes and/or new features.\nHere you will find more information about the new version:\n\n" + THISSCRIPTINSTALL_URL + "\n\nAn update is recommended and can be done directly afterwards.\n\nNote: The check for new versions is only done once a day."
  127.  
  128. // Hinweistext ausgeben
  129. alert(alerttext);
  130. // Seite mit dem neuen Skript laden, um eine Installation zu ermöglichen
  131. window.location.href = THISSCRIPTINSTALL_URL+'/code/Spendenbutton%20-%20PG40%20-%20All%20Games.user.js';
  132. }
  133. }
  134. }
  135. });
  136. // Setze den Parameter auf das aktuelle Datum (Updatesuche wurde ausgeführt)
  137. GM_setValue("LastScriptUpdateCheckGF", tagesdatum)
  138. }
  139. }
  140.  
  141. // ***********************************************************************************************
  142. // ***********************************************************************************************
  143. // Funktion erzeugt einen Fortschrittsbalken und liefert ihn als Tabelle zurück
  144. // ***********************************************************************************************
  145. // ***********************************************************************************************
  146. function CreateProgressTable(columnr) {
  147. var newtable = document.createElement("table");
  148. newtable.style.width = "500px";
  149. newtable.style.border = "#000000 1px solid";
  150. var newtr = document.createElement("tr");
  151. newtable.appendChild(newtr);
  152.  
  153. for (var i = 1; i <= columnr; i++) {
  154. var newtd = document.createElement("td");
  155. newtd.innerHTML = '&nbsp;';
  156. newtr.appendChild(newtd);
  157. }
  158.  
  159. return newtable;
  160. }
  161.  
  162. // ***********************************************************************************************
  163. // ***********************************************************************************************
  164. // Funktion füllt den Fortschrittsbalken bis zur Spalte columnnr
  165. // ***********************************************************************************************
  166. // ***********************************************************************************************
  167. function FillProgressTable(currenttable, columnnr) {
  168. for (var i = 0; i < columnnr; i++) {
  169. var currenttd = currenttable.getElementsByTagName("td")[i];
  170. currenttd.style.backgroundColor = "#33cc00 ";
  171. }
  172. }
  173.  
  174. // **********************************************************************************
  175. // **********************************************************************************
  176. // Funktion wandelt einen HTML-Content in ein DOM um
  177. // **********************************************************************************
  178. // **********************************************************************************
  179. function HTML2DOM(content) {
  180.  
  181. var host = document.location.host;
  182. var dummyDiv = document.createElement('div');
  183. dummyDiv.innerHTML = content;
  184.  
  185. return dummyDiv;
  186. }
  187.  
  188. //---------------------------------------------------------------------------------------------------
  189. // Ermitteln der PG Seite
  190. //---------------------------------------------------------------------------------------------------
  191.  
  192. var urls = new Array();
  193. urls[0] = 'http://www.menelegame.pl/';
  194. urls[1] = 'http://pennerga.me/';
  195. urls[2] = 'http://spenden.hitfaker.net/';
  196. var links = new Array();
  197. links[0] = 'http://www.menelegame.pl/';
  198. links[1] = 'http://pennerga.me/donate.php';
  199. links[2] = 'http://spenden.hitfaker.net/';
  200. var data = new Array();
  201. data[0] = 'url=%s&Submit=Donate';
  202. data[1] = 'url=%s&Submit=Donate';
  203. data[2] = 'url=%s';
  204. var pg = new Array();
  205. pg[0] = 'POST';
  206. pg[1] = 'POST';
  207. pg[2] = 'click';
  208.  
  209. if(window.location.hostname == "spenden.hitfaker.net"){
  210. var don = GM_getValue("hitfakerlink", "");
  211. if (don != "") {
  212. function checklink(link, start) {
  213. if (document.getElementById(link).value == "")
  214. window.setTimeout(checklink, 1000, link, start);
  215. else {
  216. document.getElementById(link).value = don;
  217. window.setTimeout('document.getElementById("' + start + '").click()', 1000);
  218. window.setTimeout(checkrun, 1000);
  219. }
  220. }
  221. function checkrun() {
  222. if (document.getElementById("status"))
  223. if (document.getElementById("status").innerHTML.indexOf("<strong>") != -1) {
  224. GM_deleteValue("hitfakerlink");
  225. window.close();
  226. return;
  227. }
  228. window.setTimeout(checkrun, 1000);
  229. }
  230. window.setTimeout(checklink, 1000, "url", "start");
  231. }
  232. }
  233. else {
  234. var url = document.location.href;
  235. var link = url.split('/overview')[0];
  236. var german = (link.substr(link.length-2,2) == "de");
  237. var indx = GM_getValue("donationindex", 0);
  238. if (indx >= urls.length)
  239. indx = 0;
  240.  
  241. CheckForUpdate(german);
  242. }
  243.  
  244. // ***********************************************************************************************
  245. // ***********************************************************************************************
  246. //----Ende----Auto Update Funktion---Ende---------------------------------------------------
  247. // ***********************************************************************************************
  248. // ***********************************************************************************************
  249.  
  250.  
  251. //---------------------------------------------------------------------------------------------------
  252. // Spendenlink auslesen
  253. //---------------------------------------------------------------------------------------------------
  254. var donationlink = document.getElementsByTagName('html')[0].innerHTML.split('name="reflink" value="')[1];
  255. var donationlink2 = donationlink.split('"')[0];
  256. //---------------------------------------------------------------------------------------------------
  257. // Ausgabe auf der Overviewseite
  258. //---------------------------------------------------------------------------------------------------
  259. var div_tieritemA2 = document.getElementsByClassName('tieritemA');
  260. for (var i = 0; i < div_tieritemA2.length; i++)
  261. if (div_tieritemA2[i].innerHTML.indexOf('change_please') != -1) {
  262. var donPos = i;
  263. break;
  264. }
  265. var lis = div_tieritemA2[donPos].getElementsByTagName('li');
  266. var donText = lis[3].innerHTML.replace(/[,.]/g, '').split(' ');
  267. var j = 0;
  268. for (var i = 0; i < donText.length; i++) {
  269. if (!isNaN(donText[i]))
  270. if (j++)
  271. var remDon = Number(donText[i]); // remaining donations
  272. else
  273. var recDon = Number(donText[i]); // received donations
  274. }
  275.  
  276. var new2div = document.createElement('div');
  277. new2div.setAttribute('class', 'tieritemA');
  278. new2div.style.width = "500px";
  279. if (german)
  280. new2div.innerHTML = '<h4><div style="padding-top:9px;">Spenden holen via: <a id="donlink" href="' + urls[indx] + '" title="Link zu ' + urls[indx] + '" target="_blank">' + urls[indx] + '</a></div><div style="text-align: right; margin-top:-20px;">Spenden übrig:<span style="font-size:1.6em"> '+remDon+'</span></div></h4><table Border="0" Width="100%"><tr><td><div style="text-align: left;"><span style="font-size:1.4em"><u><b>Info:</b></u></span><br>Hier kannst du mit einem Klick deine Spenden <br>innerhalb von ca. 60 Sek. abholen!<br><br>1. Wasche deinen Penner.<br>2. Lege einen Spendenplunder an.<br>3. Klicke den <b>"Spenden holen"</b> Button.<br> &nbsp;&nbsp;&nbsp; Warte auf die Bestätigung... FERTIG!!!<br><br></div></td><td><div style="text-align: right; padding-top:40px; padding-right:10px;"><form name="Formular" action=""><input type="button" value="Spenden holen" title="Klicke hier um deine Spenden für heute abzuholen!!!" id="holespenden"></form></div></td></tr></table>';
  281. else
  282. new2div.innerHTML = '<h4><div style="padding-top:9px;">Receive donations via: <a id="donlink" href="' + urls[indx] + '" title="Link to ' + urls[indx] + '" target="_blank">' + urls[indx] + '</a></div><div style="text-align: right; margin-top:-20px;">Donations left:<span style="font-size:1.6em"> '+remDon+'</span></div></h4><table Border="0" Width="100%"><tr><td><div style="text-align: left;"><span style="font-size:1.4em"><u><b>Info:</b></u></span><br>Here you can receive your donations with one click<br>within about 60sec.!<br><br>1. Wash your bum.<br>2. Put on some junk for higher donations.<br>3. Clicke the <b>"receive donations"</b> button.<br> &nbsp;&nbsp;&nbsp; Wait for the confirmation... READY!!!<br><br></div></td><td><div style="text-align: right; padding-top:40px; padding-right:10px;"><form name="Formular" action=""><input type="button" value="receive donations" title="Click here to receive your donations for today!!!" id="holespenden"></form></div></td></tr></table>';
  283. div_tieritemA2[donPos].parentNode.insertBefore(new2div, div_tieritemA2[donPos]);
  284.  
  285. // ***********************************************************************************************
  286. // Fortschrittsbalken einfügen
  287. // ***********************************************************************************************
  288. var newtd = document.createElement("td");
  289. newtd.setAttribute("colspan", "2");
  290. if (german)
  291. newtd.innerHTML = 'Spendenanzahl:';
  292. else
  293. newtd.innerHTML = 'Number of donations:';
  294. new2div.appendChild(newtd);
  295.  
  296. var ProgressTable = CreateProgressTable(recDon+remDon);
  297. newtd.appendChild(ProgressTable);
  298. FillProgressTable(ProgressTable, recDon);
  299.  
  300. if (GM_getValue("hitfakerlink", donationlink2) != donationlink2)
  301. document.getElementById("holespenden").disabled = true;
  302.  
  303. if (remDon == 0) {
  304. // Button disablen
  305. document.getElementById("holespenden").disabled = true;
  306. GM_deleteValue("hitfakerlink");
  307. }
  308.  
  309. document.getElementById("holespenden").addEventListener("click", function(event) {
  310. function updateDonCount(newdiv, link, lis, recDonOld, lstCnt) {
  311. GM_xmlhttpRequest({
  312. method: 'GET',
  313. url: ''+link+'/overview/',
  314. onload: function(responseDetails) {
  315. if (responseDetails.status == 200) {
  316. var content = responseDetails.responseText;
  317. if (content.indexOf('change_please') != -1) {
  318. var doc = HTML2DOM(content);
  319.  
  320. var div_tieritemA2 = doc.getElementsByClassName('tieritemA');
  321. for (var i = 0; i < div_tieritemA2.length; i++)
  322. if (div_tieritemA2[i].innerHTML.indexOf('change_please') != -1) {
  323. var donPos = i;
  324. break;
  325. }
  326. var lis2 = div_tieritemA2[donPos].getElementsByTagName('li');
  327.  
  328. lis[0].innerHTML = lis2[0].innerHTML;
  329. lis[1].innerHTML = lis2[1].innerHTML;
  330. lis[2].innerHTML = lis2[2].innerHTML;
  331. lis[3].innerHTML = lis2[3].innerHTML;
  332. var money = document.getElementsByClassName("icon money");
  333. var money2 = doc.getElementsByClassName("icon money");
  334. money[0].innerHTML = money2[0].innerHTML;
  335. var donText = lis2[3].innerHTML.replace(/[,.]/g, '').split(' ');
  336. var j = 0;
  337. for (var i = 0; i < donText.length; i++) {
  338. if (!isNaN(donText[i]))
  339. if (j++)
  340. var remDon = Number(donText[i]); // remaining donations
  341. else
  342. var recDon = Number(donText[i]); // received donations
  343. }
  344. var donrem = newdiv.getElementsByTagName('div')[1];
  345. donrem.innerHTML = donrem.innerHTML.replace(/> [0-9]*</, '> '+remDon+'<');
  346. var ProgressTable = newdiv.getElementsByTagName('table')[1];
  347. FillProgressTable(ProgressTable, recDon);
  348. if (recDon == recDonOld) {
  349. if (lstCnt < 50)
  350. updateDonCount(newdiv, link, lis, recDon, lstCnt+1);
  351. else {
  352. if (german)
  353. alert ("Es kommen keine weiteren Spenden !!");
  354. else
  355. alert ("You do not receive any more donations !!");
  356. document.location.reload();
  357. }
  358. return;
  359. }
  360. if (remDon > 0)
  361. updateDonCount(newdiv, link, lis, recDon, 0);
  362. else {
  363. document.location.reload();
  364. if (german)
  365. alert ("Es wurden alle Spenden geholt !!");
  366. else
  367. alert ("All donations have been fetched !!");
  368. GM_deleteValue(donationlink2);
  369. }
  370. return;
  371. }
  372. }
  373. updateDonCount(newdiv, link, lis, recDon, lstCnt);
  374. }
  375. });
  376. }
  377.  
  378. document.getElementById("holespenden").disabled = true;
  379. if (event.shiftKey != 0) {
  380. indx++;
  381. if (indx >= urls.length)
  382. indx = 0;
  383. GM_setValue("donationindex", indx);
  384. var ele = document.getElementById("donlink");
  385. donlink.href = urls[indx];
  386. donlink.title = "Link " + (german?"zu ":"to ") + urls[indx];
  387. donlink.innerHTML = urls[indx];
  388. }
  389. var url = links[indx];
  390. var dat = data[indx].replace("%s", donationlink2);
  391. if (pg[indx] == "click") {
  392. GM_setValue("hitfakerlink", donationlink2);
  393. document.getElementById("donlink").click();
  394. }
  395. else {
  396. if (pg[indx] == "POST")
  397. dat = encodeURI(dat);
  398. else {
  399. url = url + "?" + dat;
  400. dat = "";
  401. }
  402. GM_setValue(donationlink2, true);
  403.  
  404. GM_xmlhttpRequest({
  405. method: pg[indx],
  406. url: url,
  407. headers: {'Content-type': 'application/x-www-form-urlencoded'},
  408. data: dat,
  409. onload: function(responseDetails) {
  410. if (GM_getValue(donationlink2, false)) {
  411. GM_deleteValue(donationlink2);
  412. var page = location.toString();
  413. window.location.href = page;
  414. if (german)
  415. alert ("Es wurden alle Spenden geholt !!");
  416. else
  417. alert ("All donations have been fetched !!");
  418. }
  419. }
  420. });
  421. }
  422. updateDonCount(new2div, link, lis, recDon, 0);
  423. }, false);