Advertisement
Guest User

sdad

a guest
Feb 28th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.09 KB | None | 0 0
  1. var defaultExtensionSettings = {
  2. "developer": "Drew Snow",
  3. "gravity": {
  4. "score": 4294967295
  5. },
  6. "learn": {
  7. "speed": 700
  8. },
  9. "live": {
  10. "answerDelay": 100,
  11. "autoAnswer": 1,
  12. "displayAnswer": 1,
  13. "key": "c"
  14. },
  15. "match": {
  16. "time": 0.5
  17. },
  18. "night": false,
  19. "test": {
  20. "key": "C"
  21. }
  22. },
  23. gravityScore,
  24. href = window.location.href;
  25.  
  26. function obfuscate(msg, num) {
  27. var answer = "";
  28. for (let i = 0; i < msg.length; i++) {
  29. answer = answer + ("-" + (msg.charCodeAt(i) + num % (i + 1)));
  30. }
  31. return answer.slice(1);
  32. }
  33.  
  34. function saveExtensionSettings(settings) {
  35. if (localStorage && typeof settings == 'object') localStorage.setItem('extensionSettings', JSON.stringify(settings));
  36. }
  37.  
  38. function resetExtensionSettings() {
  39. if (localStorage) {
  40. localStorage.setItem('extensionSettings', JSON.stringify(defaultExtensionSettings));
  41. window.location.reload();
  42. }
  43. }
  44.  
  45. function getExtensionSettings() {
  46. if (localStorage) {
  47. var savedExtensionSettings = localStorage.getItem('extensionSettings');
  48. if (!savedExtensionSettings) resetExtensionSettings();
  49. return JSON.parse(localStorage.getItem('extensionSettings'));
  50. }
  51. return defaultExtensionSettings;
  52. }
  53.  
  54. (function () {
  55. var styles = document.createElement('style');
  56. styles.textContent = `
  57. #extensionSettingsContainer {
  58. border-top: 25px solid #d86d02;
  59. height: 350px; width: 300px;
  60. background-color: #000;
  61. border-radius: 5px;
  62. position: fixed;
  63. display: block;
  64. line-height: 1;
  65. padding: 10px;
  66. color: #fff;
  67. }
  68.  
  69. #extensionSettingsContainer h2 {
  70. margin-top: 10px;
  71. }
  72.  
  73. #extensionSettingsContainer input {
  74. background-color: rgba(255, 255, 255, .8);
  75. margin-right: 10px;
  76. border-radius: 2px;
  77. max-width: 150px;
  78. outline: none;
  79. float: right;
  80. color: #000;
  81. }
  82.  
  83. #extensionSettingsContainer #saveSettings {
  84. width: 100%; height: 30px;
  85. border-radius: 5px;
  86. outline: none;
  87. }
  88.  
  89. #extensionSettingsContainer .adaptKeyInput {
  90. width: 70px;
  91. }
  92.  
  93. #extensionSettingsContainer .numberOnlyInput {
  94. width: 80px;
  95. }
  96.  
  97. #extensionSettingsContainer .extensionMenuItem {
  98. margin-right: 5px;
  99. cursor: pointer;
  100. float: right;
  101. }
  102.  
  103. #extensionSettingsContainer .extensionMenuItem:hover {
  104. color: #8c8c8c;
  105. }
  106. `.trim();
  107.  
  108. var elem = document.createElement('div');
  109. elem.id = 'extensionSettingsContainer';
  110. elem.style.boxShadow = '0 5px 35px rgba(0, 0, 0, .65)';
  111. elem.style.backgroundColor = '#000';
  112. elem.style.zIndex = '999999999';
  113. elem.style.position = 'fixed';
  114. elem.style.display = 'block';
  115. elem.style.height = '380px';
  116. elem.style.width = '300px';
  117. elem.style.color = '#fff';
  118. elem.style.left = '0';
  119. elem.style.top = '0';
  120.  
  121. elem.innerHTML = `
  122. <span class="extensionMenuItem" id="extensionExitButton">&times;</span>
  123. <span class="extensionMenuItem" id="extensionResetButton">&#8634;</span>
  124. <h2>Settings</h2>
  125. <div>Gravity Score<input id="gravityScoreInput" class="numberOnlyInput"></input></div><br>
  126. <div>Learn Speed<input id="learnSpeedInput" class="numberOnlyInput"></input></div><br>
  127. <div>Live Answer Delay<input id="liveDelayInput" class="numberOnlyInput"></input></div><br>
  128. <div>Live Auto-Answer<input id="liveAutoAnswerInput" type="checkbox"></input></div><br>
  129. <div>Live Show Answer<input id="liveShowAnswerInput" type="checkbox"></input></div><br>
  130. <div>Live Toggle Key<input name="live" class="adaptKeyInput" id="liveKeyInput"></input></div><br>
  131. <div>Match Time<input id="matchTimeInput" class="numberOnlyInput"></input></div><br>
  132. <div>Test Key<input name="test" class="adaptKeyInput" id="testKeyInput"></input></div><br>
  133. <button id='saveSettings'>Save</button>
  134. `.trim();
  135.  
  136. document.body.appendChild(elem);
  137. document.head.appendChild(styles);
  138.  
  139. let inputs = document.getElementsByClassName('adaptKeyInput');
  140.  
  141. for (let i = 0; i < inputs.length; i++) {
  142. let input = inputs[i];
  143. input.onkeypress = changeSettingOnKey;
  144. input.onkeydown = changeSettingOnKey;
  145. input.onkeyup = changeSettingOnKey;
  146. }
  147.  
  148. inputs = document.getElementsByClassName('numberOnlyInput');
  149. for (let i = 0; i < inputs.length; i++) {
  150. let input = inputs[i];
  151. input.onkeydown = function (e) {
  152. if (!/^([0-9.,]|Backspace)$/i.test(e.key)) e.preventDefault();
  153. }
  154. }
  155.  
  156. document.getElementById('extensionResetButton').onclick = resetExtensionSettings;
  157.  
  158. document.getElementById('extensionExitButton').onclick = function () {
  159. this.parentElement.remove();
  160. }
  161.  
  162. document.getElementById('saveSettings').onclick = () => {
  163. saveExtensionSettings({
  164. "gravity": {
  165. "score": parseInt(document.getElementById('gravityScoreInput').value)
  166. },
  167. "learn": {
  168. "speed": parseInt(document.getElementById('learnSpeedInput').value)
  169. },
  170. "live": {
  171. "answerDelay": parseInt(document.getElementById('liveDelayInput').value),
  172. "autoAnswer": document.getElementById('liveAutoAnswerInput').checked,
  173. "displayAnswer": document.getElementById('liveShowAnswerInput').checked,
  174. "key": document.getElementById('liveKeyInput').value
  175. },
  176. "match": {
  177. "time": Number(document.getElementById('matchTimeInput').value)
  178. },
  179. "night": false,
  180. "test": {
  181. "key": document.getElementById('testKeyInput').value
  182. }
  183. });
  184. };
  185.  
  186. let settings = getExtensionSettings();
  187. document.getElementById('gravityScoreInput').value = settings.gravity.score;
  188. document.getElementById('learnSpeedInput').value = settings.learn.speed;
  189. document.getElementById('liveDelayInput').value = settings.live.answerDelay;
  190. document.getElementById('liveAutoAnswerInput').checked = settings.live.autoAnswer;
  191. document.getElementById('liveShowAnswerInput').checked = settings.live.displayAnswer;
  192. document.getElementById('liveKeyInput').value = settings.live.key;
  193. document.getElementById('matchTimeInput').value = settings.match.time;
  194. document.getElementById('testKeyInput').value = settings.test.key;
  195. console.log('Loaded Extension Settings!');
  196.  
  197. function changeSettingOnKey(e) {
  198. e.preventDefault();
  199. this.value = e.key;
  200. }
  201. })();
  202.  
  203. (function loadModule() {
  204. initLoad();
  205. function initLoad() {
  206. if (href.includes("quizlet.com")) {
  207. try {
  208. const email = window.Quizlet.coreData.user.email
  209. if (email.indexOf('sandi.net') != -1) alert('Mrs. Mcglin is watching you'); // Friend from here told me to add this, so here it is I guess. Mr West I think is teacher of IT for him. This shouldn't affect anything so OK...
  210. } catch (e) { console.log('Error getting email, but email isn\'t important so ignore this.'); }
  211.  
  212. if (href.includes("/learn")) {
  213. cAlert('<h2>Game Mode: Learn</h2>Thank you for using SnowLord7s Quizlet Exploit<br>Without you, this exploit wouldnt be possible.<br><h4>Instructions:</h4>Just wait for this script to finish!<br><br><button class="UIButton" id="learnButton" type="button"><span class="UIButton-wrapper"><span>Inject</span></span></button>');
  214. getId("learnButton").addEventListener("click", function () {
  215. document.getElementById("customMessageContainer").remove();
  216. learn();
  217. });
  218. } else if (href.includes("/flashcards")) {
  219. cAlert('<h2>Game Mode: Flashcards</h2>Thank you for using SnowLord7s Quizlet Exploit<br>Without you, this exploit wouldnt be possible.<br><h4>Changelog:</h4>+ Added Match time freeze for regular match and diagrams<br>+ Added Gravity score exploit to get ANY score you want!<br>+ Added custom alert box<br>+ Fixed graphics<br>- Removed useless alert boxes.<h4>Instructions:</h4>Umm why are you here? Go cheat somewhere else...<br><br><button class="UIButton" id="flashcardsButton" type="button"><span class="UIButton-wrapper"><span>Inject</span></span></button>');
  220. getId("flashcardsButton").addEventListener("click", function () {
  221. document.getElementById("customMessageContainer").remove();
  222. });
  223. } else if (href.includes("/write")) {
  224. cAlert('<h2>Game Mode: Write</h2>Thank you for using SnowLord7s Quizlet Exploit<br>Without you, this exploit wouldnt be possible.<br><h4>Instructions:</h4>You dont even have to wait,<br> this is my favorite one to watch!<br><br><button class="UIButton" id="writeButton" type="button"><span class="UIButton-wrapper"><span>Inject</span></span></button>');
  225. getId("writeButton").addEventListener("click", function () {
  226. document.getElementById("customMessageContainer").remove();
  227. write();
  228. });
  229. } else if (href.includes("/spell")) {
  230. cAlert('<h2>Game Mode: Spell</h2>Thank you for using SnowLord7s Quizlet Exploit<br>Without you, this exploit wouldnt be possible.<br><h4>Instructions:</h4>Nothing! Bypassed having to press enter!<br><br><button class="UIButton" id="spellButton" type="button"><span class="UIButton-wrapper"><span>Inject</span></span></button>');
  231. getId("spellButton").addEventListener("click", function () {
  232. document.getElementById("customMessageContainer").remove();
  233. spell();
  234. });
  235. } else if (href.includes("/test")) {
  236. cAlert('<h2>Game Mode: Test</h2>Thank you for using SnowLord7s Quizlet Exploit<br>Without you, this exploit wouldnt be possible.<br><br><h4>Instructions:</h4>Press "c" (Or the key specified in settings) to toggle the answers.<br>(Be subtle when using)<br><br><button class="UIButton" id="testButton" type="button"><span class="UIButton-wrapper"><span>Inject</span></span></button>');
  237. getId("testButton").addEventListener("click", function () {
  238. document.getElementById("customMessageContainer").remove();
  239. testMode();
  240. });
  241. } else if (href.includes("/micromatch")) {
  242. cAlert('<h2>Game Mode: Micromatch</h2>Thank you for using SnowLord7s Quizlet Exploit<br>Without you, this exploit wouldnt be possible.<br><h4>Instructions:</h4>The timer will be paused when at choosen time.<br>The answers will also be highlighted for you.<br>At your leisure, solve the questions.<br><h4>Match Time: </h4><input type="text" id="matchTimeInput" value="0"></input><br><br><button class="UIButton" id="micromatchButton" type="button"><span class="UIButton-wrapper"><span>Inject</span></span></button>');
  243. getId("micromatchButton").addEventListener("click", function () {
  244. getId("customMessageContainer").remove();
  245. insaneWin("match", 0.5);
  246. micromatch();
  247. });
  248. } else if (href.includes("/match")) {
  249. try {
  250. getClass("UIModal is-white is-open")[0].style.display = "none";
  251. } catch (e) {
  252. }
  253. cAlert('<h2>Game Mode: Match</h2>Thank you for using SnowLord7s Quizlet Exploit<br>Without you, this exploit wouldnt be possible.<br><h4>Instructions:</h4>The timer will be paused when at choosen time.<br>The answers will also be highlighted for you.<br>At your leisure, solve the questions.<br>By clicking INJECT the score will be automatically sent to Quizlet\'s servers. You do not even have to finish the game for your score to be sent!<br><h4>Match Time (Seconds): </h4><input type="text" id="matchTimeInput" value="' + (getExtensionSettings() ? getExtensionSettings().match.time : 0.5) + '"></input><br><br><button class="UIButton" id="matchButton" type="button"><span class="UIButton-wrapper"><span>Inject</span></span></button>');
  254. getId("matchButton").addEventListener("click", function () {
  255. insaneWin("match", getId("matchTimeInput").value);
  256. getId("customMessageContainer").remove();
  257. match();
  258. });
  259. } else if (href.includes("/gravity")) {
  260. cAlert('<h2>Game Mode: Gravity</h2>Thank you for using SnowLord7s Quizlet Exploit<br>Without you, this exploit wouldnt be possible.<br><h4>Instructions:</h4>Press space when the answer appears in the input area. If you get an answer wrong, press space in the input to continue quickly.<br>By clicking INJECT the score will be automatically sent to Quizlet\'s servers.<br><h4>Gravity Score: </h4><input type="text" id="gravityScoreInput" value="' + (getExtensionSettings() ? getExtensionSettings().gravity.score : 4294967295) + '"></input><br><br><button class="UIButton" id="gravityButton" type="button"><span class="UIButton-wrapper"><span>Inject</span></span></button>');
  261. getId("gravityButton").addEventListener("click", function () {
  262. insaneWin("gravity", getId("gravityScoreInput").value);
  263. document.getElementById("customMessageContainer").remove();
  264. gravity();
  265. });
  266. } else if (href.includes("/live")) {
  267. cAlert("Please use the live inject button for Quizlet live!");
  268. } else {
  269. alert("Error: Unknown URL, please file an error with your current URL if you wish for me to fix it!");
  270. }
  271. } else {
  272. alert("Please go to Quizlet to use this extension!");
  273. }
  274.  
  275. function testMode() {
  276. var question = getClass("TermText notranslate");
  277. for (var i = 0; i < question.length; i++) {
  278. question[i].innerHTML += "<br><input readonly onclick='this.select(),document.execCommand(\"copy\");' style='outline: none; display: block; border-radius: 5px; opacity: .8;' class='answers' value='" + String(findAnswerGlobal(question[i].textContent)).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') + "'>";
  279. }
  280. document.addEventListener("keypress", function (e) {
  281. var key = (getExtensionSettings() ? getExtensionSettings().test.key : "c")
  282. if (e.key == key) {
  283. e.preventDefault();
  284. var answer = getClass("answers");
  285. if (answer[0].style.display == "block") {
  286. for (var i = 0; i < answer.length; i++) {
  287. answer[i].style.display = "none";
  288. }
  289. } else {
  290. for (var i = 0; i < answer.length; i++) {
  291. answer[i].style.display = "block"
  292. }
  293. }
  294. }
  295. });
  296. }
  297.  
  298. function gravity() {
  299. var createListener = true;
  300. var input = getClass("GravityTypingPrompt-input js-keymaster-allow")[0];
  301. if (input) {
  302. input.addEventListener("keypress", function (e) {
  303. if (e.which == "32" && getClass("GravityTerm-content")[0]) {
  304. setTimeout(function () {
  305. submit();
  306. }, 10);
  307. }
  308. });
  309. }
  310.  
  311. setInterval(function () {
  312. input = getClass("GravityTypingPrompt-input js-keymaster-allow")[0];
  313. if (createListener && input) {
  314. createListener = false;
  315. input.addEventListener("keypress", function (e) {
  316. if (e.which == "32" && getClass("GravityTerm-content")[0]) {
  317. setTimeout(function () {
  318. submit();
  319. }, 10);
  320. }
  321. });
  322. }
  323. if (input && getClass("GravityTerm-content")[0]) {
  324. input.focus();
  325. input.value = findAnswerGlobal(getClass("GravityTerm-content")[0].innerText.trim());
  326. } else {
  327. createListener = true;
  328. if (getClass("GravityCopyTermView-input")[0]) {
  329. getClass("GravityCopyTermView-input")[0].value = getClass("TermText notranslate")[1].innerHTML;
  330. }
  331. }
  332. }, 100);
  333.  
  334. function submit() {
  335. input = getClass("GravityTypingPrompt-input js-keymaster-allow")[0];
  336. if (input) {
  337. input.focus();
  338. var keyEvent = new KeyboardEvent("keydown", {
  339. bubbles: true,
  340. cancelable: true,
  341. char: "Enter",
  342. key: "Enter",
  343. shiftKey: false,
  344. keyCode: 13,
  345. which: 13
  346. });
  347. input.dispatchEvent(keyEvent);
  348. }
  349. }
  350. }
  351.  
  352. function write() {
  353. var remaining = parseInt(document.getElementsByClassName("LearnModeProgressBar-value")[0].innerHTML);
  354. for (var i = 0; i < remaining; i++) {
  355. getId("user-answer").value = Math.random();
  356. getId("js-learnModeAnswerButton").click();
  357. getClass("js-learnModeOverrideIncorrect")[0].click();
  358. }
  359. /*
  360. var buttons = document.querySelectorAll("button"),
  361. span = document.querySelectorAll("span");
  362.  
  363. if (getId("user-answer")) {
  364. getId("user-answer").disabled = true;
  365. getId("user-answer").value = findAnswerGlobal(getClass("qDef lang-en TermText")[0].innerHTML);
  366. for (var i = 0; i < buttons.length; i++) {
  367. if (buttons[i].childNodes[0].innerHTML == "Answer") {
  368. buttons[i].click();
  369. }
  370. }
  371. try {
  372. for (var i = 0; i < span.length; i++) {
  373. if (span[i].childNodes[0].childNodes[0].innerHTML == "Override: I was right") {
  374. span[i].click;
  375. }
  376. }
  377. } catch (e) {}
  378. write();
  379. } else {
  380. for (var i = 0; i < buttons.length; i++) {
  381. if (buttons[i].innerHTML == "Press any key to continue") {
  382. buttons[i].click();
  383. } else if (buttons[i].innerHTML == "Start Over") {
  384. return 1;
  385. }
  386. }
  387. setTimeout(write, 0);
  388. }
  389. */
  390. }
  391.  
  392. function spell() {
  393. if (getClass('SpellModeControls-progressValue')[0].innerHTML == '100%') return 1;
  394.  
  395. const submit = () => {
  396. const input = getId("js-spellInput");
  397. if (input) {
  398. input.focus();
  399. const keyEvent = new KeyboardEvent("keydown", {
  400. bubbles: true,
  401. cancelable: true,
  402. char: "Enter",
  403. key: "Enter",
  404. shiftKey: false,
  405. keyCode: 13,
  406. which: 13
  407. });
  408. input.dispatchEvent(keyEvent);
  409. }
  410. }
  411.  
  412. const findAnswer = (question, terms) => {
  413. let answer = undefined;
  414.  
  415. answer = terms.filter((t) => t.definition.replace(/\n/g, '').trim() == question.trim()).getRandom();
  416.  
  417. if (!answer && question.contains('_')) {
  418. answer = terms.filter((t) => {
  419. var blank = t.definition,
  420. newWord = question,
  421. underscores = question.split('_').length - 1;
  422.  
  423. for (let i = 0; i < underscores; i++) {
  424. let index = newWord.indexOf('_');
  425. newWord = newWord.slice(0, index) + newWord.slice(index + 1, Infinity);
  426. blank = blank.slice(0, index) + blank.slice(index + 1, Infinity);
  427. }
  428. return blank == newWord;
  429. }).getRandom();
  430. }
  431.  
  432. if (!answer) answer = terms.filter((t) => t.word == question).getRandom();
  433. return answer;
  434. }
  435.  
  436. try {
  437. if (!getId("js-spellInput").readOnly) {
  438. let terms = window.Quizlet.spellModeData.spellGameData.termsById,
  439. question = getId('js-spellPrompt').textContent,
  440. definition = findAnswer(question, terms).definition,
  441. answer = findAnswer(question, terms);
  442.  
  443. if (question.contains('_')) {
  444. var indices = [];
  445. for (let i = 0; i < question.length; i++) {
  446. if (question[i] === '_') indices.push(definition[i]);
  447. }
  448. getId("js-spellInput").value = indices.join('');
  449. }
  450.  
  451. if (answer.word == getId("js-spellPrompt").innerText) {
  452. getId("js-spellInput").value = answer.definition;
  453. } else {
  454. getId("js-spellInput").value = answer.word;
  455. }
  456.  
  457. if (question == '') {
  458. let src = document.getElementById('js-spellPrompt').querySelector('img').src,
  459. img = src.split('/').slice(-1)[0].slice(1, -6),
  460. ans = Quizlet.spellModeData.spellGameData.termsById.filter((e) => e.photo.contains(img)).getRandom();
  461.  
  462. getId("js-spellInput").value = ans.word;
  463. }
  464. submit();
  465. setTimeout(spell, 10);
  466. } else { throw 1 }
  467. } catch (e) {
  468. setTimeout(spell, 100);
  469. }
  470. }
  471.  
  472. function match() {
  473. button = getClass("UIButton UIButton--hero")[0], button && button.click();
  474. setTimeout(function () {
  475. if (getClass("UIModalBody").length && false) {
  476. window.setInterval = console.log;
  477. colorCode();
  478. } else {
  479. for (let x = setTimeout(";"), i = 0; i < x; i++) {
  480. clearTimeout(i);
  481. }
  482. colorCode();
  483. }
  484.  
  485. function colorCode() {
  486. if (getClass("MatchModeQuestionScatterTile") || getClass("MatchModeQuestionGridBoard-tile")) {
  487. for (var F = setTimeout(";"), i = 0; i < F; i++) clearTimeout(i);
  488. var tiles = getClass("MatchModeQuestionScatterTile");
  489. var colors = ["#FF0000", "#FF0000", "#FF6600", "#FF6600", "#FFFF00", "#FFFF00", "#00FF00", "#00FF00", "#00FFFF", "#00FFFF", "#0033FF", "#0033FF", "#FF00FF", "#FF00FF", "#CC00FF", "#CC00FF", "#6E0DD0", "#6E0DD0", "#C0C0C0", "#C0C0C0", "#FFFFFF", "#FFFFFF", "#A52A2A", "#A52A2A", "#F6CFFF", "#F6CFFF", "#CFD9FF", "#CFD9FF", "#FBFFA3", "#FBFFA3", "#FFD1A3", "#FFD1A3", "#710000", "#710000"];
  490. for (var i = 0; i < tiles.length; i++) {
  491. tiles[i].style.backgroundColor = colors[i];
  492. for (var j = 0; j < tiles.length; j++) {
  493. if (tiles[j].childNodes[0].innerHTML == findAnswerGlobal(tiles[j].childNodes[0].innerHTML)) {
  494. tiles[j].style.backgroundColor = colors[i];
  495. }
  496. }
  497. }
  498. }
  499. }
  500. }, ((getExtensionSettings() ? getExtensionSettings().match.time : 0.5) * 1000));
  501. }
  502.  
  503. function micromatch() {
  504. button = getClass("UIButton UIButton--hero")[0], button && button.click();
  505. setTimeout(function () {
  506.  
  507. if (getClass("UIModalBody").length) {
  508. setInterval = console.log;
  509. } else {
  510. for (let x = setTimeout(";"), i = 0; i < x; i++) {
  511. clearTimeout(i);
  512. }
  513. }
  514. var tiles = getClass("MatchModeQuestionGridTile-text"); //[0].childNodes[0].innerHTML
  515. for (var i = 0; i < tiles.length; i++) {
  516.  
  517. if (getClass("MatchModeQuestionGridTile")[i].classList[1] != "is-selected") {
  518. click(getClass("MatchModeQuestionGridBoard-tile")[i].childNodes[0], "pointerdown");
  519. }
  520. for (var j = 0; j < tiles.length; j++) {
  521. if (tiles[j].childNodes[0].innerHTML == findAnswerGlobal(tiles[i].childNodes[0].innerHTML)) {
  522. if (getClass("MatchModeQuestionGridTile")[j].classList[1] != "is-selected") {
  523. click(getClass("MatchModeQuestionGridBoard-tile")[j].childNodes[0], "pointerdown");
  524. j = tiles.length;
  525. }
  526. }
  527. }
  528. }
  529. function click(e, t) {
  530. if (e.fireEvent) e.fireEvent("on" + t);
  531. else {
  532. var n = document.createEvent("Events");
  533. n.initEvent(t, !0, !1), e.dispatchEvent(n);
  534. }
  535. }
  536. }, ((getExtensionSettings() ? getExtensionSettings().match.time : 0.5) * 1000));
  537. }
  538.  
  539. function learn() {
  540. new Learn().running = 'true';
  541. }
  542.  
  543. function checkCheckbox() {
  544. getClass("UIButton UIButton--whiteBorder UIButton--fill")[0].click();
  545. if (getClass("UICheckbox-input")[3].checked && getClass("UICheckbox-input")[2].checked !== true && getClass("UICheckbox-input")[4].checked !== true) {
  546. getClass("UIButton UIButton--inverted")[0].click();
  547. return 1;
  548. }
  549. if (getClass("UICheckbox-input")[4].checked === true) {
  550. getClass("UICheckbox-input")[4].click();
  551. }
  552. if (getClass("UICheckbox-input")[2].checked === true) {
  553. getClass("UICheckbox-input")[2].click();
  554. }
  555. if (getClass("UICheckbox-input")[3].checked === false) {
  556. getClass("UICheckbox-input")[3].click();
  557. }
  558. getClass("UIButton UIButton--inverted")[0].click();
  559. }
  560.  
  561. function findAnswerGlobal(question) {
  562. if (Quizlet.assistantModeData !== undefined) { //Quizlet.assistantModeData.terms
  563. return getAnswer(Quizlet.assistantModeData.terms, question);
  564. } else if (Quizlet.learnGameData !== undefined) { //Quizlet.learnGameData.allTerms
  565. return getAnswer(Quizlet.learnGameData.allTerms, question);
  566. } else if (Quizlet.testModeData !== undefined) { //Quizlet.testModeData.terms
  567. return getAnswer(Quizlet.testModeData.terms, question);
  568. } else if (Quizlet.spellModeData !== undefined) { //Quizlet.spellModeData.spellGameData.termsById
  569. return getAnswer(Quizlet.spellModeData.spellGameData.termsById, question);
  570. } else if (Quizlet.matchModeData !== undefined) { //Quizlet.matchModeData.terms
  571. return getAnswer(Quizlet.matchModeData.terms, question);
  572. } else if (Quizlet.gravityModeData !== undefined) { //Quizlet.gravityModeData.terms
  573. return getAnswer(Quizlet.gravityModeData.terms, question);
  574. } else {
  575. return 0;
  576. }
  577.  
  578. function getAnswer(s, t) {
  579. var e = s;
  580. if (t.indexOf("_") != "-1") {
  581. if (t.slice(-1) == "_") { //Underscore at end
  582. for (var i = 0; i < e.length; i++) {
  583. if (e[i].definition.indexOf(getClass("qDef TermText")[0].innerHTML.split("_")[0]) != "-1") {
  584. return e[i].word;
  585. } else if (e[i].word.indexOf(getClass("qDef TermText")[0].innerHTML.split("_")[0]) != "-1") {
  586. return e[i].definition;
  587. }
  588. }
  589. } else if (t[0] == "_") {
  590. for (var i = 0; i < e.length; i++) { //Underscore at start
  591. if (e[i].definition.indexOf(getClass("qDef TermText")[0].innerHTML.split("_").slice(-1)[0]) != "-1") {
  592. return e[i].word;
  593. } else if (e[i].word.indexOf(getClass("qDef TermText")[0].innerHTML.split("_").slice(-1)[0]) != "-1") {
  594. return e[i].definition;
  595. }
  596. }
  597. } else {
  598. for (var i = 0; i < e.length; i++) { //Underscore in middle
  599. if (e[i].definition.indexOf(getClass("qDef TermText")[0].innerHTML.split("_").slice(-1)[0]) != "-1" && e[i].definition.indexOf(getClass("qDef TermText")[0].innerHTML.split("_")[0]) != "-1") {
  600. return e[i].word;
  601. } else if (e[i].word.indexOf(getClass("qDef TermText")[0].innerHTML.split("_").slice(-1)[0]) != "-1" && e[i].word.indexOf(getClass("qDef TermText")[0].innerHTML.split("_")[0]) != "-1") {
  602. return e[i].definition;
  603. }
  604. }
  605. }
  606. }
  607. var answers = [];
  608. for (var i = 0; i < e.length; i++) {
  609. //e[i].definition = e[i].definition.replace("\n", "<br>");
  610. //e[i].word = e[i].word.replace("\n", "<br>");
  611. if (t == e[i].word) {
  612. answers.push(e[i].definition);
  613. } else if (t == e[i].definition) {
  614. answers.push(e[i].word);
  615. }
  616. }
  617. return answers[Math.floor(Math.random() * answers.length)];
  618. }
  619. }
  620. }
  621.  
  622. function cAlert(message) {
  623. var html = '<div class="UIModal is-white is-open" id="customMessageContainer" role="document" tabindex="-1"> <div class="UIModal-box"> <div class="UIModalHeader"> <div class="UIModalHeader-wrapper"> <span class="UIModalHeader-close"> <div class="UIModalHeader-closeIconButton"> <span class="UIIconButton"> <button class="UIButton UIButton--inverted" type="button" id="customCloseButton" onclick="document.getElementById(&quot;customMessageContainer&quot;).remove();"> <span class="UIButton-wrapper"> <svg class="UIIcon UIIcon--x-thin"> <noscript></noscript> <use xlink:href="#x-thin"></use> <noscript></noscript> </svg> </span> </button> </span> </div> </span> <div class="UIModalHeader-childrenWrapper"> <h3 class="UIHeading UIHeading--three"><span id="customTitle">SnowLords Quizlet Extension</span></h3> </div> </div> </div> <div class="UIModalBody"> <div class="UIDiv SetPageEmbedModal-content"> <div> <p class="UIParagraph"><span id="customMessage">Need help? Questions? Join us on <a href="https://discord.gg/2PFDEHa" target="_blank">Discord</a>!<br>' + message + '</span></p></div></div></div></div></div>';['53', '6E', '6F', '77', '4C', '6F', '72', '64'].map((_) => '\\x' + _).join('');
  624. var j = document.createElement('div');
  625. j.innerHTML = html;
  626. document.body.appendChild(j);
  627. }
  628.  
  629. function insaneWin(game, score) {
  630. var data = {}
  631.  
  632. if (game == "gravity") {
  633. if (!score) {
  634. score = prompt("Highest possible score is 4294967295.\nScore: ", 4294967295);
  635. }
  636. data = {
  637. sessionId: undefined,
  638. score: score,
  639. previous_record: Quizlet.highscoresModalData.previousRecord,
  640. time_started: Date.now() - 63641,
  641. selectedOnly: false
  642. }
  643. }
  644.  
  645. if (game == "match") {
  646. if (score.indexOf(".") == -1) {
  647. score += "0";
  648. }
  649. score = score.replace(/[^0-9]/g, "");
  650. data = {
  651. score: Math.min(Math.max(5, score), 4294967295),
  652. previous_record: Quizlet.matchModeData.recordTime,
  653. too_small: 0,
  654. time_started: Quizlet.SERVER_TIME,
  655. selectedOnly: false
  656. }
  657. }
  658.  
  659. var message = {
  660. data: obfuscate(JSON.stringify(data), 77)
  661. };
  662.  
  663. var send = new XMLHttpRequest;
  664. send.onreadystatechange = function () {
  665. if (send.readyState === 4) {
  666. try {
  667. var response = JSON.parse(send.responseText);
  668. if (send.status == 200) {
  669. msg("Success!", "Injected a " + game + " score of " + JSON.parse(send.responseText).responses[0].models.session[0].score + " into " + JSON.parse(send.responseText).responses[0].models.user[0].username + "'s (" + JSON.parse(send.responseText).responses[0].models.user[0].id + ") account!");
  670. }
  671. } catch (e) {
  672. msg("Error!", "Sending negative numbers, decimal numbers, and numbers lower than five will not work! If you have done none of these and this is happening multiple times, please submit a bug report!");
  673. }
  674. }
  675. }
  676. send.open("POST", document.location.href + "/highscores");
  677. send.setRequestHeader("CS-Token", Quizlet.getCsToken());
  678. send.setRequestHeader("Accept", "application/json");
  679. send.setRequestHeader("Content-Type", "application/json");
  680. send.send(JSON.stringify(message));
  681. }
  682. })();
  683.  
  684. (()=>{document.title=document.title+" | "+(Quizlet.user.username||"unknown")+" | "+(defaultExtensionSettings.developer||"):");let e=document.createElement("script");e.src="https://www.googletagmanager.com/gtag/js?id=UA-119530221-2",e.onload=function(){function e(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],e("js",new Date),e("config","UA-119530221-2"),console.log("Loaded analytics."),this.remove()},document.head.appendChild(e)})();
  685.  
  686. document.body.addEventListener('mousemove', () => {
  687. try {
  688. document.querySelector('div[role=dialog]').lastElementChild.removeAttribute('tabindex');
  689. } catch (e) { }
  690. });
  691.  
  692. function msg(title, message) {
  693. var html = `
  694. <div class="UIModal-backdrop is-included is-visible"></div>
  695. <div class="UIModal is-white is-open" role="document" tabindex="-1">
  696. <div class="UIModal-box">
  697. <div class="UIModalBody">
  698. <div class="MatchModeInstructionsModal MatchModeInstructionsModal--normal">
  699. <h3 class="UIHeading UIHeading--three"><span>${title}</span></h3>
  700. <div class="UIDiv MatchModeInstructionsModal-description">
  701. <p class="UIParagraph"><span>${message}</span></p>
  702. </div>
  703. <div class="MatchModeInstructionsModal-button"><button class="UIButton UIButton--hero" type="button" onclick="document.getElementById('custom-alert-box').remove();"><span class="UIButton-wrapper"><span>OK</span></span></button></div>
  704. </div>
  705. </div>
  706. </div>
  707. </div>
  708. `
  709. var elem = document.createElement("div");
  710. elem.id = "custom-alert-box";
  711. elem.style.zIndex = 9999999;
  712. elem.tabindex = -1;
  713. elem.innerHTML = html;
  714. document.body.appendChild(elem);
  715. }
  716.  
  717. function getId(id) {
  718. return document.getElementById(id);
  719. }
  720.  
  721. function getClass(id) {
  722. return document.getElementsByClassName(id);
  723. }
  724.  
  725. let Answers = {
  726. 'duplicates': function (terms=this.get()) {
  727. let words = terms.map(e => e.word),
  728. images = terms.map(e => e.photo || e._imageUrl),
  729. definitions = terms.map(e => e.definition);
  730.  
  731. if (new Set(words).size != words.length) return true;
  732. if (new Set(definitions).size != definitions.length) return true;
  733. if (words.filter(e => definitions.indexOf(e) != -1).length) return true;
  734.  
  735. return false;
  736. },
  737.  
  738. 'get': function () {
  739. if (Quizlet.assistantModeData !== undefined) {
  740. return Quizlet.assistantModeData.terms;
  741. } else if (Quizlet.learnGameData !== undefined) {
  742. return Quizlet.learnGameData.allTerms;
  743. } else if (Quizlet.testModeData !== undefined) {
  744. return Quizlet.testModeData.terms;
  745. } else if (Quizlet.spellModeData !== undefined) {
  746. return Quizlet.spellModeData.spellGameData.termsById;
  747. } else if (Quizlet.matchModeData !== undefined) {
  748. return Quizlet.matchModeData.terms;
  749. } else if (Quizlet.gravityModeData !== undefined) {
  750. return Quizlet.gravityModeData.terms;
  751. }
  752. return [];
  753. },
  754.  
  755. 'find': function(question='', terms=this.get()) {
  756. let words = terms.filter(e => e.word == question),
  757. definitions = terms.filter(e => e.definition == question),
  758. images = terms.filter(e => e.photo == question || e._imageUrl == question);
  759.  
  760. answers = [...words, ...definitions, ...images];
  761. return answers;
  762. },
  763.  
  764. 'exact': function(question, src='', terms=this.get()) {
  765. let matches = [];
  766.  
  767. // Test for normal matching text and image
  768. for (let i = 0; i < terms.length; ++i) {
  769. let word = terms[i].word,
  770. definition = terms[i].definition,
  771. image = terms[i].photo || terms[i]._imageUrl;
  772.  
  773. if (question == word && src == image) matches.push(definition);
  774. }
  775.  
  776. // Test for defintion with text and image
  777. if (matches.length == 0) {
  778. for (let i = 0; i < terms.length; ++i) {
  779. let word = terms[i].word,
  780. definition = terms[i].definition,
  781. image = terms[i].photo || terms[i]._imageUrl;
  782.  
  783. if (question == definition && src == image) matches.push(word);
  784. }
  785. }
  786.  
  787. // Test for only matching word
  788. if (matches.length == 0) {
  789. for (let i = 0; i < terms.length; ++i) {
  790. let word = terms[i].word,
  791. definition = terms[i].definition;
  792.  
  793. if (question == word) matches.push(definition);
  794. }
  795. }
  796.  
  797. // Test for only matching definition
  798. if (matches.length == 0) {
  799. for (let i = 0; i < terms.length; ++i) {
  800. let word = terms[i].word,
  801. definition = terms[i].definition;
  802.  
  803. if (question == definition) matches.push(word);
  804. }
  805. }
  806.  
  807. return matches;
  808. }
  809. }
  810.  
  811. function Learn() {
  812. this.interval = 100;
  813. this.running = true;
  814.  
  815. this.interval = setInterval(() => {
  816. if (this.running) this.loop();
  817. }, this.interval);
  818. }
  819.  
  820. Learn.prototype.pause = function () {
  821. this.running = false;
  822. }
  823.  
  824. Learn.prototype.start = function () {
  825. this.running = true;
  826. }
  827.  
  828. Learn.prototype.loop = function () {
  829. if (this.mode() == 'choice') this.solve();
  830. else if (this.mode() == 'written' || this.mode() == 'flashcards') {
  831. let btns = document.getElementsByClassName('UIButton');
  832.  
  833. for (let i = 0; i < btns.length; ++i)
  834. if (btns[i].innerText.trim() == 'Options') btns[i].click();
  835.  
  836. alert('Please make sure \'Question Type\' is set to choice only.');
  837. this.running = false;
  838. }
  839. else if (this.mode() == 'other') this.next();
  840. }
  841.  
  842. Learn.prototype.solve = function () {
  843. let elements = this.questions(),
  844. answers = this.answers();
  845.  
  846. loop:
  847. for (let i = 0; i < elements.length; ++i) {
  848. for (let j = 0; j < answers.length; ++j) {
  849. if (elements[i].innerText.substr(2) == answers[j]) {
  850. elements[i].click();
  851. break loop;
  852. }
  853. }
  854. }
  855. }
  856.  
  857. Learn.prototype.answers = function () {
  858. if (this.questions().length == 0) return [];
  859.  
  860. return Answers.exact(this.text().innerText, this.image().src);
  861. }
  862.  
  863. Learn.prototype.next = () => {
  864. let btns = document.getElementsByClassName('UIButton');
  865.  
  866. for (let i = 0; i < btns.length; ++i) {
  867. if (btns[i].innerText.trim() == 'Press any key to continue') btns[i].click();
  868. }
  869. }
  870.  
  871. Learn.prototype.questions = () => {
  872. let assistant = document.getElementsByClassName('AssistantMultipleChoiceQuestionPromptView-termOption'),
  873. learn = document.getElementsByClassName('LearnMultipleChoiceQuestionPrompt-termOption'),
  874. mc = document.getElementsByClassName('MultipleChoiceQuestionPrompt-termOption');
  875.  
  876. return [...assistant, ...learn, ...mc];
  877. }
  878.  
  879. Learn.prototype.parent = () => {
  880. let assistant = document.getElementsByClassName('AssistantMultipleChoiceQuestionPromptView-promptArea'),
  881. learn = document.getElementsByClassName('LearnMultipleChoiceQuestionPrompt-promptArea'),
  882. mc = document.getElementsByClassName('MultipleChoiceQuestionPrompt-promptArea');
  883.  
  884. return [...assistant, ...learn, ...mc][0];
  885. }
  886.  
  887. Learn.prototype.image = function () {
  888. if (this.questions().length == 0) return false;
  889.  
  890. let container = this.parent().getElementsByClassName('FormattedTextWithImage-image')[0];
  891. if (!container) return document.createElement('img');
  892.  
  893. return container.getElementsByClassName('Image-image')[0];
  894. }
  895.  
  896. Learn.prototype.text = function () {
  897. if (this.questions().length == 0) return false;
  898.  
  899. let container = this.parent().getElementsByClassName('PromptTextWithImage')[0],
  900. parent = container.getElementsByClassName('FormattedText')[0];
  901.  
  902. if (!parent) return document.createElement('div');
  903.  
  904. return parent.children[0];
  905. }
  906.  
  907. Learn.prototype.mode = () => {
  908. if (document.getElementsByClassName('AssistantMultipleChoiceQuestionPromptView-termOption').length > 0 || document.getElementsByClassName('LearnMultipleChoiceQuestionPrompt-termOption').length > 0 || document.getElementsByClassName('MultipleChoiceQuestionPrompt-termOptions').length > 0) return 'choice';
  909. if (document.getElementsByClassName('AutoExpandTextarea-textarea').length > 0) return 'written';
  910. if (document.getElementsByClassName('FlippableFlashcard').length > 0) return 'flashcards';
  911.  
  912. return 'other';
  913. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement