florr.io | Playtime counter

Show how no life you are

目前為 2023-02-25 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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

var leech = [0, 0, 0, 0, 0, 0, 0],
    today = new Date().getDay()
var newDoc = document.createElement('div')
newDoc.style = `
    right: 6px;
    bottom: 13px;
    font-size: 20px;
    color: white;
    text-shadow: rgb(0 0 0) -1px -1px 0px, rgb(0 0 0) 0px -1px 0px, rgb(0 0 0) 1px -1px 0px, rgb(0 0 0) 1px 0px 0px, rgb(0 0 0) 1px 1px 0px, rgb(0 0 0) 0px 1px 0px, rgb(0 0 0) -1px 1px 0px, rgb(0 0 0) -1px 0px 0px;
    position: absolute;
    z-index: 1;
    font-family: Ubuntu;
    line-height: 2px;
    text-align: right;
`
document.documentElement.appendChild(newDoc)

if (localStorage.getItem("florrTime") === null || !JSON.parse(localStorage.getItem("florrTime")).includes(0)) localStorage.setItem('florrTime', JSON.stringify(leech))

var start = Date.now() - Number(JSON.parse(localStorage.getItem("florrTime"))[today]),
    time,
    week,
    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[today] = delta
        time = Time(Math.floor(JSON.parse(localStorage.getItem('florrTime'))[today] / 1000))
        week = Time(Math.floor(JSON.parse(localStorage.getItem('florrTime')).reduce((a, b) => a + b, 0) / 1000))
        console.log(week)
        localStorage.setItem('florrTime', JSON.stringify(x));
        newDoc.innerHTML = `<p style="font-size:12px">Week: ${week}</p><br>${time}`
    }
}, 1000)

document.documentElement.addEventListener("keydown", function() {
    if (event.keyCode === 191 && event.ctrlKey && event.shiftKey) stop = true
    else if (event.keyCode === 186) newDoc.style.display = newDoc.style.display === 'none' ? '' : 'none';
});