ASCII text
        
            1
            // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0 
        
            2
            function updateButtons(postID, score) { 
        
            4
                document.getElementById(postID + "-voteup").classList.remove("selected"); 
        
            5
                document.getElementById(postID + "-votedown").classList.remove("selected"); 
        
            6
                if(score == 1) { 
        
            8
                    document.getElementById(postID + "-voteup").classList.add("selected"); 
        
            9
                } else if(score == -1) { 
        
            10
                    document.getElementById(postID + "-votedown").classList.add("selected"); 
        
            11
                } 
        
            12
            } 
        
            13
            async function vote(postID, score) { 
        
            15
                if(score === 1) { 
        
            16
                    action = "voteup"; 
        
            17
                } else if(score === -1) { 
        
            18
                    action = "votedown"; 
        
            19
                } else { 
        
            20
                    action = "votes"; 
        
            21
                } 
        
            22
                const response = await fetch(postID + "/" + action); 
        
            23
                const info = await response.text(); 
        
            24
                document.getElementById(postID + "-vote").innerText = info.split(" ")[0]; 
        
            25
                updateButtons(postID, info.split(" ")[1]) 
        
            26
            } 
        
            27
            // @license-end