Quizlet gravity game "helper"

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

当前为 2016-12-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Quizlet gravity game "helper"
  3. // @namespace Danielv123
  4. // @version 1.4
  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. selector = "#GravityGameTarget > div > div > div > div.ModeLayout-content > div > div.GravityGameplayView-inner > div:nth-child(5) > div > div > div > .TermText > .TermText";
  12.  
  13. setInterval(function() {
  14. //console.log(words);
  15. translatedWord = words[document.querySelector(selector).innerHTML.replace(RegExp(
  16. '<!--[\\s\\S]*?(?:-->)?'
  17. + '<!---+>?' // A comment with no body
  18. + '|<!(?![dD][oO][cC][tT][yY][pP][eE]|\\[CDATA\\[)[^>]*>?'
  19. + '|<[?][^>]*>?', // A pseudo-comment
  20. 'g'), "")];
  21. //console.log(translatedWord);
  22. // update the feedback button with one of our AJAX words
  23. // select the "Restart" button
  24. document.querySelector("#GravityGameTarget > div > div > div > div.ModeLayout-controls > div > div > div > div.ModeControls-main > div.ModeControls-actions > div:nth-child(2) > div > button > span").innerHTML = translatedWord;
  25. }, 100);
  26. // load words using AJAX on load
  27. words = {};
  28. function loadXMLDoc(link) {
  29. var xmlhttp = new XMLHttpRequest();
  30. xmlhttp.onreadystatechange = function() {
  31. if (xmlhttp.readyState == XMLHttpRequest.DONE ) {
  32. if (xmlhttp.status == 200) {
  33. words = {};
  34. var element = document.createElement('div');
  35. element.insertAdjacentHTML('beforeend', xmlhttp.responseText);
  36. adsaf = element.querySelectorAll(".TermText");
  37. for(i=0;i<adsaf.length;i+=2){
  38. words[adsaf[i].innerHTML] = adsaf[i+1].innerHTML;
  39. }
  40. }
  41. }
  42. };
  43. xmlhttp.open("GET", link, true);
  44. xmlhttp.send();
  45. }
  46. loadXMLDoc("https://quizlet.com/"+document.location.pathname.split("/")[1]+"/original?_pjax");
  47.