GamekitImageAutoRate

Continuously rate every pictures with ransom stars

  1. // ==UserScript==
  2. // @name GamekitImageAutoRate
  3. // @namespace fr.mrcraftcod
  4. // @version 0.5
  5. // @description Continuously rate every pictures with ransom stars
  6. // @author MrCraftCod
  7. // @match https://gamekit.com/image/star/*
  8. // @match https://dogry.pl/image/star/*
  9. // @require http://code.jquery.com/jquery-3.4.1.min.js
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var loadDate = Date.now();
  16. function tryRate()
  17. {
  18. var captchaValid = $('#google_recaptcha_send');
  19. if(captchaValid && captchaValid !== undefined && captchaValid !== null && captchaValid.length && captchaValid.length > 0) //Can't valid automatically captcha due to CORS
  20. {
  21. console.log("[GamekitImageAutoRate] Captcha, waiting user input");
  22. return;
  23. }
  24. var note = (1 + getRandomInt(5)) * 2;
  25. var button = $('[data-rating="' + note + '"]');
  26. if(!button || button === null || button === undefined){
  27. console.log("[GamekitImageAutoRate] Stars not found, retrying in 100ms");
  28. setTimeout(tryRate, 100);
  29. }
  30. else{
  31. console.log("[GamekitImageAutoRate] Rated image with " + note / 2 + " stars");
  32. button.click(); //Page will reload and script be run again after
  33. }
  34. }
  35.  
  36. function getRandomInt(max) {
  37. return Math.floor(Math.random() * Math.floor(max));
  38. }
  39.  
  40. $(document).ready(function(){
  41. var delay = Math.max(0, (loadDate + 1000) - Date.now());
  42. if(delay == 0){
  43. tryRate();
  44. }else{
  45. console.log("[GamekitImageAutoRate] Waiting " + delay + "ms before rating");
  46. setTimeout(tryRate, delay); //wait at least 1s since the scipt have been loaded
  47. }
  48. });
  49. })();
  50.  
  51.