// ==UserScript== // @name mmmturkeybacon Floating Timers // @author mmmturkeybacon // @description Adds total time elapsed, time remaining, and task time elapsed to a floating display. The task timer keeps track of page load times to more accurately reflect the amount of required to finish a HIT. // @namespace http://userscripts.org/users/523367 // @match https://*.mturk.com/mturk/preview* // @match https://*.mturk.com/mturk/accept* // @match https://*.mturk.com/mturk/continue* // @match https://*.mturk.com/mturk/submit* // @match https://*.mturk.com/mturk/return* // @require http://code.jquery.com/jquery-latest.min.js // @version 1.04 // @grant none // @downloadURL none // ==/UserScript== /* Code for calculating time remaining modified from mTurk Title Bar Timer (http://userscripts-mirror.org/scripts/review/169153) * The offset calculation is much more simplistic than https://www.mturk.com/js/timer.js uses but it is probably sufficient. */ // try to get serverTimestamp and set offset immediately, if that fails try again when the document is ready. var offset; var serverTimestamp = unsafeWindow.serverTimestamp; if (serverTimestamp) { offset = (new Date()).getTime() - serverTimestamp; } /* Set task_start_time as soon as possible, because page load time affects how long it takes to complete * a task. */ var task_start_time = localStorage.getItem('mtb_page_unload_time'); if (task_start_time == null) { task_start_time = (new Date()).getTime(); } //$(document).ready(function() window.addEventListener('load', function() { if (offset) { serverTimestamp = unsafeWindow.serverTimestamp; if (serverTimestamp) { offset = (new Date()).getTime() - serverTimestamp; } } var endTime = unsafeWindow.endTime; if (endTime) { endTime = endTime.getTime(); } var timer_holder = document.createElement("DIV"); timer_holder.style = "position: fixed; top: 0px; left: 0px; z-index: 20; background-color: black;"; timer_holder.align = "right"; var timer_holder_innerHTML = '