Greasy Fork

Symbolab Pro

Symbolab pro for free

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

// ==UserScript==
// @name         Symbolab Pro
// @namespace    http://tampermonkey.net/
// @version      1.4.1
// @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";

    // check if the user is signed in
    const signedIn = !!document.getElementById("userName").title.trim();

    // the script only works if the user is signed in to a Symbolab account
    if (signedIn) {
        // initialize constants
        const url = location.href;
        const langMatch = url.match("//([a-z]{2}).symbolab");
        const lang = langMatch ? langMatch[1] : "en";
        const query = htmlDecode(SYMBOLAB.params.query);

        // 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", query, "", 0, "", lang, "true");
        SOLUTIONS.init();

        // prevent paywall from appearing when verify button is clicked
        createUpgradeTooltip = () => {};
    }

    // create a warning next to the sign in link to tell the user they must log in
    else {
        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);
    }
})();