proxmox Autologin

Edit the Password Variable and @match Value to match the password and URL of your Proxmox GUI. This script will skip the subscription dialogs in proxmox and log you into the Webfrontend automatically.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name proxmox Autologin
// @description Edit the Password Variable and @match Value to match the password and URL of your Proxmox GUI. This script will skip the subscription dialogs in proxmox and log you into the Webfrontend automatically.
// @match https://pve.domain:8006/*
// @version 0.0.1.20210507103421
// @namespace https://greasyfork.org/users/165409
// ==/UserScript==

var Password = "*****";
var LoginDialogText = "Proxmox VE Login";
var LoginButtonText = "Login";
var SubscriptionDialogText = "No valid subscription";
var SubscriptionButtonText = "OK";

function findElementbyText(Elements, Text) {
    for (let Element of Elements) {
        if (Element.textContent == Text && window.getComputedStyle(Element).visibility != "hidden") {
            return Element;
        }
    }
}

function findElementbyTextoverParent(ParentElements, Text) {
    for (let Element of ParentElements) {
        var ElementStyle = window.getComputedStyle(Element);
        if (ElementStyle.display !== 'none') {
            var ElementChildren = Element.querySelectorAll("span");
            for (let ElementChild of ElementChildren) {
                if (ElementChild.textContent == Text) {
                    return Element;
                }
            }
        }
    }
}

setInterval(function() {
    var divTags = document.getElementsByTagName("div");
    var LoginDialog = findElementbyText(divTags, LoginDialogText);
    var SubscriptionDialog = findElementbyText(divTags, SubscriptionDialogText);

    if (LoginDialog != null) {
        document.querySelectorAll('[type="password"]')[0].value = Password;
        var LoginButton = findElementbyTextoverParent(LoginDialog.parentElement.getElementsByTagName("a"), LoginButtonText);
        if (LoginButton != null) {
            LoginButton.click();
        } else {
            findElementbyTextoverParent(LoginDialog.parentElement.parentElement.parentElement.parentElement.nextElementSibling.getElementsByTagName("a"), LoginButtonText).click();
        }
    }

    if (SubscriptionDialog != null) {
        var SubscriptionButton = findElementbyTextoverParent(SubscriptionDialog.parentElement.getElementsByTagName("a"), SubscriptionButtonText)
        if (SubscriptionButton != null) {
            SubscriptionButton.click();
        } else {
            findElementbyTextoverParent(SubscriptionDialog.parentElement.parentElement.parentElement.parentElement.nextElementSibling.getElementsByTagName("a"), SubscriptionButtonText).click();
        }
    }
}, 1000);