YouLikeHits Bot

Interacts with YLH automatically whereever possible.

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/414314/861075/YouLikeHits%20Bot.js

  1. // ==/UserScript==
  2.  
  3. (() => {
  4. const J = jQuery.noConflict(true);
  5. const globalInterval = 2000;
  6.  
  7. solveCaptcha = (imageEl, outputEl, captchaIdentifier, callback = () => {}) => {
  8. if (window[captchaIdentifier] == undefined) {
  9. window[captchaIdentifier] = true; //solving takes some time, so we'll lock a duplicate solver instance out
  10. let note = attachNotification(imageEl, "Please wait while your captcha is being solved. Don't worry if the code does not seem to match; that's because a new captcha image has been generated!");
  11. Tesseract.recognize(J(imageEl).attr("src")).then(equation => {
  12. var formula = equation.text;
  13. if (formula.length = 3) {//the exact length of the fomula
  14. if (formula.substr(1, 1) == 7) { //2-1 gets recognized as 271
  15. formula = formula.substr(0, 1) + "-" + formula.substr(2);
  16. }
  17. formula = formula.replace(/x/g, "*"); //x is just the human version of *
  18. formula = formula.replace(/[} ]/g, ""); //a random char being the result of misinterpretation; occasionally happening on the login form
  19. //console.log(formula); //re-enable this to debug how the captchasolving is doing so far
  20. outputEl.val(eval(formula));
  21. window[captchaIdentifier] = false; //not really necessary IF directly triggering a classic non-ajax post request
  22. removeNotification(note);
  23. callback()
  24. }
  25. });
  26. }
  27. }
  28.  
  29. attachNotification = (identifier, notification) => {
  30. el = "<p style='color: red;'>" + notification + "</p>";
  31. prevEl = J(identifier).prev()[0];
  32. if (prevEl == undefined || prevEl.innerText != notification)
  33. return J(el).insertBefore(identifier);
  34. }
  35.  
  36. removeNotification = (el) => {
  37. if (el != undefined)
  38. el.remove()
  39. }
  40.  
  41. alertOnce = (message, identifier) => {
  42. localIdentifier = (identifier != undefined) ? identifier : message;
  43. if (shownWarnings.indexOf(localIdentifier) == -1) {
  44. shownWarnings.push(localIdentifier);
  45. alert(message)
  46. }
  47. }
  48.  
  49. //runtime vars
  50. let previousVideo = "";
  51. /** indicates if a warning/message has already been shown. Happens once per window. Use alertOnce() */
  52. let shownWarnings = [];
  53.  
  54. setInterval(() => {
  55. if (J("*:contains('503 Service Unavailable')").length) {
  56. console.log("Server Error! reloading...");
  57. location.reload();
  58. } else if (J("*:contains('not logged in!')").length) {
  59. window.location.href = "login.php"
  60. } else if (J("*:contains('Failed. You did not successfully solve the problem.')").length) {
  61. J("a:contains('Try Again')")[0].click()
  62. } else {
  63. switch (document.location.pathname) {
  64. case "/login.php":
  65. if (!J("#password").val().length) attachNotification("#username", "Consider storing your login data in your browser.")
  66. captcha = J("img[alt='Enter The Numbers']");
  67. if (captcha.length)
  68. solveCaptcha(captcha[0], J("input[name='postcaptcha']"), "ylh_login_captchasolving");
  69. break;
  70. case "/bonuspoints.php":
  71. if (J("body:contains('You have made ')").length && J("body:contains(' Hits out of ')").length) {
  72. attachNotification(".maintable", "Not enough points. Reloading the website in 2 minutes to check again...");
  73. setTimeout(() => location.reload(), 1000 * 120);
  74. } else if (J(".buybutton").length) J(".buybutton")[0].click()
  75. break;
  76. case "/youtubenew2.php":
  77. if (J('body:contains("failed")').length) location.reload(); //captcha failed?
  78. if (J(".followbutton").length) { //if false, there is likely a captcha waiting to be solved
  79. let vidID = () => { return J(".followbutton").first().parent().children("span[id*='count']").attr("id") };
  80. let patienceKiller = (prev) => { setTimeout( () => { if (vidID() == prev) { J(".followbutton").parent().children("a:contains('Skip')").click(); newWin.close(); }}, 1000 * 135)}; //max time: 120s + 15s grace time (max length: http://prntscr.com/q4o75o)
  81. //console.log(previousVideo + " " + vidID() + (previousVideo != vidID() ? " true": " false"));
  82. if (vidID() != previousVideo) { //has a new video has been provided yet? This will overcome slow network connections causing the same video to be played over and over
  83. previousVideo = vidID();
  84. if (window.eval("typeof(window.newWin) !== 'undefined'")) {
  85. if (newWin.closed) {
  86. console.log("Watching one Video!");
  87. J(".followbutton")[0].click();
  88. patienceKiller(previousVideo)
  89. }
  90. } else {
  91. console.log("Watching one Video!");
  92. J(".followbutton")[0].click();
  93. patienceKiller(previousVideo)
  94. }
  95. } //else do nothing and wait (until the video gets replaced or our patience thread tears)
  96. } else {
  97. captcha = J("img[src*='captchayt']");
  98. if (captcha.length) //captcha? no problemo, amigo.
  99. solveCaptcha(captcha[0], J("input[name='answer']"), "ylh_yt_traffic_captchasolving", () => J("input[value='Submit']").first().click());
  100. }
  101. break;
  102. }
  103. GM.getValue("ylh_traffic_tab_open", false).then(state => {
  104. switch (document.location.pathname) {
  105. case "/websites.php":
  106. if (J("*:contains('There are no Websites currently visitable for Points')").length) {
  107. alertOnce("All websites were visited. Revisit/reload the page to start surfing again.")
  108. } else {
  109. if (!state && window.eval("typeof(window.childWindow) !== 'undefined'")) {
  110. if (!childWindow.closed)
  111. childWindow.close();
  112. } else if (state && window.eval("typeof(window.childWindow) == 'undefined'")) {
  113. console.log("no child window is actually open. let's create a new tab as if we came here for the very first time!");
  114. state = false;
  115. }
  116. var buttons = J(".followbutton:visible");
  117. if (buttons.length) {
  118. if (!state) {
  119. console.log("setting the tabstate to true...");
  120. GM.setValue('ylh_traffic_tab_open', true).then(() => {
  121. console.log("Visiting a new page...");
  122. buttons[0].onclick();
  123. });
  124. } else {
  125. }
  126. } else {
  127. console.log("We ran out of buttons! requesting more...");
  128. //GM.getValue("ylh_traffic_reloadlimit", false).then(rlimit => {
  129. if (window.eval("typeof(window.childWindow) !== 'undefined'") && childWindow.closed) //without this we would not wait for the last link of the page to be visited successfully
  130. location.reload();
  131. //J("a[title='Refresh']")[0].click();
  132. }
  133. }
  134. break;
  135. case "/viewwebsite.php":
  136. if (!J("*:contains('been logged out of YouLikeHits')").length) {
  137. if (J(".alert:visible:contains('You got'):contains('Points')").length || J('body:contains("We couldn\'t locate the website you\'re attempting to visit.")').length) {
  138. console.log("setting the tabstate to false...");
  139. GM.setValue('ylh_traffic_tab_open', false).then(() => { //free the way for a new tab
  140. /*window.close(); //might not always work in FF
  141. setTimeout (window.close, 1000);*/
  142. });
  143. } else if (J("*:contains('viewing websites too quickly! Please wait')").length) location.reload();
  144. } else alert("Please reload the website list, and make sure you are still logged in.");
  145. break;
  146. }
  147. });
  148. }
  149. }, globalInterval);
  150. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址