Greasy Fork

Symbolab Pro

Symbolab pro for free

目前为 2021-12-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         Symbolab Pro
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  Symbolab pro for free
// @author       J. Lawrence Dev Pro Tips
// @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(lang, '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 = "&times;";
            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");
})();