Quizlet gravity game "helper"

The correct answer pops up in the browser console and the feedback button down left

当前为 2017-02-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Quizlet gravity game "helper"
  3. // @namespace Danielv123
  4. // @version 2.0
  5. // @description The correct answer pops up in the browser console and the feedback button down left
  6. // @author You
  7. // @match https://quizlet.com/*/gravity
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. // get word from asteroid
  13. selector = "#GravityGameTarget > div > div > div > div.ModeLayout-content > div > div.GravityGameplayView-inner > div:nth-child(5) > div > div > div > .TermText > .TermText";
  14. outputSelector = "#GravityGameTarget > div > div > div > div.ModeLayout-controls > div > div > div > div.ModeControls-main > div.ModeControls-actions > div:nth-child(2) > div > button > span";
  15.  
  16. setInterval(function() {
  17. // console.log(words);
  18. if(document.querySelector(selector).innerHTML){
  19. translatedWord = words[document.querySelector(selector).innerHTML.replace(RegExp(
  20. '<!--[\\s\\S]*?(?:-->)?'
  21. + '<!---+>?' // A comment with no body
  22. + '|<!(?![dD][oO][cC][tT][yY][pP][eE]|\\[CDATA\\[)[^>]*>?'
  23. + '|<[?][^>]*>?', // A pseudo-comment
  24. 'g'), "")];
  25. console.log(translatedWord);
  26. // update the feedback button with one of our translated words
  27. document.querySelector(outputSelector).innerHTML = translatedWord;
  28. }
  29. }, 100);
  30.  
  31. // Quizlet.gravityData.terms[0].definition gets data straight from quizlet :3
  32. words = {};
  33. for(i = 0; i<Quizlet.gravityData.terms.length; i++){
  34. words[Quizlet.gravityData.terms[i].word] = Quizlet.gravityData.terms[i].definition;
  35. }