JR mturk timer warning

Script will warn you at specific times left for your hit. The times can be set in the options menu.

  1. // ==UserScript==
  2. // @name JR mturk timer warning
  3. // @version 0.7.10
  4. // @namespace https://gf.qytechs.cn/users/6406
  5. // @description Script will warn you at specific times left for your hit. The times can be set in the options menu.
  6. // @author John Ramirez (JohnnyRS)
  7. // @include http*://*.mturk.com/mturk/continue*
  8. // @include http*://*.mturk.com/mturk/accept*
  9. // @include http*://*.mturk.com/mturk/preview*
  10. // @include http*://*.mturk.com/mturk/myhits*
  11. // @include http*://*.mturk.com/mturk/submit*
  12. // @include http*://worker.mturk.com/projects/*
  13. // @exclude *mturk.com/*HITMONITOR*
  14. // @require http://code.jquery.com/jquery-2.1.4.min.js
  15. // @grant GM_getValue
  16. // @grant GM_setValue
  17. // ==/UserScript==
  18.  
  19. // Warns you with a voice, alarm or colors on the amount of time left for the current hit. You can set your own options
  20. // in the menu at top. There is a male and female voice for the warning. You can turn off the warnings and color.
  21. // the options are saved so you don't have to set it again. You can stop it saving options for the current hit if
  22. // you just want changes for the hit you are on.
  23.  
  24. var gSeconds = 0, gElapsedSeconds = 0, gWorking = false, gDoNotSpeak = false, gVolume = 1, intervalVar=null, gNewSite=false, gSpeech=new SpeechSynthesisUtterance();
  25. var gOptionsDefault = {"status":["On",0],"voice":["female",0],"alarm":["Off",0],"color":["On",0],"firstSpeak":["On",0]};
  26. var gOptionTimesDefault = {"60":["Off",0],"30":["On",0],"20":["Off",0],"10":["Off",0],"5":["On",0],"1":["On",0],"30s":["On",0],"every1":["off",0],
  27. "every5":["off",0],"every10":["off",0]};
  28. var gWarningTimes = {"60":false,"30":false,"20":false,"10":false,"5":false,"1":false,"30s":false,"every1":false,"every5":false,
  29. "every10":false};
  30. var gHtmlColors = ["FF0000","FF3322","FF6633","FFAA39","FFCCCC","FFEFEC","FFEFCC","EEEFCC","CCCCBB","CCCCBF","CCCCCC","CCCCDD","CCCCDF","CCCCEE","CCCCEF","CCDDFF","DDDDFF","EEEEFF","EEEEF9","EEEEF6","FFFFF2","FFFFF5","FFFFF8","FFFFFF"];
  31.  
  32. var f60MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%201%20hour%20left%20-%20Laura.mp3");
  33. var m60MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%201%20hour%20left%20-%20Paul.mp3");
  34. var a60MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%2060%20minutes%20left.mp3");
  35. var f30MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2030%20minutes%20left%20-%20laura.mp3");
  36. var m30MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2030%20minutes%20left%20-%20Paul.mp3");
  37. var a30MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%2030%20minutes%20left.mp3");
  38. var f20MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2020%20minutes%20left%20-%20laura.mp3");
  39. var m20MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2020%20minutes%20left%20-%20Paul.mp3");
  40. var a20MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%2020%20minutes%20left.mp3");
  41. var f10MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2010%20minutes%20left%20-%20Laura.mp3");
  42. var m10MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2010%20minutes%20left%20-%20Paul.mp3");
  43. var a10MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%2010%20minutes%20left.mp3");
  44. var f5MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%205%20minutes%20left%20-%20Laura.mp3");
  45. var m5MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%205%20minutes%20left%20-%20Paul.mp3");
  46. var a5MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%205%20minutes%20left.mp3");
  47. var f1MinuteLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%201%20minute%20left%20-%20Laura.mp3");
  48. var m1MinuteLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%201%20minute%20left%20-%20Paul.mp3");
  49. var a1MinuteLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%201%20minute%20left.mp3");
  50. var f30SecondsLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2030%20seconds%20left%20-%20Laura.mp3");
  51. var m30SecondsLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2030%20seconds%20left%20-%20Paul.mp3");
  52. var a30SecondsLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%2030%20seconds%20left.mp3");
  53. var fTesting = new Audio("http://www.allbyjohn.com/sounds/This%20is%20just%20a%20test%20of%20this%20warning%20system%20-%20Laura.mp3");
  54. var mTesting = new Audio("http://www.allbyjohn.com/sounds/This%20is%20just%20a%20test%20of%20this%20warning%20system%20-%20Paul.mp3");
  55. var g60MinutesLeft = null, g30MinutesLeft = null, g20MinutesLeft = null, g10MinutesLeft = null, g5MinutesLeft = null, g1MinutesLeft = null,
  56. g30SecondsLeft = null, gTesting = null, gOptions = null, gOptionTimes = null, gVoices = null;
  57.  
  58. function defaultFillIn(data,defaultData) {
  59. if (!data) return null; var returnData = data;
  60. for (var key in defaultData) { if (!(key in returnData)) returnData[key] = defaultData[key]; }
  61. return returnData;
  62. }
  63. function loadSettings() {
  64. var loadedOptions = JSON.parse(GM_getValue("JR_WN_options",JSON.stringify(gOptionsDefault)));
  65. var loadedOptionTimes = JSON.parse(GM_getValue("JR_WN_optionTimes",JSON.stringify(gOptionTimesDefault)));
  66. gOptions = defaultFillIn(loadedOptions,gOptionsDefault);
  67. gOptionTimes = defaultFillIn(loadedOptionTimes,gOptionTimesDefault);
  68. }
  69. function saveSettings() {
  70. GM_setValue("JR_WN_options",JSON.stringify(gOptions));
  71. GM_setValue("JR_WN_optionTimes",JSON.stringify(gOptionTimes));
  72. }
  73. function speakThisNow(thisText,gender) {
  74. if('speechSynthesis' in window){
  75. var thisVoice = (gender) ? ((gender.toLowerCase()=="male") ? gVoices[0] : gVoices[1]) : gVoices[0];
  76. gSpeech.lang = 'en-US';
  77. gSpeech.volume = gVolume;
  78. gSpeech.voice = thisVoice;
  79. gSpeech.text = thisText;
  80. window.speechSynthesis.speak(gSpeech);
  81. }
  82. }
  83. function convertTimeToSeconds(hours,minutes,seconds,days,weeks) {
  84. var totalSeconds = seconds + ((minutes) ? (minutes*60) : 0) + ((hours) ? (hours*3600) : 0) +
  85. ((days) ? (days*86400) : 0) + ((weeks) ? (weeks*604800) : 0);
  86. return totalSeconds;
  87. }
  88. function pad(number, length) {
  89. var str = '' + number;
  90. while (str.length < length) {
  91. str = '&nbsp;' + str;
  92. }
  93. return str;
  94. }
  95. (function($){ $.fn.disableSelection = function() { return this.attr('unselectable', 'on').css('user-select', 'none').on('selectstart', false); }; })(jQuery);
  96. function createDiv(theHtml) { var inner = (theHtml) ? theHtml : ""; return $('<div>').html(inner); }
  97. function createSpan(theHtml) { var inner = (theHtml) ? theHtml : ""; return $('<span>').html(inner); }
  98. function createMyElement(elementName,theClass,theId,theStyle,theText) {
  99. var theElement = document.createElement(elementName);
  100. if (theClass) theElement.className = theClass;
  101. if (theId) theElement.id = theId;
  102. if (theStyle) theElement.setAttribute("style",theStyle);
  103. if (theText) theElement.innerHTML = theText;
  104. return theElement;
  105. }
  106. function createButton(theClass,theId,theValue,theName,theStyle) {
  107. var theButton = createMyElement("input",theClass,theId,theStyle);
  108. theButton.type = "button";
  109. if (theValue) theButton.value = theValue;
  110. if (theName) theButton.name = theName;
  111. return theButton;
  112. }
  113. function createCheckbox(theClass,theId,theValue,theName,theStyle) {
  114. var theCheckbox = createMyElement("input",theClass,theId,theStyle);
  115. theCheckbox.value = theValue;
  116. theCheckbox.type = "checkbox";
  117. if (theName) theCheckbox.name = theName;
  118. return theCheckbox;
  119. }
  120. function createTextInput(theClass,theId,theValue,theName,theStyle) {
  121. var theInput = createMyElement("input",theClass,theId,theStyle);
  122. theInput.type = "text";
  123. if (theValue) theInput.value = theValue;
  124. if (theName) theInput.name = theName;
  125. return theInput;
  126. }
  127. function setUpVoices(gender) {
  128. if (gender == "Female") {
  129. g60MinutesLeft = f60MinutesLeft; g30MinutesLeft = f30MinutesLeft; g20MinutesLeft = f20MinutesLeft; g10MinutesLeft = f10MinutesLeft;
  130. g5MinutesLeft = f5MinutesLeft; g1MinuteLeft = f1MinuteLeft; g30SecondsLeft = f30SecondsLeft; gTesting = fTesting;
  131. } else if (gender == "Male") {
  132. g60MinutesLeft = m60MinutesLeft; g30MinutesLeft = m30MinutesLeft; g20MinutesLeft = m20MinutesLeft; g10MinutesLeft = m10MinutesLeft;
  133. g5MinutesLeft = m5MinutesLeft; g1MinuteLeft = m1MinuteLeft; g30SecondsLeft = m30SecondsLeft; gTesting = mTesting;
  134. } else {
  135. g60MinutesLeft = a60MinutesLeft; g30MinutesLeft = a30MinutesLeft; g20MinutesLeft = a20MinutesLeft; g10MinutesLeft = a10MinutesLeft;
  136. g5MinutesLeft = a5MinutesLeft; g1MinuteLeft = a1MinuteLeft; g30SecondsLeft = a30SecondsLeft; gTesting = a30SecondsLeft;
  137. }
  138. }
  139. function setColor(theTimeLeft) {
  140. var theColor = "FFFFFF";
  141. if (theTimeLeft<30) theColor = gHtmlColors[0]; // less than 30 seconds
  142. else if (theTimeLeft<60) theColor = gHtmlColors[1]; // less than 1 minute
  143. else if (theTimeLeft<600) {
  144. theColor = gHtmlColors[Math.ceil(theTimeLeft/60)]; // less than 10 minutes
  145. }
  146. else if (theTimeLeft<1200) {
  147. theColor = gHtmlColors[Math.ceil((theTimeLeft-600)/120)+10]; // less than 20 minutes
  148. }
  149. else if (theTimeLeft<1800) {
  150. theColor = gHtmlColors[Math.ceil((theTimeLeft-1200)/240)+15]; // less than 30 minutes
  151. }
  152. else if (theTimeLeft<2100) theColor = gHtmlColors[20];
  153. else if (theTimeLeft<2400) theColor = gHtmlColors[21];
  154. else if (theTimeLeft<3000) theColor = gHtmlColors[22];
  155. else if (theTimeLeft<2600) theColor = gHtmlColors[23];
  156. $("#MainContent").css("background-color","#"+theColor);
  157. }
  158. function timeElapsed() {
  159. var hours = 0, minutes = 0, seconds = 0, minutesAt = 1;
  160. var theTime = document.getElementsByClassName("completion-timer");
  161. if (theTime.length) {
  162. var theSplit = theTime[0].innerHTML.split(":");
  163. if (theSplit.length < 3) minutesAt=0;
  164. hours = (theSplit.length == 3) ? parseInt(theSplit[0]) : 0;
  165. minutes = parseInt(theSplit[minutesAt]);
  166. seconds = parseInt(theSplit[minutesAt + 1]);
  167. minutes += hours * 60;
  168. var gElapsedSeconds = seconds + (minutes * 60);
  169. return gElapsedSeconds;
  170. } else return null;
  171. }
  172. function timeAlotted() {
  173. var theTime = document.getElementsByClassName("completion-timer");
  174. if (theTime.length) {
  175. var theSplit = theTime[0].innerHTML.split("of ");
  176. var theMinutesString = theSplit[1].split(" ");
  177. return Number(theMinutesString[0]) * 60;
  178. }
  179. }
  180. function timeLeft() {
  181. return timeAlotted() - timeElapsed();
  182. }
  183. function warning(theSound,theTime) {
  184. theSound.volume = gVolume;
  185. theSound.play();
  186. gWarningTimes[theTime] = true;
  187. }
  188. function checkTimes(announceNow) {
  189. var timeLeftSeconds = timeLeft();
  190. if (timeLeftSeconds) {
  191. if (timeLeftSeconds<=30) {
  192. if (gOptionTimes["30s"][0] == "On" && !gWarningTimes["30s"]) warning(g30SecondsLeft,"30s");
  193. } else if (timeLeftSeconds<=60) {
  194. if (gOptionTimes["1"][0] == "On" && !gWarningTimes["1"]) warning(g1MinuteLeft,"1");
  195. } else if (timeLeftMinutes<5 && (timeLeftMinutes>3 || announceNow)) {
  196. if (gOptionTimes["5"][0] == "On" && (!gWarningTimes["5"] || announceNow))
  197. if (gElapsedSeconds>185 || announceNow) warning(g5MinutesLeft,"5");
  198. } else if (timeLeftMinutes<10 && (timeLeftMinutes>7 || announceNow)) {
  199. if (gOptionTimes["10"][0] == "On" && (!gWarningTimes["10"] || announceNow))
  200. if (gElapsedSeconds>185 || announceNow) warning(g10MinutesLeft,"10");
  201.  
  202. } else if (timeLeftMinutes<20 && (timeLeftMinutes>15 || announceNow)) {
  203. if (gOptionTimes["20"][0] == "On" && (!gWarningTimes["20"] || announceNow))
  204. if (gElapsedSeconds>305 || announceNow) warning(g20MinutesLeft,"20");
  205. } else if (timeLeftMinutes<30 && (timeLeftMinutes>24 || announceNow)) {
  206. if (gOptionTimes["30"][0] == "On" && (!gWarningTimes["30"] || announceNow))
  207. if (gElapsedSeconds>365 || announceNow) warning(g30MinutesLeft,"30");
  208. } else if (timeLeftMinutes<60 && (timeLeftMinutes>53 || announceNow)) {
  209. if (gOptionTimes["60"][0] == "On" && (!gWarningTimes["60"] || announceNow))
  210. if (gElapsedSeconds>425 || announceNow) warning(g60MinutesLeft,"60");
  211. }
  212. if (gOptions.color[0] == "On") setColor(timeLeftSeconds);
  213. else document.getElementsByTagName("form")[1].style.backgroundColor = "#FFFFFF";
  214. }
  215. }
  216. function setOptions() {
  217. gOptions.status[0] = document.getElementById("warningOption").getAttribute("currentValue");
  218. gOptions.status[1] = document.getElementById("warningOption").getAttribute("valueIndex");
  219. gOptions.voice[0] = document.getElementById("warningVoiceOptions").getAttribute("currentValue");
  220. gOptions.voice[1] = document.getElementById("warningVoiceOptions").getAttribute("valueIndex");
  221. gOptions.alarm[0] = document.getElementById("warningAlarmOptions").getAttribute("currentValue");
  222. gOptions.alarm[1] = document.getElementById("warningAlarmOptions").getAttribute("valueIndex");
  223. gOptions.color[0] = document.getElementById("warningColorOptions").getAttribute("currentValue");
  224. gOptions.color[1] = document.getElementById("warningColorOptions").getAttribute("valueIndex");
  225. gOptions.firstSpeak[0] = document.getElementById("speakStartOption").getAttribute("currentValue");
  226. gOptions.firstSpeak[1] = document.getElementById("speakStartOption").getAttribute("valueIndex");
  227. gOptionTimes["60"][0] = document.getElementById("1HourOptions").getAttribute("currentValue");
  228. gOptionTimes["60"][1] = document.getElementById("1HourOptions").getAttribute("valueIndex");
  229. gOptionTimes["30"][0] = document.getElementById("30MinutesOptions").getAttribute("currentValue");
  230. gOptionTimes["30"][1] = document.getElementById("30MinutesOptions").getAttribute("valueIndex");
  231. gOptionTimes["20"][0] = document.getElementById("20MinutesOptions").getAttribute("currentValue");
  232. gOptionTimes["20"][1] = document.getElementById("20MinutesOptions").getAttribute("valueIndex");
  233. gOptionTimes["10"][0] = document.getElementById("10MinutesOptions").getAttribute("currentValue");
  234. gOptionTimes["10"][1] = document.getElementById("10MinutesOptions").getAttribute("valueIndex");
  235. gOptionTimes["5"][0] = document.getElementById("5MinutesOptions").getAttribute("currentValue");
  236. gOptionTimes["5"][1] = document.getElementById("5MinutesOptions").getAttribute("valueIndex");
  237. gOptionTimes["1"][0] = document.getElementById("1MinuteOptions").getAttribute("currentValue");
  238. gOptionTimes["1"][1] = document.getElementById("1MinuteOptions").getAttribute("valueIndex");
  239. gOptionTimes["30s"][0] = document.getElementById("30SecondsOptions").getAttribute("currentValue");
  240. gOptionTimes["30s"][1] = document.getElementById("30SecondsOptions").getAttribute("valueIndex");
  241. gOptionTimes.every1[0] = document.getElementById("every1").getAttribute("currentValue");
  242. gOptionTimes.every1[1] = document.getElementById("every1").getAttribute("valueIndex");
  243. gOptionTimes.every5[0] = document.getElementById("every5").getAttribute("currentValue");
  244. gOptionTimes.every5[1] = document.getElementById("every5").getAttribute("valueIndex");
  245. gOptionTimes.every10[0] = document.getElementById("every10").getAttribute("currentValue");
  246. gOptionTimes.every10[1] = document.getElementById("every10").getAttribute("valueIndex");
  247. if (gOptions.voice[0] != "Off") setUpVoices(gOptions.voice[0]);
  248. else if (gOptions.alarm[0] != "Off") setUpVoices();
  249. if (gWorking) {
  250. if (gOptions.color[0] == "On" && gOptions.status[0] == "On") setColor(timeElapsed());
  251. else document.getElementsByTagName("form")[1].style.backgroundColor = "#FFFFFF";
  252. if (!gDoNotSpeak && gOptions.status[0] == "On" && (gOptions.voice[0] != "Off" || gOptions.alarm[0] != "Off")) checkTimes(true);
  253. } else if (gOptions.status[0] == "On" && gOptions.voice[0] != "Off" && !gDoNotSpeak) {
  254. if (gNewSite) speakThisNow("This is a test of this warning system.",gOptions.voice[0]); else gTesting.play();
  255. }
  256. if (document.getElementById("warningOptionsSave").checked) saveSettings();
  257. }
  258. function createSpanOptions(theNode,theOptions) {
  259. var theId = "", theText = "", theValues = [], theStatus = "", replaceWith="";
  260. for (var i=0,len=theOptions.length; i<len; i++) {
  261. theId = theOptions[i][0];
  262. theText = theOptions[i][1];
  263. theValues = theOptions[i][2];
  264. theStatus = theValues[theOptions[i][3]].substr(0,1);
  265. replaceWith = theValues[theOptions[i][3]].replace(theStatus,"");
  266. theOption = createMyElement("span","myOwnSpan",theId,
  267. "cursor:pointer; -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;",
  268. theText.replace("$",replaceWith));
  269. if (theStatus=="-") theOption.style.color = "#FF0000";
  270. else theOption.style.color = "#006600";
  271. theOption.setAttribute("theValues",JSON.stringify(theValues));
  272. theOption.setAttribute("valueIndex",theOptions[i][3]);
  273. theOption.setAttribute("theText",theText);
  274. theOption.setAttribute("currentValue",replaceWith);
  275. theNode.appendChild(document.createTextNode(" "));
  276. theNode.appendChild(theOption);
  277. theOption.onmousemove = function(e) {
  278. e.preventDefault();
  279. e.stopPropagation();
  280. return false;
  281. };
  282. theOption.onclick = function() {
  283. gDoNotSpeak = true;
  284. var theValues = JSON.parse(this.getAttribute("theValues"));
  285. var theIndex = parseInt(this.getAttribute("valueIndex"));
  286. var theText = this.getAttribute("theText");
  287. theIndex = (theIndex < theValues.length-1) ? theIndex+1 : 0;
  288. this.setAttribute("valueIndex",theIndex);
  289. var theStatus = theValues[theIndex].substr(0,1);
  290. var replaceWith = theValues[theIndex].replace(theStatus,"");
  291. this.innerHTML = theText.replace("$",replaceWith);
  292. this.setAttribute("currentValue",replaceWith);
  293. if (theStatus=="-") this.style.color = "#FF0000";
  294. else this.style.color = "#006600";
  295. if (this.id == "warningAlarmOptions" && replaceWith == "On") {
  296. document.getElementById("warningVoiceOptions").setAttribute("currentValue","Off");
  297. document.getElementById("warningVoiceOptions").setAttribute("valueIndex","1");
  298. document.getElementById("warningVoiceOptions").innerHTML = "[ Voice: Off ]";
  299. document.getElementById("warningVoiceOptions").style.color = "#FF0000";
  300. } else if (this.id == "warningVoiceOptions" && replaceWith != "Off") {
  301. document.getElementById("warningAlarmOptions").setAttribute("currentValue","Off");
  302. document.getElementById("warningAlarmOptions").setAttribute("valueIndex","0");
  303. document.getElementById("warningAlarmOptions").innerHTML = "[ Alarm: Off ]";
  304. document.getElementById("warningAlarmOptions").style.color = "#FF0000";
  305. gDoNotSpeak = false;
  306. } else if (this.id == "warningOption" && replaceWith != "Off") {
  307. gDoNotSpeak = false;
  308. } else if (this.id == "speakStartOption") { gDoNotSpeak = true; sayTimeLeft(); }
  309. setOptions();
  310. };
  311. }
  312. }
  313. function toggleOptionsMenu() {
  314. var rect = $("#JRTimerOptions").offset();
  315. toggleOptionsMenu.display = toggleOptionsMenu.display || false;
  316. toggleOptionsMenu.display = !toggleOptionsMenu.display;
  317. if (toggleOptionsMenu.display) $("#JR_TimerWOptionsMenu").css("top",rect.top - $(window).scrollTop() + 18).show();
  318. else $("#JR_TimerWOptionsMenu").hide();
  319. }
  320. function showOptionsNew(menuNode) {
  321. var theOptionsContainer = createMyElement("div","myOwnDiv","warningOptionsContainer", "padding: 11px 1px 0 7px;");
  322. var theOptionsControl = createMyElement("div","myOwnDiv","warningOptionsController","");
  323. var spanWarningOptions = [ ["warningOption","[ Status: $ ]",["+On","-Off"],gOptions.status[1]], ["warningVoiceOptions","[ Voice: $ ]",["+Female","-Off","+Male"],
  324. gOptions.voice[1]], ["warningAlarmOptions","[ Alarm: $ ]",["-Off","+On"],gOptions.alarm[1]], ["warningColorOptions","[ Color: $ ]",["+On","-Off"],gOptions.color[1]]];
  325. theOptionsControl.appendChild( createMyElement("span","myOwnSpan","","color:blue; font-weight:bold;","Time Left Warning: ") );
  326. createSpanOptions(theOptionsControl,spanWarningOptions);
  327. theOptionsControl.appendChild(createMyElement("br"));
  328. theOptionsControl.appendChild( createMyElement("span","myOwnSpan","","color:blue; font-weight:bold;","Warn at: ") );
  329. var spanTimeOptions = [ ["30SecondsOptions","[30 seconds]",["+On","-Off"],gOptionTimes["30s"][1]], ["1MinuteOptions","[1 minute]",["+On","-Off"],gOptionTimes["1"][1]],
  330. ["5MinutesOptions","[5 minutes]",["+On","-Off"],gOptionTimes["5"][1]], ["10MinutesOptions","[10 minutes]",["-Off","+On"],gOptionTimes["10"][1]],
  331. ["20MinutesOptions","[20 minutes]",["-Off","+On"],gOptionTimes["20"][1]], ["30MinutesOptions","[30 minutes]",["+On","-Off"],gOptionTimes["30"][1]],
  332. ["1HourOptions","[1 hour]",["-Off","+On"],gOptionTimes["60"][1]] ];
  333. createSpanOptions(theOptionsControl,spanTimeOptions);
  334. theOptionsControl.appendChild(createMyElement("br"));
  335. theOptionsControl.appendChild( createMyElement("span","myOwnSpan","","color:blue; font-weight:bold;","Warn for: ") );
  336. var spanEveryOptions = [ ["every1","[Every&nbsp;Minute]",["-Off","+On"],gOptionTimes.every1[1]],
  337. ["every5","[Every&nbsp;Five&nbsp;Minutes]",["-Off","+On"],gOptionTimes.every5[1]],["every10","[Every&nbsp;10&nbsp;Minutes]",["-Off","+On"],gOptionTimes.every10[1]]];
  338. createSpanOptions(theOptionsControl,spanEveryOptions);
  339. theOptionsControl.appendChild(createMyElement("br"));
  340. var spanStartOptions = [ ["speakStartOption","[ Speak Time Left: $ ]",["+On","-Off"],gOptions.firstSpeak[1]] ];
  341. theOptionsControl.appendChild( createMyElement("span","myOwnSpan","","color:blue; font-weight:bold;","At Beginning Options: ") );
  342. createSpanOptions(theOptionsControl,spanStartOptions);
  343. theOptionsControl.appendChild(createMyElement("br"));
  344. theOptionsControl.appendChild(document.createTextNode("Click on text above to change options."));
  345. theOptionsControl.appendChild(createMyElement("br"));
  346. var theOptionsSave = createCheckbox("myOwnCheckBox","warningOptionsSave","save Me","","margin-left:20px; height:10px;");
  347. theOptionsSave.checked = true;
  348. theOptionsSave.onclick = function() { if (theOptionsSave.checked) saveSettings(); };
  349. theOptionsControl.appendChild(theOptionsSave);
  350. theOptionsControl.appendChild(document.createTextNode(" Permanently Save Options"));
  351. var volumeLower = createMyElement("span","myOwnSpan","lowerVolumeControl",
  352. "cursor: pointer; margin-left:20px; margin-right:10px; -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;","<-");
  353. theOptionsControl.appendChild(volumeLower);
  354. var volumeLevelText = createMyElement("span","myOwnSpan","theVolumeText",
  355. "cursor:pointer; display: inline-block; width:125px; -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;",
  356. " Volume Level: 100 ");
  357. theOptionsControl.appendChild(volumeLevelText);
  358. var volumeHigher = createMyElement("span","myOwnSpan","lowerVolumeControl",
  359. "cursor: pointer; -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;","->");
  360. theOptionsControl.appendChild(volumeHigher);
  361. volumeLower.onclick = function() {
  362. gVolume = (gVolume<0.1) ? 0 : (gVolume-0.1);
  363. document.getElementById("theVolumeText").innerHTML = " Volume Level: " + pad(Math.round(gVolume*100),3);
  364. speakThisNow("Hi",gOptions.voice[0]);
  365. };
  366. volumeHigher.onclick = function() {
  367. gVolume = (gVolume>0.9) ? 1 : (gVolume+0.1);
  368. document.getElementById("theVolumeText").innerHTML = " Volume Level: " + pad(Math.round(gVolume*100),3);
  369. speakThisNow("Hi",gOptions.voice[0]);
  370. };
  371. theOptionsControl.appendChild(createMyElement("br"));
  372. theOptionsControl.appendChild( createMyElement("div","myOwnDiv","myCloseMenu","box-sizing:content-box; font-size:12px; background-color:#eeeeee; " +
  373. "border:3px groove darkgrey; padding:0px 2px; margin-left:45px; margin-top:5px; width:150px;","Close Menu" ));
  374. theOptionsControl.appendChild(createMyElement("br"));
  375. theOptionsContainer.appendChild(theOptionsControl);
  376. $(menuNode).append($(theOptionsContainer)[0]);
  377. $("#myCloseMenu").disableSelection().click(function() { toggleOptionsMenu(); });
  378. }
  379. function timerLeftAlarms(theHours,theMinutes,theSeconds,voice) {
  380. var returnValue = "";
  381. if (timerLeftAlarms.last) {
  382. if (theHours===0 && theMinutes===0 && theSeconds>0) {
  383. if (theSeconds==30 && gOptionTimes["30s"][0] == "On")
  384. returnValue= (voice) ? "seconds" : "30seconds"; // 30second alarm should sound
  385. else returnValue="";
  386. }
  387. if (returnValue === "") {
  388. if (timerLeftAlarms.last.minutes != theMinutes) {
  389. if (gOptionTimes.every1[0] == "On") returnValue= (voice) ? "minutes" : "every"; // every 1 minute alarm should sound
  390. else if (gOptionTimes.every5[0] == "On" && theMinutes % 5 === 0)
  391. returnValue= (voice) ? "minutes" : "every"; // every 5 minute alarm should sound
  392. else if (gOptionTimes.every10[0] == "On" && theMinutes % 10 === 0)
  393. returnValue= (voice) ? "minutes" : "every"; // every 10 minute alarm should sound
  394. else if (theHours===0 && theMinutes===1 && theSeconds===0 && gOptionTimes["1"][0] == "On")
  395. returnValue= (voice) ? "1minute" : "oneminute"; // 1 minute alarm should sound
  396. else if (theHours===0 && theMinutes===5 && theSeconds===0 && gOptionTimes["5"][0] == "On")
  397. returnValue= (voice) ? "minutes" : "fiveminute"; // 5 minute alarm should sound
  398. else if (theHours===0 && theMinutes===10 && theSeconds===0 && gOptionTimes["10"][0] == "On")
  399. returnValue= (voice) ? "minutes" : "tenminute"; // 10 minute alarm should sound
  400. else if (theHours===0 && theMinutes===20 && theSeconds===0 && gOptionTimes["20"][0] == "On")
  401. returnValue= (voice) ? "minutes" : "twentyminute"; // 20 minute alarm should sound
  402. else if (theHours===0 && theMinutes===30 && theSeconds===0 && gOptionTimes["30"][0] == "On")
  403. returnValue= (voice) ? "minutes" : "thirtyminute"; // 30 minute alarm should sound
  404. else if (theHours===1 && theMinutes===0 && theSeconds===0 && gOptionTimes["60"][0] == "On")
  405. returnValue= (voice) ? "hours" : "sixtyminute"; // 60 minute alarm should sound
  406. }
  407. }
  408. } else returnValue = (gOptions.firstSpeak[0]=="On") ? "full" : "";
  409. timerLeftAlarms.last = {"hours":theHours,"minutes":theMinutes,"seconds":theSeconds};
  410. return returnValue;
  411. }
  412. function sayTimeLeft(format) {
  413. var secondsLeft = timeLeft();
  414. var theHours = Math.floor(secondsLeft / 3600);
  415. var theMinutes = Math.floor( (secondsLeft - (theHours*3600)) / 60);
  416. var theSeconds = secondsLeft - (theHours*3600) - (theMinutes*60);
  417. if ( (thisFormat=timerLeftAlarms(theHours,theMinutes,theSeconds, (gOptions.alarm[0]=="On") ? false : true)) !== "") {
  418. if (thisFormat=="full") speakThisNow( "You have " + ((theHours>0) ? (theHours + ((theHours>1) ? (" Hours ") : " Hour ")) : "") +
  419. theMinutes + " Minutes" + theSeconds + " Seconds left",gOptions.voice[0]);
  420. else if (thisFormat=="minutes") speakThisNow( "You have " + ((theHours>0) ? (theHours + ((theHours>1) ? (" Hours ") : " Hour ")) : "") +
  421. theMinutes + ((theMinutes>1) ? " Minutes" : " Minute") + " Left",gOptions.voice[0]);
  422. else if (thisFormat=="seconds" || thisFormat=="1minute") speakThisNow( "You have " + theSeconds + " Seconds Left",gOptions.voice[0]);
  423. else {
  424. if (thisFormat=="30seconds") warning(g30SecondsLeft,"30s"); else if (thisFormat=="oneminute") warning(g1MinuteLeft,"1");
  425. else if (thisFormat=="fiveminute") warning(g5MinutesLeft,"5"); else if (thisFormat=="tenminute") warning(g10MinutesLeft,"10");
  426. else if (thisFormat=="twentyminute") warning(g20MinutesLeft,"20"); else if (thisFormat=="thirtyminute") warning(g30MinutesLeft,"30");
  427. else if (thisFormat=="sixtyminute") warning(g60MinutesLeft,"60"); else if (thisFormat=="every") warning(g10MinutesLeft,"10");
  428. }
  429. }
  430. if (gOptions.color[0] == "On") setColor(convertTimeToSeconds(theHours,theMinutes,theSeconds));
  431. else $("#MainContent").css("background-color","#FFFFFF");
  432. }
  433.  
  434. $(function() {
  435. if (window.location.href.indexOf("worker.mturk.com") != -1) {
  436. if('speechSynthesis' in window){
  437. gVoices = window.speechSynthesis.getVoices();
  438. window.speechSynthesis.onvoiceschanged = function() {
  439. gVoices = window.speechSynthesis.getVoices();
  440. };
  441. }
  442. gNewSite = true;
  443. loadSettings();
  444. setUpVoices();
  445. var newTimerNode = $(".completion-timer");
  446. if (newTimerNode.length && $(newTimerNode).closest("div").text().indexOf("Time Elapsed") != -1) {
  447. if ($(".checkbox.m-y-0").length) {
  448. createSpan("Timer Options").css({"box-sizing":"content-box","font-size":"10px","background-color":"#eeeeee", "border":"2px groove darkgrey", "padding":"0px 4px","margin-left":"5px" }).attr('id', "JRTimerOptions").disableSelection()
  449. .click(function() { toggleOptionsMenu(); }).appendTo($(".checkbox.m-y-0:first"));
  450. } else {
  451. buttonPosition = $(".col-md-6.col-xs-12:first").find(".col-sm-8.col-xs-7");
  452. createDiv("Timer Options").css({"box-sizing":"content-box","float":"left","font-size":"10px","background-color":"#eeeeee", "border":"2px groove darkgrey", "padding":"0px 2px" }).attr('id', "JRTimerOptions")
  453. .disableSelection().click(function() { toggleOptionsMenu(); }).appendTo(buttonPosition);
  454. }
  455. createDiv("").css({"position":"fixed","width":"700px","height":"200px","top":"78px","right":"280px","float":"right",
  456. "background-color":"#eceadf","border":"3px solid #000"}).attr({"id":"JR_TimerWOptionsMenu"}).hide().appendTo("body");
  457. setTimeout( function() {
  458. intervalVar = setInterval( function(){
  459. sayTimeLeft();
  460. }, 1000);
  461. }, 1300);
  462. showOptionsNew($("#JR_TimerWOptionsMenu"));
  463. }
  464. }
  465. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址