Metatag Bookmarklet Tool




var id = WIKIREQUEST.info.pageId;
function input(a, b) {
    return '<label>' + a + ': </label><input type="text" id="' + ("meta" + a.toLowerCase()) + '" value="' + b + '"><br>';
}
var ran;
if (!ran) {
    document.getElementById("page-content").insertAdjacentHTML('afterbegin', input("Title", document.getElementById("page-title").innerHTML.replaceAll("  ", "").replaceAll("\n", "").replaceAll('"', "&quot;").split(" - ")[0].split("")[0] + " - The Backrooms Wiki") + input("Description", "") + input("Image", "") + "<button onclick='saveall();'>Save Changes</button><label id='uifeedback'></label>");
}
ran = true;
var feedback = document.getElementById("uifeedback");
null;
 
function savemeta(name, field) {
    var content = document.getElementById(field).value;
    if (content) {
        OZONE.ajax.requestModule("edit/EditMetaModule", {
            metaName: name,
            metaContent: content,
            action: "WikiPageAction",
            event: "saveMetaTag",
            pageId: id
        }, x => x)
    };
}
async function saveall() {
    savemeta("og:title", "metatitle");
    savemeta("og:description", "metadescription");
    savemeta("description", "metadescription");
    savemeta("og:image", "metaimage");
    var newtags = "";
    await new Promise(res => OZONE.ajax.requestModule("pagetags/PageTagsModule", {
        pageId: id
    }, s => {
        newtags = s.body.split('value="')[1].split('"/')[0] + " _metatag";
        res()
    }));
    OZONE.ajax.requestModule(null, {
        tags: newtags,
        pageId: id,
        action: "WikiPageAction",
        event: "saveTags"
    }, x => x);
    feedback.innerHTML = "  Action Completed!";
    setTimeout(() => feedback.innerHTML = "", 1000)
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License