GetUndeployedMunzeeURLs

Get Urls for The Munzee Skin Machine

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         GetUndeployedMunzeeURLs
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Get Urls for The Munzee Skin Machine
// @author       CzPeet
// @match        https://www.munzee.com/print
// @icon         https://www.google.com/s2/favicons?domain=munzee.com
// @update       https://greasyfork.org/en/scripts/434808-getundeployedmunzeeurls
// @grant        none
// ==/UserScript==

async function PrintYourMunzees()
{
    if (document.body.innerText.includes("Print Your Munzees"))
    {
        var mainForm = document.getElementsByClassName("form")[0];

        var URLDIV = document.createElement('DIV');
        URLDIV.setAttribute('style', 'margin-top: 20px');

        var URLsTextArea = document.createElement('TEXTAREA');
        URLsTextArea.setAttribute('id','urlArea');
        URLsTextArea.setAttribute('style','width: 100%;height: 350px;');

        URLDIV.appendChild(URLsTextArea);
        mainForm.appendChild(URLDIV);

        //EventListeners
        var check_batch = findButtonByText("Check");
        check_batch.addEventListener('click', chBoxCheckedChange);

        var check_all = findButtonByText("Check All");
        check_all.addEventListener('click', chBoxCheckedChange);

        var inputs = document.querySelectorAll('input[type="checkbox"]');
        for(var i = 0; i < inputs.length; i++) {
            if (inputs[i].value.includes("munzee.com"))
            {
                inputs[i].addEventListener('change', chBoxCheckedChange);
            }
        }
    }
}

function findButtonByText(text) {
    const buttons = document.getElementsByTagName("button");
    for (let i = 0; i < buttons.length; i++) {
        if (buttons[i].textContent === text) {
            return buttons[i];
        }
    }
    return null; // Button with the specified text not found
}

async function chBoxCheckedChange()
{
    await new Promise(resolve => setTimeout(resolve, 250)); // Wait for 200 ms
    var selectedURLs = "";
    var ua = document.getElementById('urlArea');
    ua.setAttribute('value','');
    var inputs = document.querySelectorAll('.PrivateSwitchBase-input:checked');
    for(var i = 0; i < inputs.length; i++) {
         if (inputs[i].value.includes("munzee.com"))
         {
             selectedURLs += '\n' +inputs[i].value;
         }
    }
    ua.value = selectedURLs;
}

//###########################################//
//New FireBase adaptation DOM Loaded checking//
//###########################################//
var DOMLoaded = false;
var doc = "";
var equalCounter = 0;

async function delayedLoop() {
    while (!DOMLoaded)
    {
        if (doc == document)
        {
            equalCounter++;
        }
        else
        {
            doc = document;
            equalCounter = 0;
        }

        if (equalCounter == 10)
        {
            DOMLoaded = true;
        }

        await new Promise(resolve => setTimeout(resolve, 250)); // Wait for 200 ms
    }

    PrintYourMunzees();
}

delayedLoop();