FreeRice Multiplication Script/Bot

Userscript to automatically play FreeRice multiplication game

目前為 2023-10-13 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name FreeRice Multiplication Script/Bot
  3. // @namespace https://github.com/fxolan
  4. // @version 1
  5. // @description Userscript to automatically play FreeRice multiplication game
  6. // @author https://github.com/fxolan
  7. // @match https://play.freerice.com/categories/multiplication-table
  8. // @grant none
  9. // @homepage https://github.com/fxolan/freerice-multiplication-script-bot
  10. // @license The Unlicense
  11. // @supportURL https://github.com/fxolan/freerice-multiplication-script-bot/issues
  12. // ==/UserScript==
  13.  
  14. function eval() {
  15.  
  16. let text = document.querySelector('.card-title').innerText;
  17.  
  18. let numbers = text.split(' x ');
  19.  
  20. return numbers[0] * numbers[1];
  21. }
  22.  
  23. function clickAnswer() {
  24. let answers = document.querySelectorAll('.card-button');
  25.  
  26. for (let i = 0; i < answers.length; i++) {
  27. if (answers[i].innerText == eval()) {
  28. answers[i].click();
  29. break;
  30. }
  31. }
  32. }
  33. setInterval(clickAnswer, 1000);
  34. 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.