GauthMath Bypass Paywall newer version

Bypass the paywall and hopefully jailbreak the site

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/488027/1331884/GauthMath%20Bypass%20Paywall%20newer%20version.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         GauthMath Bypass Paywall newer version
// @namespace    http://tampermonkey.net/
// @version      2.5
// @license      MIT
// @description  Bypass the paywall and hopefully jailbreak the site
// @author       Viruszy
// @match        https://www.gauthmath.com/
// @match        https://www.gauthmath.com/calculator
// @match        https://www.gauthmath.com/search-question?questionID=1791612050420741&action=image_search
// @match        https://www.gauthmath.com/solution/1782791331021829/
// @match        https://www.gauthmath.com/solution/1782791331021829/
// @match        https://www.gauthmath.com/solution/1782635516057605/
// @icon         a photo of gauthmath symbol
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    const elementsToRemove = [
        "[data-testid^='ad_below_']" //Annoying video ads
    ];
    //simulating button click to keep native Gauth Math functionality without needing additional code.
    const elementsToClick = [
        "[data-testid='registration_toplayer_close_button']", //Login popup/modal close button
        '[aria-label="Close this dialog window"]' //Promotion popup/modal close button
    ];
    const config = { attributes: true, childList: true, subtree: true };
    let timeoutID = 0;
    let mutationObserver;
    const mutationCallback = () => {
        mutationObserver.disconnect();
        for (let query of elementsToRemove) {
            let nodes = document.querySelectorAll(query);
            for (let node of nodes)
                node.remove();
        }
        for (let query of elementsToClick) {
            let nodes = document.querySelectorAll(query);
            for (let node of nodes)
                if (timeoutID === 0)
                    timeoutID = setTimeout(() => { timeoutID = 0; node.click(); }, 500);
        }
        mutationObserver.observe(document.body, config);
    }
    try {
        localStorage.clear();
    } catch (err) {
        console.error("Couldn't clear local storage, the browser is most likely blocking access to it. (are all cookies being blocked?)");
        console.error(err);
    }
    document.addEventListener("DOMContentLoaded", () => {
        mutationObserver = new MutationObserver(mutationCallback);
        mutationCallback();
        // Remove paywall elements
    function bypassPaywall() {
        const paywallElement = document.getElementById('paywall'); // Adjust the ID based on the actual paywall element
        if (paywallElement) {
            paywallElement.remove();
        }
    }
         // Enable Gauthplus features
    function enableGauthplus() {
        // Simulate successful Gauthplus subscription
        localStorage.setItem('isGauthplus', 'true');
    }

    // Check if user has Gauthplus subscription
    function hasGauthplus() {
        return localStorage.getItem('isGauthplus') === 'true';
    }

    // Main function
    function main() {
        bypassPaywall();
        if (!hasGauthplus()) {
            enableGauthplus();
        }
    }
    });
})();