Quizlet Question Bypass

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

当前为 2022-12-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Quizlet Question Bypass
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.30
  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.  
  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.  
  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. $(selectElementContainer).eq(0).children().removeAttr('hidden') // show hidden divs (again best when not logged in)
  42. });
  43. }
  44.  
  45.  
  46. // Actually unblur KATEX
  47. selectEachElement.each(function (index, element){
  48. $(selectEachElement).eq(index).children().eq(1).children().first().children().first().removeAttr('style').css("filter","blur(0)")
  49.  
  50. });
  51.  
  52. var data2 = [];
  53. for(let i = 0; i < data.length; i++){
  54. data[i] = data[i].substring(0, data[i].indexOf("\""))
  55. if (dataIncludes("lateximg.png", i) || dataIncludes("assets", i) || dataIncludes("textbook_covers", i) || dataIncludes("cache", i)){
  56. data.splice(i, 1)
  57. i--
  58. }
  59. else if (dataIncludes("textbook-solutions", i)){
  60. data2.push(data[i])
  61. }
  62. }
  63.  
  64.  
  65. var buttonCont = document.createElement("div");
  66. buttonCont.setAttribute('id', 'buttonContainer');
  67. buttonCont.style.backgroundColor = "white";
  68. document.body.appendChild(buttonCont);
  69.  
  70. var buttonContainer = document.getElementById('buttonContainer');
  71. var buttonFrag = document.createDocumentFragment();
  72.  
  73. // skip question buttons if logged in (WIP)
  74. data2.forEach(function(url, index, originalArray) {
  75. var btn = document.createElement('button');
  76. btn.style.textAlign = 'center';
  77. btn.style.transitionDuration = '0.4s'; // if i decide to add a hover event (unfortunately requires a css file)
  78. btn.style.display = 'inline-block';
  79. btn.style.margin= '6px 8px';
  80. switch (true){
  81. case (index == 0):
  82. btn.innerText = "Next Problem";
  83. break;
  84. case (index == 1):
  85. btn.innerText = "Skip 2 Problems";
  86. break;
  87. case (index == 2):
  88. btn.innerText = "Previous Problem";
  89. break;
  90. case (index == originalArray.length - 1):
  91. btn.innerText = "Back to Textbook";
  92. break;
  93. default:
  94. return;
  95. }
  96. btn.style.padding = '20px 40px';
  97. btn.style.background = 'white'; // setting the background color to white
  98. btn.style.color = 'black'; // setting the color to black
  99. btn.style.border = '2px solid #f44336'
  100. btn.style.fontSize = '20px'; // setting the font size to 20px
  101. btn.onclick = function() {
  102. location.href = url;
  103. }
  104. buttonContainer.appendChild(btn);
  105. });
  106. buttonContainer.appendChild(buttonFrag);
  107. document.getElementById("buttonContainer").style.display = "flex";
  108. document.getElementById("buttonContainer").style.alignItems = "center";
  109. document.getElementById("buttonContainer").style.justifyContent = "center";
  110.  
  111. // remove popup
  112. var paywallremover = [ document.getElementsByClassName("hideBelow--s"), document.getElementsByClassName("hideBelow--s"), document.getElementsByClassName("hideBelow--m")]
  113. try{
  114. paywallremover.forEach(element => element[0].remove())
  115. }
  116. catch (err){
  117. console.log(err)
  118. }
  119.  
  120. // add new container for images
  121. var imgCont = document.createElement("div");
  122. imgCont.setAttribute('id', 'imageContainer')
  123. imgCont.style.backgroundColor = "white";
  124. document.body.appendChild(imgCont);
  125.  
  126. var container = document.getElementById('imageContainer');
  127. var docFrag = document.createDocumentFragment();
  128.  
  129. data.forEach(function(url, index, originalArray) {
  130. var img = document.createElement('img');
  131. img.src = url;
  132. docFrag.appendChild(img);
  133. });
  134. container.appendChild(docFrag);
  135.  
  136.  
  137. // to work in tandem with quizlet bypass
  138. let div = document.createElement('div');
  139. div.classList.add('hideBelow--s');
  140. document.body.appendChild(div)
  141. let div2 = document.createElement('div');
  142. div2.classList.add('hideAbove--s');
  143. document.body.appendChild(div2)
  144. }, false);