Unlock locked steps in Symbolab (DEC 2021 FIXED)

unlocks locked symbolab step-by-step instructions by overwriting XMLHttpRequest

当前为 2021-12-17 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Unlock locked steps in Symbolab (DEC 2021 FIXED)
// @namespace    http://*.symbolab.com/*
// @version      2.1
// @description  unlocks locked symbolab step-by-step instructions by overwriting XMLHttpRequest
// @author       joseph
// @match        *://*.symbolab.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function(open) {
    const version = "2.1";

    let srcset = `
    console.log("Symbolab Unlock 2.0 is running.")

var PATCHED     = 0;
var SIGNED_IN   = document.body.classList.contains('signedin');
var ALERT_SHOWN = false;

let NOT_SIGNED_IN_MESSAGE = "[Symbolab Unlock] ALERT! It looks like you are not logged into any Symbolab account. Note that Symbolab has recently changed their backend and steps are only sent if you are logged in. The script will not work until you create a free Symbolab account and sign in to it. If you are signed in, ignore this message.";

// Symbolab internal constants
let INTERNAL_SOLUTIONS_OBJ_PTR = "SOLUTIONS";
let INTERNAL_SOLUTIONS_PROTO_PTR = "Solutions";
let INTERNAL_STEPS_OBJ_PTR = "SYSTEPS";
let INTERNAL_STEPS_PROTO_PTR = "SymbolabSteps";

if (SIGNED_IN && window["SYMBOLAB"]["params"]["query"] !== null) {
    let INTERNAL_SOLUTIONS_PROTO_DEFAULT_ARGS = [
        window[INTERNAL_SOLUTIONS_OBJ_PTR].subject,
        window[INTERNAL_SOLUTIONS_OBJ_PTR].page,
        window[INTERNAL_SOLUTIONS_OBJ_PTR].query,
        window[INTERNAL_SOLUTIONS_OBJ_PTR].input,
        window[INTERNAL_SOLUTIONS_OBJ_PTR].input_back,
        window[INTERNAL_SOLUTIONS_OBJ_PTR].appLangs,
        window[INTERNAL_SOLUTIONS_OBJ_PTR].curLang,
        "true"
    ];

    let INTERNAL_STEPS_PROTO_DEFAULT_ARGS = [
        window[INTERNAL_STEPS_OBJ_PTR].requestLang,
        "true",
        false,
        window[INTERNAL_STEPS_OBJ_PTR].referer
    ];

    window[INTERNAL_STEPS_OBJ_PTR] = new window[INTERNAL_STEPS_PROTO_PTR](...INTERNAL_STEPS_PROTO_DEFAULT_ARGS);
    window[INTERNAL_SOLUTIONS_OBJ_PTR] = new window[INTERNAL_SOLUTIONS_PROTO_PTR](...INTERNAL_SOLUTIONS_PROTO_DEFAULT_ARGS);
    window[INTERNAL_SOLUTIONS_OBJ_PTR].init();

    // Thanks to ShortHax for the following--looks like SB even allows us to
    // check solutions on the backend!
    document.getElementById("click-capture").classList.add("click-capture-subscribed");
} else {
    // Determine where we should place the alert
    referenceNode = document.getElementById("nl-mainNav");

    // Create warning div
    warningDiv = document.createElement("div");
    warningDiv.style.border = "2px dashed #f00";
    warningDiv.style.width = "60%";
    warningDiv.style.margin = "9px auto";
    warningDiv.id = "warning_text_symbolab_unlock";
    warningDiv.style.padding = "5px 5px 5px 5px";

    // Create warning text
    warningTxt = document.createElement("b");
    warningTxt.appendChild(document.createTextNode(NOT_SIGNED_IN_MESSAGE))
    warningTxt.style.color = "red";

    // Append text to div
    warningDiv.appendChild(warningTxt);

    // Append div to page
    referenceNode.parentNode.insertBefore(warningDiv, referenceNode.nextSibling);
}
    `

    // Credits to ShortHax for the following method which forces the script to
    // execute at first priority.
    document.documentElement.setAttribute("onreset", srcset);
    document.documentElement.dispatchEvent(new CustomEvent("reset"));
    document.documentElement.removeAttribute("onreset");

    // v2.0 onboarding
    if (!localStorage.getItem("SyUnlock_v2_Onboarding"))
    {
        localStorage.setItem("SyUnlock_v2_Onboarding", true);
        alert(`Symbolab Unlock has been updated to version 2.0! Most importantly, the script has been rewritten with new methodology. Patching works again. You can now also check your answers. Many thanks to ShortHax on Greasyfork for discovering much of the new methodology. Enjoy!`)
    }

})(XMLHttpRequest.prototype.open);