Automatic Money Collector (for hentaiheroes.com)

3 functions: getMoneyBackground, getMoneyGUI, displayGirlsId

  1. // ==UserScript==
  2. // @name Automatic Money Collector (for hentaiheroes.com)
  3. // @namespace https://greasyfork.org/fr/scripts/424081
  4. // @version 1.3
  5. // @description 3 functions: getMoneyBackground, getMoneyGUI, displayGirlsId
  6. // @author ManJizz
  7. // @match https://www.hentaiheroes.com/
  8. // @grant none
  9. // @require https://code.jquery.com/jquery-3.6.0.min.js
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/notify/0.4.2/notify.js
  11.  
  12. // getMoneyBackground:
  13. // It collects money on a regular basis by sending POST requests to the server (even if the harem section is not displayed).
  14. // You will need to find the ids of the girls you own in order to put them into the array allGirlsId.
  15. // Here is a selector to find your girls' id:
  16. // $('#hh_game').contents().find('body div#contains_all.fixed_scaled div#harem_whole div.global-container div#harem_left div.girls_list div[id_girl] div[class=""]')
  17. // You can run it with Tampermonkey or on your browser console (F12 => Console).
  18. // You can also use the function displayGirlsId.
  19.  
  20. // getMoneyGUI:
  21. // It collects money on a regular basis by sending POST requests to the server.
  22. // It's only triggered if the harem section is open.
  23. // This function doesn't need the ids of your girls. It finds them itself.
  24.  
  25. // displayGirlsId:
  26. // It displays the girls' id.
  27. // The harem section has to be open.
  28.  
  29. // The functions don't refresh the page so you will still see the progress bar after the collect.
  30. // Both funtions use JQuery and Notify.js, which is a JQuery plugin for the notifications
  31. // The script has been made for https://www.hentaiheroes.com/
  32.  
  33. // ==/UserScript==
  34. jQuery(function($) {
  35. var notifOpts = {
  36. autoHideDelay: 5000,
  37. showAnimation: "fadeIn",
  38. hideAnimation: "fadeOut",
  39. className: 'info',
  40. };
  41.  
  42. function getMoneyBackground(){
  43. /** allGirlsId => array to fill with the ids of your girls **/
  44. var allGirlsId = [1,4,5,7,10,15,12,14,7914892,13,11];
  45. var textAlert = 'Collect money from ';
  46. var nbGirls = [];
  47. var girls = '/ ';
  48. var promises = [];
  49.  
  50. // For each girl id in allGirlsId
  51. $.each(allGirlsId, function(index, value) {
  52. var dfd = new $.Deferred();
  53. // Post request to query the server
  54. $.post('ajax.php', { class: "Girl", id_girl : value, action : "get_salary"}, function(response){
  55. var data = JSON.parse(JSON.stringify(response));
  56. if(data.success === true){
  57. nbGirls.push(value);
  58. girls = girls.concat(value.toString()).concat(' / ');
  59. }
  60. }).done(function() {
  61. dfd.resolve();
  62. }).fail(function() {
  63. console.log('failed');
  64. });
  65. promises.push(dfd);
  66. });
  67.  
  68. // All post requests are treated => report
  69. $.when.apply($, promises).done(function () {
  70. if(nbGirls.length > 0){
  71. // If any money has been collected
  72. textAlert = textAlert.concat(nbGirls.length).concat(' girl(s): ').concat(girls);
  73. console.log(textAlert);
  74. } else {
  75. // If no money has been collected
  76. textAlert = 'No money to collect';
  77. console.log(textAlert);
  78. }
  79. $.notify(textAlert, notifOpts);
  80. });
  81. }
  82.  
  83. function getMoneyGUI(){
  84. var allGirlsId = [];
  85. var textAlert;
  86. // Selectors to reach the div
  87. var divGirlsList = $('#hh_game').contents().find('body div#contains_all.fixed_scaled div#harem_whole div.global-container div#harem_left div.girls_list')
  88. if(divGirlsList.is(":visible")){
  89. var divIdGirl = divGirlsList.find('div[id_girl]');
  90. $(divIdGirl).each(function() {
  91. if($(this).contents().find('button.collect_money').is(":visible")){
  92. // All ids are pushed into allGirlsId
  93. allGirlsId.push($(this).attr("id_girl"));
  94. }
  95. });
  96.  
  97. if(allGirlsId.length > 0){
  98. // If any id has been found
  99. textAlert = 'Money collected for girl(s): ';
  100. $.each(allGirlsId, function(index, value) {
  101. $.post('ajax.php', { class: "Girl", id_girl : value, action : "get_salary"}, function(response){
  102. var data = JSON.parse(JSON.stringify(response));
  103. console.log('Post request returned: ' + data.success + ' for girl n°' + value.toString());
  104. }).fail(function() {
  105. console.log('failed');
  106. });
  107. textAlert = textAlert.concat(value.toString());
  108. textAlert = textAlert.concat(' / ');
  109. });
  110. console.log(textAlert);
  111. $.notify(textAlert, notifOpts);
  112. } else {
  113. // If no id has been found
  114. textAlert = 'No money to collect.';
  115. console.log(textAlert);
  116. $.notify(textAlert, notifOpts);
  117. }
  118. console.log('Money collected for : ' + allGirlsId.length + ' girl(s).');
  119. } else {
  120. // Notification when the harem is closed
  121. textAlert = 'Harem iframe is hidden.';
  122. console.log(textAlert);
  123. $.notify(textAlert, notifOpts);
  124. }
  125. }
  126.  
  127. function displayGirlsId(){
  128. var allGirlsId = [];
  129. var textAlert = "";
  130. var idGirls = $('#hh_game').contents().find('body div#contains_all.fixed_scaled div#harem_whole div.global-container div#harem_left div.girls_list div[id_girl]');
  131. idGirls.find('div[class=""]').add(idGirls.find('div[class="opened"]')).each(function() {
  132. allGirlsId.push($(this).attr("girl"));
  133. textAlert = textAlert.concat($(this).attr("girl").toString());
  134. textAlert = textAlert.concat(', ');
  135. });
  136.  
  137. if(allGirlsId.length > 0){
  138. console.log(textAlert);
  139. $.notify(textAlert, notifOpts);
  140. } else {
  141. textAlert = "Can't get the girls' id";
  142. console.log(textAlert);
  143. $.notify(textAlert, notifOpts);
  144. }
  145. }
  146.  
  147.  
  148. // 1 s = 1000 ms / 1 min = 60000 ms
  149. var interval = 37000;
  150.  
  151. /** First call **/
  152. getMoneyBackground();
  153. //displayGirlsId();
  154. //getMoneyGUI();
  155.  
  156. /** Interval: duration between each request **/
  157. window.setInterval(getMoneyBackground,interval);
  158. //window.setInterval(displayGirlsId,interval);
  159. //window.setInterval(getMoneyGUI,interval);
  160. });