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