您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds total time elapsed, time remaining, and task time elapsed to a floating display.
当前为
// ==UserScript== // @name mtb Floating Timers // @author mmmturkeybacon // @description Adds total time elapsed, time remaining, and task time elapsed to a floating display. // @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.0 // @grant 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; } $(document).ready(function() { if (offset) { serverTimestamp = unsafeWindow.serverTimestamp; if (serverTimestamp) { offset = (new Date()).getTime() - serverTimestamp; } } var endTime = unsafeWindow.endTime; if (endTime) { endTime = endTime.getTime(); } var task_start_time; var timer_holder = document.createElement("DIV"); timer_holder.style = "position: fixed; top: 0px; left: 0px; z-index: 20; background-color: black; filter:alpha(opacity=75); /* IE */ opacity: 0.75; /* Safari, Opera */ -moz-opacity:0.75; /* FireFox */"; timer_holder.align = "right"; var timer_holder_innerHTML = '<div><span id="elapsed_timer" class="title_orange_text" style="text-align: right;"></span></div>'; timer_holder_innerHTML += '<div><span id="remaining_timer" class="title_orange_text" style="text-align: right;"></span></div>'; timer_holder_innerHTML += '<div><span id="task_timer" class="title_orange_text" style="text-align: right;"></span></div>'; timer_holder.innerHTML = timer_holder_innerHTML; document.body.insertBefore(timer_holder, document.body.firstChild); var theTime = document.getElementById("theTime"); var elapsed_timer = document.getElementById("elapsed_timer"); var remaining_timer = document.getElementById("remaining_timer"); var task_timer = document.getElementById("task_timer"); var observer = new MutationObserver(function (mutations) { var now = (new Date()).getTime(); elapsed_timer.innerHTML = theTime.innerHTML; /* Want task_start_time to be as close as possible to when the page is fully loaded * and work can begin. */ if (!task_start_time) {task_start_time = now;}; var task_seconds_elapsed = Math.floor((now - task_start_time)/1000); task_timer.innerHTML = format_time(task_seconds_elapsed); if (endTime && offset) { var seconds_remaining = Math.floor((endTime - (now + offset))/1000); remaining_timer.innerHTML = format_time(seconds_remaining); } else { remaining_timer.innerHTML = "error"; } }); var options = { subtree: true, childList: true, attributes: false }; observer.observe(theTime, options); }); function format_time(time_in_seconds) { var time_str = "error"; if (time_in_seconds >= 0) { // time formatting code modified from http://userscripts.org/scripts/show/169154 var days = Math.floor((time_in_seconds/(60*60*24))); var hours = Math.floor((time_in_seconds/(60*60)) % 24); var minutes = Math.floor((time_in_seconds/60) % 60); var seconds = time_in_seconds % 60; time_str = (days == 0 ? '' : days + (days > 1 ? ' days ' : ' day ')); if (hours < 10) {hours = "0"+hours;} if (minutes < 10) {minutes = "0"+minutes;} if (seconds < 10) {seconds = "0"+seconds;} time_str += hours + ':' +minutes + ':' + seconds; } return time_str; }