Greasy Fork

florr.io | Playtime counter

Shows how no life you are

当前为 2023-03-03 提交的版本,查看 最新版本

// ==UserScript==
// @name         florr.io | Playtime counter
// @namespace    https://github.com/Samer-Kizi
// @version      1.0.3
// @description  Shows 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: 0px;
    text-align: right;
    pointer-events: none;
`
document.querySelector('body').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

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:12px">Since ${JSON.parse(localStorage.getItem('florrTime')).at(-1).date}:  ${allTimeA}</p><p style="font-size:20px">${time}</p>`
        allTime = 0
    }
}, 1000)

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'
});