Wolfar / Timer

// ==UserScript==
// @namespace    https://openuserjs.org/users/Wolfar
// @name         Timer
// @version      0.0.0
// @description  Show Buffs time in profile page
// @include      https://*.e-sim.org/battle.html?id=*
// @license      MIT
// @grant        none
// ==/UserScript==

// ==OpenUserJS==
// @author Wlfar
// ==/OpenUserJs==

function title() {
    let id = window.location.href.split('e-sim.org/battle.html?id=')[1];
    fetch('apiBattles.html?battleId=' + id)
    .then(function(response) {
        return response.json()
    })
    .then(function(response) {
        let hours = response[0].hoursRemaining;
        let minutes = response[0].minutesRemaining;
        let seconds = response[0].secondsRemaining;
        console.log(seconds,minutes,hours);
        document.title = hours + ':' + minutes + ':' + seconds;
    })
    .catch(function(err) {
        console.log('Failed to fetch page: ', err);
    })
}

var interval = setInterval(function(){title()},500);