Show Web App Version

show app version and building timestamp!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Show Web App Version
// @namespace    https://crossjs.com/
// @version      0.4
// @description  show app version and building timestamp!
// @author       crossjs
// @match        *://*.arnoo.com/*
// @grant        unsafeWindow
// @grant        GM_registerMenuCommand
// ==/UserScript==

(function() {
    'use strict';

    const chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
    const radix = chars.length;

    function decode(str) {
        const len = str.length;
        let num = 0;
        for (let i = 0; i < len; i++) {
            num += chars.indexOf(str.charAt(len - i - 1)) * Math.pow(radix, i);
        }
        return num;
    }

    const prefix = "VERSION: ";

    const showVersion = () => {
        const element = document.querySelector("[data-role=__VERSION_AND_TIMESTAMP__]");
        if (element) {
            const value = element.textContent;
            if (value.indexOf(prefix) === 0) {
                const [_, v, d] = value.match(/^VERSION: (\d+\.\d+\.\d+(?:-(?:alpha|beta)\.\d+)?)\.(.+)$/)
                alert(`Version: ${v}\nTS: ${new Date(decode(d))}`);
                return;
            }
        }
        setTimeout(showVersion, 1000)
    };

    GM_registerMenuCommand('Show Web App Version', showVersion);
})();