Greasy Fork is available in English.

Transshipment HUB FANs

Adds a button to in Transshipment HUB that sends FANs to stowers

// ==UserScript==
// @name         Transshipment HUB FANs
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a button to in Transshipment HUB that sends FANs to stowers
// @author       milcz
// @match        https://afttransshipmenthub-eu.aka.amazon.com/LCY2/stowing-in-progress/*
// @icon         https://qph.cf2.quoracdn.net/main-qimg-c8781a4bb1f17e330b50cb35f851da05.webp
// @grant        GM.xmlHttpRequest
// @grant        GM.openInTab
// ==/UserScript==

(function() {



    function load() {
    const activeStowers = document.getElementById('active-stowers');
    const totes = activeStowers.querySelectorAll('[id^="ts"][id$="row"]');
    for (let tote of totes) {
        let login = tote.parentElement.parentElement.parentElement.childNodes[0].childNodes[1].childNodes[1].lastChild.data.substring(4)
        let toteNumber = tote.childNodes[0].childNodes[1].childNodes[1].lastChild.data
        const button = document.createElement('button')
        const secondButton = document.createElement('button')
        button.innerHTML = 'Send Prioritize FAN'
        secondButton.innerHTML = 'Send Give To CR FAN'
        tote.childNodes[0].childNodes[1].appendChild(button)
        tote.childNodes[0].childNodes[1].appendChild(secondButton)
        button.parentElement.style.display = 'flex'
        button.onclick = function() {
            GM.xmlHttpRequest({
            method: "POST",
            url: "https://fans-dub.amazon.com/api/message/new",
            data: `{"to":"${login}","directReports":"","messageText":"Hi, can you prioritize tote ${toteNumber}, please?"}`,
            headers: {
                "Content-Type": "application/json"
            },
            onload: function(response) {
            console.log(response)
            if (response.status === 204) {
                button.style.display = 'none'
                secondButton.style.display = 'none'
                const responseMessage = document.createElement('div')
                responseMessage.innerHTML = "The FAN was sent!"
                responseMessage.style.padding = '5px'
                button.parentElement.appendChild(responseMessage)
            } else {
                GM.openInTab('https://fans-dub.amazon.com/', true)

            }
            }
            });

           }
        secondButton.onclick = function() {
            GM.xmlHttpRequest({
            method: "POST",
            url: "https://fans-dub.amazon.com/api/message/new",
            data: `{"to":"${login}","directReports":"","messageText":"Give tote ${toteNumber} to a cart runner if you cannot stow it, please."}`,
            headers: {
                "Content-Type": "application/json"
            },
            onload: function(response) {
            console.log(response)
            if (response.status === 204) {
                button.style.display = 'none'
                secondButton.style.display = 'none'
                const responseMessage = document.createElement('div')
                responseMessage.innerHTML = "The FAN was sent!"
                responseMessage.style.padding = '5px'
                button.parentElement.appendChild(responseMessage)
            } else {
                GM.openInTab('https://fans-dub.amazon.com/', true)

            }
            }
            });

           }

    }
}

    document.querySelector('[href="#active-stowers"]').addEventListener('click', load, {once: true})

})();