PlugShareAnonymous

Allows using PlugShare without an account.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         PlugShareAnonymous
// @namespace    https://greasyfork.org/en/users/1365511-robosphinx
// @version      2025.01.21.001
// @description  Allows using PlugShare without an account.
// @author       robosphinx_, callumhume
// @match        *://*.plugshare.com/*
// @grant        none
// @license      GPLv3
// ==/UserScript==

(function main() {
    'use strict';

    const SCRIPT_LONG_NAME = GM_info.script.name;
    const SCRIPT_SHORT_NAME = "PSA";
    const SCRIPT_VERSION = GM_info.script.version;

    const LOGIN_DIALOG_CLASS = '.md-dialog-container';
    const ANTI_CLICK_BACKGROUND_1_ID = '#toast-container';
    const ANTI_CLICK_BACKGROUND_2_ID = '.md-dialog-backdrop';
    const LOAD_MAP_BUTTON = '.load';

    let successfulStartup = false;

    function log(tag, message) {
        if (tag == "ERROR") {
            console.error(SCRIPT_SHORT_NAME + ": " + tag + ": " + message);
        }
        else {
            console.log(SCRIPT_SHORT_NAME + ": " + tag + ": " + message);
        }
    }

    function removeLoginWindow() {
        // Heirarchy follows
        // ID layer-switcher-region
        // class layer-switcher
        // class menu
        // class scrollable
        // class list-unstyled togglers
        // class group
        // class md-dialog-container ng-scope
        try {
            log("INFO", "Looking for div ids to nuke...");
            let loginDialog = document.querySelector(LOGIN_DIALOG_CLASS); // Grab element by class name
            if (loginDialog != null) {
                log("INFO", "Found login dialog: " + loginDialog);
                loginDialog.remove();
                let toastContainer = document.querySelector(ANTI_CLICK_BACKGROUND_1_ID); // Grab element by ID
                if (toastContainer != null) {
                    log("INFO", "Found toast container: " + toastContainer);
                    toastContainer.remove();
                    let dialogBackdrop = document.querySelector(ANTI_CLICK_BACKGROUND_2_ID); // Grab element by class
                    if (dialogBackdrop != null) {
                        log("INFO", "Found dialog backdrop: " + dialogBackdrop);
                        dialogBackdrop.remove();
                        let loadMapButton = document.querySelector(LOAD_MAP_BUTTON); // Grab element by class
                        if (loadMapButton != null) {
                            log("INFO", "Found map load button: " + loadMapButton);
                            loadMapButton.click();
                            successfulStartup = true;
                        }
                        else {
                            log("ERROR", "Could not find element with class " + LOAD_MAP_BUTTON);
                            successfulStartup = false;
                        }
                    }
                    else {
                        log("ERROR", "Could not find element with class " + ANTI_CLICK_BACKGROUND_2_ID);
                        successfulStartup = false;
                    }
                }
                else {
                    log("ERROR", "Could not find element with class " + ANTI_CLICK_BACKGROUND_1_ID);
                    successfulStartup = false;
                }
            }
            else {
                log("ERROR", "Could not find element with class " + LOGIN_DIALOG_CLASS);
                successfulStartup = false;
            }
        }
        catch (err) {
            log("ERROR", "Looking for div ids to nuke returned error " + err);
            successfulStartup = false;
        }
    };

    function init() {
        log("INFO", SCRIPT_LONG_NAME + " " + SCRIPT_VERSION + " started");
        removeLoginWindow();
        if (successfulStartup) {
            log("INFO", SCRIPT_LONG_NAME + " initialized!");
        }
        else {
            log("ERROR", SCRIPT_LONG_NAME + " could not initialize.");
        }
    }

    function bootstrap() {
        let loginDialog = document.querySelector(LOGIN_DIALOG_CLASS); // Grab element by class name
        if (loginDialog != null) {
            init();
        } else {
            setTimeout(bootstrap, 100);
        }
    }

    bootstrap();
})();