Quizlet Question Bypass

Gives you the images of the solutions on the bottom. Works best with auto-login quizlet.

当前为 2022-11-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Quizlet Question Bypass
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.28
  5. // @description Gives you the images of the solutions on the bottom. Works best with auto-login quizlet.
  6. // @author DevT02
  7. // @license MIT
  8. // @match http*://www.quizlet.com/explanations/questions/*
  9. // @match http*://quizlet.com/explanations/questions/*
  10. // @match http*://www.quizlet.com/explanations/textbook-solutions/*
  11. // @match http*://quizlet.com/explanations/textbook-solutions/*
  12. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  13. // @require https://code.jquery.com/jquery-3.6.0.min.js
  14. // @grant none
  15. // ==/UserScript==
  16. /* globals jQuery, $, waitForKeyElements */
  17.  
  18. window.addEventListener('load', function() {
  19. 'use strict';
  20. var LOGGED_IN = true;
  21.  
  22.  
  23. var paywall = document.getElementById('__NEXT_DATA__'); // get paywall
  24. var data = paywall.outerHTML == null ? location.reload() : paywall.outerHTML; // outer json html (RELOAD IF NO HTML IS AVAILABLE, THIS IS FOR FIREFOX)
  25. console.log('Pre-checks completed! QuizletQuestionBypass by DevT02')
  26. console.log('Check out my other projects at https://github.com/DevT02/') // START PROGRAM
  27. var currentUrl = window.location.href;
  28. // split urls into an array named "data"
  29. data = data.split("https://").map(val => { return "https://"+val }).slice(1);
  30. function dataIncludes(a1, i){
  31. return data[i].includes(a1)
  32. }
  33. console.log(data)
  34. var selectEachElement = $("div[class^='ExplanationsSolutionCard'],div[class*=' ExplanationsSolutionCard']") // LUL selector
  35.  
  36. if (!LOGGED_IN){
  37. var selectElementContainer = $("div[class^='ExplanationSolutionsContainer'],div[class*=' ExplanationSolutionsContainer']")
  38. $(selectElementContainer).eq(0).removeAttr('style').css("max-height","10000rem") // best for when not logged in
  39.  
  40. selectElementContainer.each(function (index, element){
  41. console.log($(selectElementContainer).eq(0).children().removeAttr('hidden')) // show hidden divs (again best when not logged in)
  42.  
  43. });
  44. }
  45.  
  46. // var selectEachNextPage = $("div[class^='NavigationLink'],div[class*=' NavigationLink']")
  47. // var href;
  48. // selectEachNextPage.each(function (index, element){
  49. // console.log($(selectEachElement).eq(0));
  50. // console.log($(this).val($().attr("baseURI")));
  51. // });
  52.  
  53.  
  54. // Actually unblur KATEX
  55. selectEachElement.each(function (index, element){
  56. $(selectEachElement).eq(index).children().eq(1).children().first().children().first().removeAttr('style').css("filter","blur(0)")
  57.  
  58. });
  59.  
  60. var data2 = [];
  61. for(let i = 0; i < data.length; i++){
  62. data[i] = data[i].substring(0, data[i].indexOf("\""))
  63. if (dataIncludes("lateximg.png", i) || dataIncludes("assets", i) || dataIncludes("textbook_covers", i) || dataIncludes("cache", i)){
  64. data.splice(i, 1)
  65. i--
  66. }
  67. else if (dataIncludes("textbook-solutions", i)){
  68. data2.push(data[i])
  69. }
  70. }
  71. for (let i = 0; i < 3; i++){
  72. console.log(data2[i]);
  73. // 0 = next question, 1 = 2nd next question, 2 = previous!
  74. }
  75.  
  76. var buttonCont = document.createElement("div");
  77. buttonCont.setAttribute('id', 'buttonContainer');
  78. buttonCont.style.backgroundColor = "white";
  79. document.body.appendChild(buttonCont);
  80.  
  81. var buttonContainer = document.getElementById('buttonContainer');
  82. var buttonFrag = document.createDocumentFragment();
  83.  
  84. // skip question buttons if logged in (WIP)
  85. data2.forEach(function(url, index, originalArray) {
  86. console.log(originalArray.length)
  87. console.log(index)
  88. var btn = document.createElement('button');
  89. btn.style.textAlign = 'center';
  90. btn.style.transitionDuration = '0.4s'; // if i decide to add a hover event (unfortunately requires a css file)
  91. btn.style.display = 'inline-block';
  92. btn.style.margin= '6px 8px';
  93. switch (true){
  94. case (index == 0):
  95. btn.innerText = "Next Problem";
  96. break;
  97. case (index == 1):
  98. btn.innerText = "Skip 2 Problems";
  99. break;
  100. case (index == 2):
  101. btn.innerText = "Previous Problem";
  102. break;
  103. case (index == originalArray.length - 1):
  104. btn.innerText = "Back to Textbook";
  105. break;
  106. default:
  107. return;
  108. }
  109. btn.style.padding = '20px 40px';
  110. btn.style.background = 'white'; // setting the background color to white
  111. btn.style.color = 'black'; // setting the color to black
  112. btn.style.border = '2px solid #f44336'
  113. btn.style.fontSize = '20px'; // setting the font size to 20px
  114. btn.onclick = function() {
  115. location.href = url;
  116. }
  117. buttonContainer.appendChild(btn);
  118. });
  119. buttonContainer.appendChild(buttonFrag);
  120. document.getElementById("buttonContainer").style.display = "flex";
  121. document.getElementById("buttonContainer").style.alignItems = "center";
  122. document.getElementById("buttonContainer").style.justifyContent = "center";
  123.  
  124.  
  125. console.log(data)
  126.  
  127. // remove popup
  128. var paywallremover = document.getElementsByClassName("hideBelow--s")
  129. var paywallremover2 = document.getElementsByClassName("hideAbove--s")
  130.  
  131. try{
  132. paywallremover[0].remove()
  133. paywallremover2[0].remove()
  134. }
  135. catch (err){
  136. console.log(err)
  137. }
  138.  
  139. // add new container for images
  140. var imgCont = document.createElement("div");
  141. imgCont.setAttribute('id', 'imageContainer')
  142. imgCont.style.backgroundColor = "white";
  143. document.body.appendChild(imgCont);
  144.  
  145. var container = document.getElementById('imageContainer');
  146. var docFrag = document.createDocumentFragment();
  147.  
  148. data.forEach(function(url, index, originalArray) {
  149. var img = document.createElement('img');
  150. img.src = url;
  151. docFrag.appendChild(img);
  152. });
  153. container.appendChild(docFrag);
  154.  
  155.  
  156. // to work in tandem with quizlet bypass
  157. let div = document.createElement('div');
  158. div.classList.add('hideBelow--s');
  159. document.body.appendChild(div)
  160. let div2 = document.createElement('div');
  161. div2.classList.add('hideAbove--s');
  162. document.body.appendChild(div2)
  163. }, false);