Tab viewing timer

Timer for when a tab being focused in HH:MM format. Reset after 24 hours.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Tab viewing timer 
// @description Timer for when a tab being focused in HH:MM format. Reset after 24 hours.
// @version     1.0
// @author      Jenie
// @namespace   FFW Scripts
// @include     *
// @grant       none
// @noframes
// @license     MIT
// ==/UserScript==

document.body.insertAdjacentHTML(
	'beforeend',
	`<div id="timer" title="${new Date()}" style="position:fixed;bottom:0;right:0;color:#fff;background-color:#000;padding:10px;z-index:1000000;cursor:pointer;border-radius:2px;margin:10px;"><span>00:00</span></div>`
);

const timerSpan = document.querySelector('div#timer > span');
let focused = !0;
let seconds = 0;
window.setInterval(() => {
	if (!focused) return;
	seconds++;
	timerSpan.textContent = new Date(seconds * 1000).toISOString().substr(11, 5);
}, 1000);

const timerDiv = document.querySelector('div#timer');
timerDiv.addEventListener('click', () => {
	focused = !focused;
	timerDiv.style.color = focused ? '#fff' : 'red';
});

window.addEventListener('blur', () => {
	focused = !1;
	timerDiv.style.color = 'red';
});
window.addEventListener('focus', () => {
	focused = !0;
	timerDiv.style.color = '#fff';
});