mTurk Title Bar Timer

Displays time remaining for HIT in title bar.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         mTurk Title Bar Timer
// @author       antithought
// @version      1.0.1
// @description  Displays time remaining for HIT in title bar.
// @include      https://www.mturk.com/mturk/accept*
// @include      https://www.mturk.com/mturk/previewandaccept*
// @include      https://www.mturk.com/mturk/continue*
// @include      https://www.mturk.com/mturk/submit*
// @namespace    https://greasyfork.org/users/6438
// ==/UserScript==

var original_title = document.title;
var st = unsafeWindow.serverTimestamp;
var et = unsafeWindow.endTime;
var timer_id;
var offset;

if (st && et) {
	timer_id = setInterval(function() {
		if (!offset) { offset = (new Date()).getTime() - st; }
		var left = Math.floor((et.getTime() - (new Date()).getTime() + offset) / 1000);
		var days = Math.floor(left / (86400));
		var hours = Math.floor(left / 3600) % 24;
		var mins = Math.floor(left / 60) % 60;
		var secs = left % 60;
		document.title = original_title + ": " + days + ":" + hours + ":" + ("0" +mins).slice(-2) + ":" + ("0" +secs).slice(-2);
	}, 1000);
}