florr.io | Playtime counter

Show how no life you are

Από την 26/02/2023. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         florr.io | Playtime counter
// @namespace    https://github.com/Samer-Kizi
// @version      1.0.1
// @description  Show how no life you are
// @author       Furaken
// @match        https://florr.io/*
// @grant        unsafeWindow
// ==/UserScript==

var today = new Date().toString().substring(0,15)
var leech = [{"date":today,"value":0}],
    cvs = document.querySelector('canvas')
var newDoc = document.createElement('div')
newDoc.style = `
    right: 6px;
    bottom: -3px;
    color: white;
    text-shadow: rgb(0, 0, 0) 2px 0px 0px, rgb(0, 0, 0) 1.75517px 0.958851px 0px, rgb(0, 0, 0) 1.0806px 1.68294px 0px, rgb(0, 0, 0) 0.141474px 1.99499px 0px, rgb(0, 0, 0) -0.832294px 1.81859px 0px, rgb(0, 0, 0) -1.60229px 1.19694px 0px, rgb(0, 0, 0) -1.97998px 0.28224px 0px, rgb(0, 0, 0) -1.87291px -0.701566px 0px, rgb(0, 0, 0) -1.30729px -1.5136px 0px, rgb(0, 0, 0) -0.421592px -1.95506px 0px, rgb(0, 0, 0) 0.567324px -1.91785px 0px, rgb(0, 0, 0) 1.41734px -1.41108px 0px, rgb(0, 0, 0) 1.92034px -0.558831px 0px;    position: absolute;
    z-index: 1;
    font-family: Ubuntu;
    line-height: 2px;
    text-align: right;
    pointer-events: none;
`
document.documentElement.appendChild(newDoc)

if (localStorage.getItem("florrTime") === null) localStorage.setItem('florrTime', JSON.stringify(leech))
if (JSON.parse(localStorage.getItem("florrTime"))[0].date != today) {
    let x = JSON.parse(localStorage.getItem('florrTime'))
    x.unshift({"date":today,"value":0})
    localStorage.setItem('florrTime', JSON.stringify(x));
}
var start = Date.now() - Number(JSON.parse(localStorage.getItem("florrTime"))[0].value),
    time,
    allTime = 0,
    allTimeA,
    stop = false

let url;
const nativeWebSocket = unsafeWindow.WebSocket;
unsafeWindow.WebSocket = function(...args){
    const socket = new nativeWebSocket(...args);
    url = socket.url
    return socket;
};

function Time(seconds) {
    var hoursLeft = Math.floor(seconds / 3600);
    var min = Math.floor((seconds - hoursLeft * 3600) / 60);
    var secondsLeft = seconds - hoursLeft * 3600 - min * 60;
    secondsLeft = Math.round(secondsLeft * 100) / 100;
    var answer = hoursLeft< 10 ? "0" + hoursLeft : hoursLeft;
    answer += ":" + (min < 10 ? "0" + min : min);
    answer += ":" + (secondsLeft< 10 ? "0" + secondsLeft : secondsLeft);
    return answer
}

setInterval(function() {
    if (stop) {
        start = Date.now()
        stop = false
    } else {
        var delta = Date.now() - start
        let x = JSON.parse(localStorage.getItem('florrTime'))
        x[0].value = delta
        time = Time(Math.floor(Number(x[0].value) / 1000))
        x.forEach(k => {allTime += Number(k.value)})
        allTimeA = Time(Math.floor(Number(allTime) / 1000))
        localStorage.setItem('florrTime', JSON.stringify(x));
        newDoc.innerHTML = `<p style="font-size:${cvs.width/160}px">${url}</p><p style="font-size:${cvs.width/160}px">Since ${JSON.parse(localStorage.getItem('florrTime'))[0].date}:  ${allTimeA}</p><p style="font-size:${cvs.width/96}px">${time}</p>`
        allTime = 0
    }
}, 1000)

let cp6 = unsafeWindow.cp6
document.documentElement.addEventListener("keydown", function() {
    if (event.keyCode === 191 && event.ctrlKey && event.shiftKey) {
        if (confirm("Confirm reset all")) {
            stop = true;
            localStorage.setItem('florrTime', JSON.stringify(leech))
        }
    }
    else if (event.keyCode === 186) newDoc.style.display = newDoc.style.display === 'none' ? '' : 'none'
    else if (event.keyCode === 191 && event.shiftKey) cp6.forceServerID(prompt('Input server id'))
});