florr.io | Playtime counter

Show how no life you are

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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';
});