JR mturk timer warning

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

当前为 2014-12-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name JR mturk timer warning
  3. // @version 0.7.0
  4. // @namespace https://greasyfork.org/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. // @exclude *mturk.com/*HITMONITOR*
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // ==/UserScript==
  15.  
  16. // Warns you with a voice, alarm or colors on the amount of time left for the current hit. You can set your own options
  17. // in the menu at top. There is a male and female voice for the warning. You can turn off the warnings and color.
  18. // the options are saved so you don't have to set it again. You can stop it saving options for the current hit if
  19. // you just want changes for the hit you are on.
  20.  
  21. var gSeconds = 0, gElapsedSeconds = 0, gWorking = false, gDoNotSpeak = false, gVolume = 1;
  22. var gOptions = {"status":["On",0],"voice":["female",0],"alarm":["Off",0],"color":["On",0]};
  23. var gOptionTimes = {"60":["Off",0],"30":["On",0],"20":["Off",0],"10":["Off",0],"5":["On",0],"1":["On",0],"30s":["On",0]};
  24. var gWarningTimes = {"60":false,"30":false,"20":false,"10":false,"5":false,"1":false,"30s":false};
  25. 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"];
  26.  
  27. var f60MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%201%20hour%20left%20-%20Laura.mp3");
  28. var m60MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%201%20hour%20left%20-%20Paul.mp3");
  29. var a60MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%2060%20minutes%20left.mp3");
  30. var f30MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2030%20minutes%20left%20-%20laura.mp3");
  31. var m30MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2030%20minutes%20left%20-%20Paul.mp3");
  32. var a30MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%2030%20minutes%20left.mp3");
  33. var f20MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2020%20minutes%20left%20-%20laura.mp3");
  34. var m20MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2020%20minutes%20left%20-%20Paul.mp3");
  35. var a20MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%2020%20minutes%20left.mp3");
  36. var f10MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2010%20minutes%20left%20-%20Laura.mp3");
  37. var m10MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2010%20minutes%20left%20-%20Paul.mp3");
  38. var a10MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%2010%20minutes%20left.mp3");
  39. var f5MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%205%20minutes%20left%20-%20Laura.mp3");
  40. var m5MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%205%20minutes%20left%20-%20Paul.mp3");
  41. var a5MinutesLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%205%20minutes%20left.mp3");
  42. var f1MinuteLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%201%20minute%20left%20-%20Laura.mp3");
  43. var m1MinuteLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%201%20minute%20left%20-%20Paul.mp3");
  44. var a1MinuteLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%201%20minute%20left.mp3");
  45. var f30SecondsLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2030%20seconds%20left%20-%20Laura.mp3");
  46. var m30SecondsLeft = new Audio("http://www.allbyjohn.com/sounds/You%20have%20less%20than%2030%20seconds%20left%20-%20Paul.mp3");
  47. var a30SecondsLeft = new Audio("http://www.allbyjohn.com/sounds/Alarm%2030%20seconds%20left.mp3");
  48. var fTesting = new Audio("http://www.allbyjohn.com/sounds/This%20is%20just%20a%20test%20of%20this%20warning%20system%20-%20Laura.mp3");
  49. var mTesting = new Audio("http://www.allbyjohn.com/sounds/This%20is%20just%20a%20test%20of%20this%20warning%20system%20-%20Paul.mp3");
  50. var g60MinutesLeft = null, g30MinutesLeft = null, g20MinutesLeft = null, g10MinutesLeft = null, g5MinutesLeft = null, g1MinutesLeft = null,
  51. g30SecondsLeft = null, gTesting = null;
  52.  
  53. function loadSettings() {
  54. gOptions = JSON.parse(GM_getValue("JR_WN_options",JSON.stringify(gOptions)));
  55. gOptionTimes = JSON.parse(GM_getValue("JR_WN_optionTimes",JSON.stringify(gOptionTimes)));
  56. }
  57. function saveSettings() {
  58. GM_setValue("JR_WN_options",JSON.stringify(gOptions));
  59. GM_setValue("JR_WN_optionTimes",JSON.stringify(gOptionTimes));
  60. }
  61. function pad(number, length) {
  62. var str = '' + number;
  63. while (str.length < length) {
  64. str = '&nbsp;' + str;
  65. }
  66. return str;
  67. }
  68. function createMyElement(elementName,theClass,theId,theStyle,theText) {
  69. var theElement = document.createElement(elementName);
  70. if (theClass) theElement.className = theClass;
  71. if (theId) theElement.id = theId;
  72. if (theStyle) theElement.setAttribute("style",theStyle);
  73. if (theText) theElement.innerHTML = theText;
  74. return theElement;
  75. }
  76. function createButton(theClass,theId,theValue,theName,theStyle) {
  77. var theButton = createMyElement("input",theClass,theId,theStyle);
  78. theButton.type = "button";
  79. if (theValue) theButton.value = theValue;
  80. if (theName) theButton.name = theName;
  81. return theButton;
  82. }
  83. function createCheckbox(theClass,theId,theValue,theName,theStyle) {
  84. var theCheckbox = createMyElement("input",theClass,theId,theStyle);
  85. theCheckbox.value = theValue;
  86. theCheckbox.type = "checkbox";
  87. if (theName) theCheckbox.name = theName;
  88. return theCheckbox;
  89. }
  90. function createTextInput(theClass,theId,theValue,theName,theStyle) {
  91. var theInput = createMyElement("input",theClass,theId,theStyle);
  92. theInput.type = "text";
  93. if (theValue) theInput.value = theValue;
  94. if (theName) theInput.name = theName;
  95. return theInput;
  96. }
  97. function setUpVoices(gender) {
  98. if (gender == "Female") {
  99. g60MinutesLeft = f60MinutesLeft; g30MinutesLeft = f30MinutesLeft; g20MinutesLeft = f20MinutesLeft; g10MinutesLeft = f10MinutesLeft;
  100. g5MinutesLeft = f5MinutesLeft; g1MinuteLeft = f1MinuteLeft; g30SecondsLeft = f30SecondsLeft; gTesting = fTesting;
  101. } else if (gender == "Male") {
  102. g60MinutesLeft = m60MinutesLeft; g30MinutesLeft = m30MinutesLeft; g20MinutesLeft = m20MinutesLeft; g10MinutesLeft = m10MinutesLeft;
  103. g5MinutesLeft = m5MinutesLeft; g1MinuteLeft = m1MinuteLeft; g30SecondsLeft = m30SecondsLeft; gTesting = mTesting;
  104. } else {
  105. g60MinutesLeft = a60MinutesLeft; g30MinutesLeft = a30MinutesLeft; g20MinutesLeft = a20MinutesLeft; g10MinutesLeft = a10MinutesLeft;
  106. g5MinutesLeft = a5MinutesLeft; g1MinuteLeft = a1MinuteLeft; g30SecondsLeft = a30SecondsLeft; gTesting = a30SecondsLeft;
  107. }
  108. }
  109. function setColor(theTimeLeft) {
  110. var theColor = "FFFFFF";
  111. if (theTimeLeft<30) theColor = gHtmlColors[0]; // less than 30 seconds
  112. else if (theTimeLeft<60) theColor = gHtmlColors[1]; // less than 1 minute
  113. else if (theTimeLeft<600) {
  114. theColor = gHtmlColors[Math.ceil(theTimeLeft/60)]; // less than 10 minutes
  115. }
  116. else if (theTimeLeft<1200) {
  117. theColor = gHtmlColors[Math.ceil((theTimeLeft-600)/120)+10]; // less than 20 minutes
  118. }
  119. else if (theTimeLeft<1800) {
  120. theColor = gHtmlColors[Math.ceil((theTimeLeft-1200)/240)+15]; // less than 30 minutes
  121. }
  122. else if (theTimeLeft<2100) theColor = gHtmlColors[20];
  123. else if (theTimeLeft<2400) theColor = gHtmlColors[21];
  124. else if (theTimeLeft<3000) theColor = gHtmlColors[22];
  125. else if (theTimeLeft<2600) theColor = gHtmlColors[23];
  126.  
  127. document.getElementsByTagName("form")[1].style.backgroundColor = "#"+theColor;
  128. }
  129. function timeLeft() {
  130. theTime = document.getElementById("theTime");
  131. if (theTime) {
  132. var theSplit = theTime.innerHTML.split(":");
  133. hours = parseInt(theSplit[0]);
  134. minutes = parseInt(theSplit[1]);
  135. seconds = parseInt(theSplit[2]);
  136. minutes += hours * 60;
  137. gElapsedSeconds = seconds + (minutes * 60);
  138. var timeLeftMinutes = Math.floor(gSeconds/60) - minutes - 1;
  139. document.getElementById("timeLeftDiv").innerHTML = "Time Left: " + timeLeftMinutes + " Minutes : " + (60-seconds) + " Seconds";
  140. return gSeconds - gElapsedSeconds;
  141. } else return null;
  142. }
  143. function warning(theSound,theTime) {
  144. theSound.volume = gVolume;
  145. theSound.play();
  146. gWarningTimes[theTime] = true;
  147. }
  148. function checkTimes(announceNow) {
  149. var timeLeftSeconds = timeLeft();
  150. var timeLeftMinutes = Math.floor(timeLeftSeconds/60);
  151.  
  152.  
  153. if (timeLeftSeconds) {
  154. if (timeLeftSeconds<=30) {
  155. if (gOptionTimes["30s"][0] == "On" && !gWarningTimes["30s"]) warning(g30SecondsLeft,"30s");
  156. } else if (timeLeftSeconds<=60) {
  157. if (gOptionTimes["1"][0] == "On" && !gWarningTimes["1"]) warning(g1MinuteLeft,"1");
  158. } else if (timeLeftMinutes<5 && (timeLeftMinutes>3 || announceNow)) {
  159. if (gOptionTimes["5"][0] == "On" && (!gWarningTimes["5"] || announceNow))
  160. if (gElapsedSeconds>185 || announceNow) warning(g5MinutesLeft,"5");
  161. } else if (timeLeftMinutes<10 && (timeLeftMinutes>7 || announceNow)) {
  162. if (gOptionTimes["10"][0] == "On" && (!gWarningTimes["10"] || announceNow))
  163. if (gElapsedSeconds>185 || announceNow) warning(g10MinutesLeft,"10");
  164.  
  165. } else if (timeLeftMinutes<20 && (timeLeftMinutes>15 || announceNow)) {
  166. if (gOptionTimes["20"][0] == "On" && (!gWarningTimes["20"] || announceNow))
  167. if (gElapsedSeconds>305 || announceNow) warning(g20MinutesLeft,"20");
  168. } else if (timeLeftMinutes<30 && (timeLeftMinutes>24 || announceNow)) {
  169. if (gOptionTimes["30"][0] == "On" && (!gWarningTimes["30"] || announceNow))
  170. if (gElapsedSeconds>365 || announceNow) warning(g30MinutesLeft,"30");
  171. } else if (timeLeftMinutes<60 && (timeLeftMinutes>53 || announceNow)) {
  172. if (gOptionTimes["60"][0] == "On" && (!gWarningTimes["60"] || announceNow))
  173. if (gElapsedSeconds>425 || announceNow) warning(g60MinutesLeft,"60");
  174. }
  175. if (gOptions.color[0] == "On") setColor(timeLeftSeconds);
  176. else document.getElementsByTagName("form")[1].style.backgroundColor = "#FFFFFF";
  177. }
  178. }
  179. function setOptions() {
  180. gOptions.status[0] = document.getElementById("warningOption").getAttribute("currentValue");
  181. gOptions.status[1] = document.getElementById("warningOption").getAttribute("valueIndex");
  182. gOptions.voice[0] = document.getElementById("warningVoiceOptions").getAttribute("currentValue");
  183. gOptions.voice[1] = document.getElementById("warningVoiceOptions").getAttribute("valueIndex");
  184. gOptions.alarm[0] = document.getElementById("warningAlarmOptions").getAttribute("currentValue");
  185. gOptions.alarm[1] = document.getElementById("warningAlarmOptions").getAttribute("valueIndex");
  186. gOptions.color[0] = document.getElementById("warningColorOptions").getAttribute("currentValue");
  187. gOptions.color[1] = document.getElementById("warningColorOptions").getAttribute("valueIndex");
  188. gOptionTimes["60"][0] = document.getElementById("1HourOptions").getAttribute("currentValue");
  189. gOptionTimes["60"][1] = document.getElementById("1HourOptions").getAttribute("valueIndex");
  190. gOptionTimes["30"][0] = document.getElementById("30MinutesOptions").getAttribute("currentValue");
  191. gOptionTimes["30"][1] = document.getElementById("30MinutesOptions").getAttribute("valueIndex");
  192. gOptionTimes["20"][0] = document.getElementById("20MinutesOptions").getAttribute("currentValue");
  193. gOptionTimes["20"][1] = document.getElementById("20MinutesOptions").getAttribute("valueIndex");
  194. gOptionTimes["10"][0] = document.getElementById("10MinutesOptions").getAttribute("currentValue");
  195. gOptionTimes["10"][1] = document.getElementById("10MinutesOptions").getAttribute("valueIndex");
  196. gOptionTimes["5"][0] = document.getElementById("5MinutesOptions").getAttribute("currentValue");
  197. gOptionTimes["5"][1] = document.getElementById("5MinutesOptions").getAttribute("valueIndex");
  198. gOptionTimes["1"][0] = document.getElementById("1MinuteOptions").getAttribute("currentValue");
  199. gOptionTimes["1"][1] = document.getElementById("1MinuteOptions").getAttribute("valueIndex");
  200. gOptionTimes["30s"][0] = document.getElementById("30SecondsOptions").getAttribute("currentValue");
  201. gOptionTimes["30s"][1] = document.getElementById("30SecondsOptions").getAttribute("valueIndex");
  202. if (gOptions.voice[0] != "Off") setUpVoices(gOptions.voice[0]);
  203. else if (gOptions.alarm[0] != "Off") setUpVoices();
  204. if (gWorking) {
  205. if (gOptions.color[0] == "On" && gOptions.status[0] == "On") setColor(timeLeft());
  206. else document.getElementsByTagName("form")[1].style.backgroundColor = "#FFFFFF";
  207. if (!gDoNotSpeak && gOptions.status[0] == "On" && (gOptions.voice[0] != "Off" || gOptions.alarm[0] != "Off")) checkTimes(true);
  208. } else if (gOptions.status[0] == "On" && (gOptions.voice[0] != "Off" || gOptions.alarm[0] != "Off") && !gDoNotSpeak) gTesting.play();
  209. if (document.getElementById("warningOptionsSave").checked) saveSettings();
  210. }
  211. function createSpanOptions(theNode,theOptions) {
  212. var theId = "", theText = "", theValues = [], theStatus = "", replaceWith="";
  213. for (var i=0,len=theOptions.length; i<len; i++) {
  214. theId = theOptions[i][0];
  215. theText = theOptions[i][1];
  216. theValues = theOptions[i][2];
  217. theStatus = theValues[theOptions[i][3]].substr(0,1);
  218. replaceWith = theValues[theOptions[i][3]].replace(theStatus,"");
  219. theOption = createMyElement("span","myOwnSpan",theId,
  220. "cursor:pointer; -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;",
  221. theText.replace("$",replaceWith));
  222. if (theStatus=="-") theOption.style.color = "#FF0000";
  223. else theOption.style.color = "#006600";
  224. theOption.setAttribute("theValues",JSON.stringify(theValues));
  225. theOption.setAttribute("valueIndex",theOptions[i][3]);
  226. theOption.setAttribute("theText",theText);
  227. theOption.setAttribute("currentValue",replaceWith);
  228. theNode.appendChild(document.createTextNode(" "));
  229. theNode.appendChild(theOption);
  230. theOption.onmousemove = function() {
  231. e.preventDefault();
  232. e.stopPropagation();
  233. return false;
  234. }
  235. theOption.onclick = function() {
  236. gDoNotSpeak = false;
  237. var theValues = JSON.parse(this.getAttribute("theValues"));
  238. var theIndex = parseInt(this.getAttribute("valueIndex"));
  239. var theText = this.getAttribute("theText");
  240. theIndex = (theIndex < theValues.length-1) ? theIndex+1 : 0;
  241. this.setAttribute("valueIndex",theIndex);
  242. var theStatus = theValues[theIndex].substr(0,1);
  243. var replaceWith = theValues[theIndex].replace(theStatus,"");
  244. this.innerHTML = theText.replace("$",replaceWith);
  245. this.setAttribute("currentValue",replaceWith);
  246. if (theStatus=="-") this.style.color = "#FF0000";
  247. else this.style.color = "#006600";
  248. if (this.id == "warningAlarmOptions" && replaceWith == "On") {
  249. document.getElementById("warningVoiceOptions").setAttribute("currentValue","Off");
  250. document.getElementById("warningVoiceOptions").setAttribute("valueIndex","1");
  251. document.getElementById("warningVoiceOptions").innerHTML = "[ Voice: Off ]";
  252. document.getElementById("warningVoiceOptions").style.color = "#FF0000";
  253. } else if (this.id == "warningVoiceOptions" && replaceWith != "Off") {
  254. document.getElementById("warningAlarmOptions").setAttribute("currentValue","Off");
  255. document.getElementById("warningAlarmOptions").setAttribute("valueIndex","0");
  256. document.getElementById("warningAlarmOptions").innerHTML = "[ Alarm: Off ]";
  257. document.getElementById("warningAlarmOptions").style.color = "#FF0000";
  258. } else if (this.id == "warningOption" && replaceWith == "Off") {
  259. gDoNotSpeak = true;
  260. } else if (this.id == "warningColorOptions") gDoNotSpeak = true;
  261. setOptions();
  262. };
  263. }
  264. }
  265. function showOptions(beforeNode) {
  266. window.addEventListener("load", function(){
  267. var theOptionsContainer = createMyElement("div","myOwnDiv","warningOptionsContainer",
  268. "background-color:#D8FCFB; text-align:center; margin:0 auto; padding: 0; width:80%; border: 2px solid black;");
  269. var theOptionsToggle = createMyElement("div","myOwnDiv","warningOptionsToggle","margin:0; padding:0 0 2px 0; background-color:#696969; color: Aqua; font-size:10px; cursor:default;",
  270. "Click here for Time Left Warning options.");
  271. var theOptionsControl = createMyElement("div","myOwnDiv","warningOptionsController","display:none;");
  272. var theOptionsSave = createCheckbox("myOwnCheckBox","warningOptionsSave","save Me","","margin-left:20px; height:10px;");
  273. theOptionsSave.checked = true;
  274. theOptionsSave.onclick = function() { if (theOptionsSave.checked) saveSettings(); }
  275. var spanWarningOptions = [ ["warningOption","[ Status: $ ]",["+On","-Off"],gOptions.status[1]], ["warningVoiceOptions","[ Voice: $ ]",["+Female","-Off","+Male"],gOptions.voice[1]],
  276. ["warningAlarmOptions","[ Alarm: $ ]",["-Off","+On"],gOptions.alarm[1]], ["warningColorOptions","[ Color: $ ]",["+On","-Off"],gOptions.color[1]]];
  277. theOptionsControl.appendChild(document.createTextNode("Time Left Warning:"));
  278. createSpanOptions(theOptionsControl,spanWarningOptions);
  279. theOptionsControl.appendChild(theOptionsSave);
  280. theOptionsControl.appendChild(document.createTextNode(" Save Options"));
  281. theOptionsControl.appendChild(createMyElement("br"));
  282. theOptionsControl.appendChild(document.createTextNode("Warn at: "));
  283. var spanTimeOptions = [ ["30SecondsOptions","[30 seconds]",["+On","-Off"],gOptionTimes["30s"][1]], ["1MinuteOptions","[1 minute]",["+On","-Off"],gOptionTimes["1"][1]],
  284. ["5MinutesOptions","[5 minutes]",["+On","-Off"],gOptionTimes["5"][1]], ["10MinutesOptions","[10 minutes]",["-Off","+On"],gOptionTimes["10"][1]],
  285. ["20MinutesOptions","[20 minutes]",["-Off","+On"],gOptionTimes["20"][1]], ["30MinutesOptions","[30 minutes]",["+On","-Off"],gOptionTimes["30"][1]],
  286. ["1HourOptions","[1 hour]",["-Off","+On"],gOptionTimes["60"][1]]];
  287. createSpanOptions(theOptionsControl,spanTimeOptions);
  288. theOptionsControl.appendChild(createMyElement("br"));
  289. theOptionsControl.appendChild(document.createTextNode("Click on text above to change options."));
  290. var volumeLower = createMyElement("span","myOwnSpan","lowerVolumeControl",
  291. "cursor: pointer; margin-left:20px; -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;","<-");
  292. theOptionsControl.appendChild(volumeLower);
  293. var volumeLevelText = createMyElement("span","myOwnSpan","theVolumeText",
  294. "cursor:pointer; display: inline-block; width:110px; -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;",
  295. " Volume Level: 100 ");
  296. theOptionsControl.appendChild(volumeLevelText);
  297. var volumeHigher = createMyElement("span","myOwnSpan","lowerVolumeControl",
  298. "cursor: pointer; -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;","->");
  299. theOptionsControl.appendChild(volumeHigher);
  300. volumeLower.onclick = function() {
  301. gVolume = (gVolume<0.1) ? 0 : (gVolume-0.1);
  302. document.getElementById("theVolumeText").innerHTML = " Volume Level: " + pad(Math.round(gVolume*100),3);
  303. }
  304. volumeHigher.onclick = function() {
  305. gVolume = (gVolume>0.9) ? 1 : (gVolume+0.1);
  306. document.getElementById("theVolumeText").innerHTML = " Volume Level: " + pad(Math.round(gVolume*100),3);
  307. }
  308. theOptionsToggle.onclick = function() {
  309. var theDisplay = theOptionsControl.style.display;
  310. theOptionsControl.style.display = (theDisplay == "none") ? "block" : "none";
  311. if (theOptionsControl.style.display == "none") this.innerHTML = "Click here for Time Left Warning options menu.";
  312. else this.innerHTML = "Click here to hide the options menu";
  313. }
  314. theOptionsContainer.appendChild(theOptionsToggle);
  315. theOptionsContainer.appendChild(theOptionsControl);
  316. beforeNode.parentNode.insertBefore(theOptionsContainer,beforeNode);
  317. }, false);
  318. }
  319.  
  320. loadSettings();
  321. setUpVoices(gOptions.voice[0]);
  322. var timerTextNode = document.getElementsByClassName("title_orange_text")[0];
  323. if (timerTextNode && timerTextNode.innerHTML.indexOf("Timer:") != -1) {
  324. gWorking = true;
  325. var weeks = 0, days = 0, hours = 0, minutes = 0;
  326. var theTime = document.getElementById("theTime");
  327. var timeLeftNode = createMyElement("div","myOwnDiv","timeLeftDiv","padding-left:20px");
  328. theTime.parentNode.parentNode.parentNode.appendChild(timeLeftNode);
  329. var ofTime = timerTextNode.innerHTML.split("</span>")[1];
  330. var ofTime = ofTime.split("<noscript>")[0].replace(/\s\s+/g," ").trim();
  331. var theSplit = ofTime.replace("of ","").split(" ");
  332. if (theSplit.length > 0) {
  333. if (theSplit > 2) {
  334. if (theSplit[3].indexOf("week") != -1) weeks = parseInt(theSplit[2]);
  335. else if (theSplit[3].indexOf("day") != -1) days = parseInt(theSplit[2]);
  336. else if (theSplit[3].indexOf("hour") != -1) hours = parseInt(theSplit[2]);
  337. }
  338. days += weeks * 7;
  339. hours += days * 24;
  340. if (theSplit[1].indexOf("day") != -1) days += parseInt(theSplit[0]);
  341. else if (theSplit[1].indexOf("hour") != -1) hours += parseInt(theSplit[0]);
  342. else if (theSplit[1].indexOf("minute") != -1) minutes = parseInt(theSplit[0]);
  343. else if (theSplit[1].indexOf("second") != -1) gSeconds = parseInt(theSplit[0]);
  344. hours += days * 24;
  345. minutes += hours * 60;
  346. gSeconds += minutes * 60;
  347. var intervalVar = setInterval( function(){
  348. if (gOptions.status[0] == "On" && (gOptions.voice[0] != "Off" || gOptions.alarm[0] != "Off")) checkTimes();
  349. else if (gOptions.status[0] == "On") timeLeft();
  350. }, 4000);
  351. var theHitForm = document.getElementsByTagName("form")[1];
  352. var theTable = theHitForm.getElementsByTagName("table")[0];
  353. var theDiv = theHitForm.getElementsByTagName("div")[2];
  354. var theIframe = theHitForm.getElementsByTagName("iframe")[0];
  355. theTable.style.backgroundColor = "#FFFFFF";
  356. theDiv.style.backgroundColor = "#FFFFFF";
  357. theIframe.style.backgroundColor = "#FFFFFF";
  358. showOptions(theHitForm);
  359. if (gOptions.color[0] == "On" && gOptions.status[0] == "On") setColor(timeLeft());
  360. else document.getElementsByTagName("form")[1].style.backgroundColor = "#FFFFFF";
  361. }
  362. } else {
  363. var theAlertBox = document.getElementById("alertBox");
  364. var theErrorTitle = document.getElementsByClassName("error_title")[0];
  365. var beforeNode = (theErrorTitle) ? theErrorTitle.parentNode.parentNode.parentNode : (theAlertBox) ? theAlertBox : timerTextNode.parentNode.parentNode.parentNode;
  366. showOptions(beforeNode);
  367. }