Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Symbolab Pro [Fixed]
- // @namespace http://tampermonkey.net/
- // @version 2.1
- // @description A script to allow students to learn mathematics without being restricted by a paywall
- // @author ShortHax,Azrak
- // @match https://www.symbolab.com/
- // @include *://*symbolab.com/*
- // @grant none
- // @license MIT
- // ==/UserScript==
- (function () {
- "use strict";
- var code = `window.onload = function(){
- const signedIn = !!document.getElementById("userName").title.trim();
- if (signedIn) {
- // initialize constants
- const url = location.href;
- const langMatch = url.match('//([a-z]{2})\.symbolab');
- const lang = langMatch ? langMatch[1] : 'en';
- // reinitialize SymbolabSteps with subscribed set to true
- SYSTEPS = new SymbolabSteps('en', 'true', null, url);
- // reinitialize Solutions with subscribed set to true
- SOLUTIONS = new Solutions("", "step-by-step", htmlDecode(SYMBOLAB.params.query),htmlDecode(''), '0', '', lang, 'true');
- SOLUTIONS.init();
- // prevent paywall from appearing when verify solution is clicked
- $("#click-capture").addClass("click-capture-subscribed");
- }
- // warn user if not logged in
- else {
- // create a tooltip popup next to the sign in link to tell the user they must log in
- const joinEl = document.getElementById("join");
- const warning = document.createElement("div");
- const styles = {
- position: "absolute",
- top: "49px",
- right: "0px",
- width: "260px",
- height: "185px",
- backgroundColor: "rgb(255 255 255)",
- zIndex: "9999",
- padding: "1em",
- fontSize: "150%",
- lineHeight: "1.5em",
- border: "2px solid red",
- };
- Object.assign(warning.style, styles);
- warning.innerHTML =
- "<h4>Viewing step-by-step solutions is only possible when logged in.</h4>" +
- "</h4><p>Sign in or create a free account to continue.</p>";
- // close button
- const closeButton = document.createElement("button");
- closeButton.innerHTML = "×";
- const closeStyles = {
- position: "absolute",
- top: "0px",
- right: "0px",
- fontSize: "150%",
- fontWeight: "bold",
- cursor: "pointer",
- background: "none",
- border: "none",
- };
- Object.assign(closeButton.style, closeStyles);
- closeButton.addEventListener("click", () => {
- warning.style.display = "none";
- });
- warning.appendChild(closeButton);
- joinEl.appendChild(warning);
- }
- }`;
- // make sure the code runs before the subscription status is checked
- document.documentElement.setAttribute("onreset", code);
- document.documentElement.dispatchEvent(new CustomEvent("reset"));
- document.documentElement.removeAttribute("onreset");
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement