Little helper functions for E-mail notifications (RoomURLescape and GetReplayLink)



  • For those who want to build your own room links in email notifications here are two useful functions:

    function GetReplayLink(roomName, tick = Game.time, msg = "Replay"){
        return "<a href='https://screeps.com/a/#!/history/" +
               Game.shard.name + "/" + RoomURLescape(roomName) +
               "?t="+ tick +"'>" + msg +"</a>";
    }
    
    function RoomURLescape(roomName){
        let mapping = {N:"%4E", S:"%53", E:"%45",W:"%57"};
        let out = "";
        for (var i = 0; i < roomName.length; i++) {
            let c = roomName[i];
            out += mapping[c] || c;
        }
        return out;
    }
    

    If the room names aren't escaped the supposed server side "regex replace" kills your custom HTML links.
    However please keep in mind that this function only works for URLs and isn't suitable for anything else.

    hf 😉