Modify Greenies' Name

You can add prefix to the name of your green munzees

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Modify Greenies' Name
// @namespace    http://tampermonkey.net/
// @version      0.1
// @author       CzPeet
// @match        https://www.munzee.com/m/*/*/admin/?prefix=*
// @match        https://www.munzee.com/m/*/deploys/0/type/0
// @icon         https://www.google.com/s2/favicons?domain=munzee.com
// @description  You can add prefix to the name of your green munzees
// @grant        none
// ==/UserScript==

if (document.location.href.indexOf("deploys")>0)
{
    //Get string container
    var container = document.getElementById("search-text").parentElement;
    var greenPreFix = localStorage.getItem("munzeeGreeniesPrefix");
    var myLabel = document.createElement("Label");
    myLabel.innerText = "Prefix: ";
    myLabel.id = "prefLabel";
    myLabel.setAttribute("style","margin-left: 30px; margin-right: 5px");
    container.appendChild(myLabel);
    var myText = document.createElement("Input");
    myText.value = (greenPreFix != null) ? greenPreFix : "";
    myText.id = "prefText";
    myText.addEventListener('keyup', changePrefixText);
    container.appendChild(myText);

    changePrefixText();
}
else if (document.location.href.indexOf("?prefix")>0)
{
    var prefix = new URLSearchParams(window.location.search).get("prefix");
    var oldTitle = $("#friendly_name").val();

    if (oldTitle.indexOf(prefix) != 0)
    {
        $("#friendly_name").val(prefix+" "+oldTitle);

        var buttons = document.getElementsByTagName('button');
        for (var b = 0;b<buttons.length; b++)
        {
            if ($(buttons[b]).text() == "Update")
            {
                $(buttons[b]).click();
            }
        }
    }
}

function changePrefixText()
{
    var prefValue = $("#prefText").val();
    if (prefValue != null && prefValue != "")
    {
        localStorage.setItem("munzeeGreeniesPrefix", prefValue);
        //Modify Links in sections
        modifyLinks(prefValue);
    }
    else
    {
        localStorage.removeItem("munzeeGreeniesPrefix");
    }
}

function modifyLinks(prefix)
{
    var sections = document.getElementsByTagName('section');
    for (var s=0; s<sections.length; s++)
    {
        var links = sections[s].getElementsByTagName('a');
        for (var a=0; a<links.length; a++)
        {
            links[a].setAttribute("href", links[a].getAttribute("href")+"admin/?prefix="+prefix);
        }
    }
}