FreeRice Multiplication Script/Bot

Automatically play FreeRice multiplication table

  1. // ==UserScript==
  2. // @name FreeRice Multiplication Script/Bot
  3. // @namespace https://github.com/AbdurazaaqMohammed
  4. // @version 1.0.3
  5. // @description Automatically play FreeRice multiplication table
  6. // @author Abdurazaaq Mohammed
  7. // @match https://play.freerice.com/categories/multiplication-table*
  8. // @grant none
  9. // @homepage https://github.com/AbdurazaaqMohammed/userscripts
  10. // @license The Unlicense
  11. // @supportURL https://github.com/AbdurazaaqMohammed/userscripts/issues
  12. // ==/UserScript==
  13.  
  14. function getAnswer() {
  15.  
  16. const numbers = document.querySelector('.card-title').textContent.split(' x ');
  17.  
  18. return numbers[0] * numbers[1];
  19. }
  20.  
  21. function clickAnswer() {
  22. const answers = document.querySelectorAll('.card-button');
  23.  
  24. for (i = 0; i < answers.length; i++) {
  25. const ans = answers[i];
  26. if (ans.textContent == getAnswer()) {
  27. ans.click();
  28. break;
  29. }
  30. }
  31. }
  32. setInterval(clickAnswer, 1000);
  33. setTimeout(function(){ location.reload(); }, 15000); //When you answer questions too quickly, Freerice starts slowing down the rate at which it gives you new questions. This can simply be reset by refreshing the page every once in a while.