Updated Quizlet Micromatch bot

Win micromatch in less than a second! this is based off of the original script by , but basically all of the code has been replaced by my own

目前为 2019-09-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Updated Quizlet Micromatch bot
  3. // @namespace BenjaminHinchliff
  4. // @version 0.1
  5. // @description Win micromatch in less than a second! this is based off of the original script by , but basically all of the code has been replaced by my own
  6. // @author You
  7. // @match https://quizlet.com/*/match*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. // this is based off of the original script for this,
  12. // but basically all of the code has been replaced by my own
  13.  
  14. // a little function to allow the program to click on elements
  15. function clickEvent(element) {
  16. let eve = new CustomEvent("pointerdown", { bubbles: true });
  17. element.dispatchEvent(eve);
  18. }
  19.  
  20. let rawTerms = Quizlet.matchModeData.terms;
  21. let terms = {};
  22. // get terms from Quizlet object (a global variable because I only want to retrive it once)
  23. for (let i = 0; i < rawTerms.length; i++) {
  24. terms[rawTerms[i].word] = rawTerms[i].definition;
  25. }
  26.  
  27. // wait until user presses start
  28. document.onclick = ()=>{
  29. // get all the nodes and store them in a variable to avoid re-querying nodes (I know it's live shut up)
  30. let nodes = document.querySelector(".MatchModeQuestionGridBoard-tiles").childNodes;
  31. for (let i = 0; i < nodes.length; i++) {
  32. // get term
  33. let search = nodes[i].childNodes[0].childNodes[0].childNodes[0].childNodes[0].innerHTML;
  34. // match with definition
  35. let dictionaryResult = terms[search];
  36. if(dictionaryResult) {
  37. // find term in nodes and send click events
  38. for (let j = 0; j < nodes.length; j++) {
  39. if (nodes[j].innerHTML.includes(dictionaryResult)) {
  40. setTimeout(() => {
  41. clickEvent(nodes[i].childNodes[0]);
  42. clickEvent(nodes[j].childNodes[0]);
  43. },
  44. i * 50); // this is only here because quizlet doesn't allow score below 0.5 seconds and this roughly comes out to 0.5
  45. }
  46. }
  47. }
  48. }
  49. };