Advertisement
Guest User

Symolab Pro

a guest
Apr 21st, 2022
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Symbolab Pro
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.4.5
  5. // @description Symbolab pro for free
  6. // @author J. Lawrence Dev Pro Tips
  7. // @match https://www.symbolab.com/
  8. // @include *://*symbolab.com/*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15.  
  16. const VERSION = "1.4.5";
  17.  
  18. console.log(`"Symbolab Pro" v${VERSION} loaded.`);
  19.  
  20. // hide steps until full solution is loaded
  21. document.head.insertAdjacentHTML("beforeend", `<style id='hide_solution'>.solution_div { display: none; }</style>`);
  22.  
  23. window.addEventListener("load", function () {
  24. // prevent paywall from appearing when verify button is clicked
  25. createUpgradeTooltip = () => null;
  26.  
  27. // only run script if on a page with a solution
  28. if (typeof SYMBOLAB !== "undefined" && SYMBOLAB?.params?.query) {
  29. // initialize constants
  30. const url = location.href;
  31. const langMatch = url.match("//([a-z]{2}).symbolab");
  32. const lang = langMatch ? langMatch[1] : "en";
  33. const query = htmlDecode(SYMBOLAB.params.query);
  34.  
  35. // reinitialize SymbolabSteps with subscribed set to true
  36. SYSTEPS = new SymbolabSteps(lang, "true", null, url);
  37.  
  38. // reinitialize Solutions with subscribed set to true
  39. SOLUTIONS = new Solutions("", "step-by-step", query, "", 0, "", lang, "true");
  40. SOLUTIONS.init();
  41.  
  42. console.log(`"Symbolab Pro" full step-by-step solutions initialized.`);
  43. }
  44.  
  45. // if not signed in, create a warning next to the sign in link to tell the user they must log in
  46. if (!isUserLoggedIn()) {
  47. console.warn(`"Symbolab Pro" only works when signed in. You can create an account for free.`);
  48. const joinEl = document.getElementById("join");
  49. const warning = document.createElement("div");
  50. warning.id = "sign_in_warning";
  51. const warningStyles = {
  52. position: "fixed",
  53. top: "48px",
  54. right: "0px",
  55. width: "260px",
  56. height: "200px",
  57. backgroundColor: "rgb(255, 255, 255)",
  58. zIndex: "9999",
  59. padding: "1em",
  60. fontSize: "150%",
  61. lineHeight: "1.5em",
  62. border: "2px solid red",
  63. };
  64. Object.assign(warning.style, warningStyles);
  65. warning.innerHTML = `<p>Viewing step-by-step solutions for free is only possible when logged in.</p>
  66. <p style="font-size: 90%">Sign in or create a free account to continue.</p>
  67. <a href="https://greasyfork.org/en/scripts/407459-symbolab-pro" onclick="return false;" style="font-size: 75%">'Symbolab Pro' script v${VERSION}</a>`;
  68. // close button
  69. const closeButton = document.createElement("button");
  70. closeButton.innerHTML = "&times;";
  71. const closeStyles = {
  72. position: "absolute",
  73. top: "0px",
  74. right: "0px",
  75. fontSize: "150%",
  76. fontWeight: "bold",
  77. cursor: "pointer",
  78. background: "none",
  79. border: "none",
  80. };
  81. Object.assign(closeButton.style, closeStyles);
  82. closeButton.addEventListener("click", () => {
  83. warning.style.display = "none";
  84. });
  85. warning.appendChild(closeButton);
  86. if (joinEl) {
  87. joinEl.appendChild(warning);
  88. }
  89. // flash warning when show steps button is clicked since the content is locked
  90. document.body.addEventListener(
  91. "click",
  92. (e) =>
  93. $(e.target).closest(".solution_title_container")[0] &&
  94. $("#sign_in_warning").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100)
  95. );
  96. }
  97.  
  98. // show solution
  99. document.getElementById("hide_solution").remove();
  100. });
  101. })();
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement