Mturk Logout Time

This will show your estimated auto logout time and display a warning when the time drops below 30 minutes.

目前为 2014-07-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Mturk Logout Time
  3. // @version 0.1
  4. // @author Cristo
  5. // @description This will show your estimated auto logout time and display a warning when the time drops below 30 minutes.
  6. // @description Click on the "HITs available now" area on the top to show time remaining until logout. Format is in a "hours:minutes" countdown.
  7. // @description The top border changes green when time is below 30 minutes, yellow for 15 minutes and red for 5 minutes.
  8. // @description Timing is based off Amazon's word that logouts are every 12 hours. Results may vary.
  9. // @include https://www.mturk.com/mturk*
  10. // @include https://www.amazon.com/ap/signin?o*
  11. // @copyright 2012+, You
  12. // @namespace https://greasyfork.org/users/1973
  13. // ==/UserScript==
  14.  
  15. if (document.getElementById("subtabs_and_searchbar")) {
  16. var number = timeMachine().replace(":","");
  17. var topBar = document.getElementById("subtabs_and_searchbar");
  18. if (number <= 5){
  19. topBar.style.cssText = "border-top:#F03C0F 10px solid";
  20. } else if (number <= 15) {
  21. topBar.style.cssText = "border-top:#D8F029 10px solid";
  22. } else if (number <= 30) {
  23. topBar.style.cssText = "border-top:#1BDA13 10px solid";
  24. }}
  25. if (document.getElementById("ap_header")) {
  26. var but = document.getElementById("signInSubmit-input");
  27. but.addEventListener( "click", function () {
  28. GM_setValue("timeoflog", new Date().getTime());
  29. } , false );}
  30. function timeMachine() {
  31. var now = new Date().getTime();
  32. var then = GM_getValue("timeoflog");
  33. var since = now - then;
  34. var timeRem = 4.32e+7 - since;
  35. var rawMins = Math.ceil(timeRem/60000);
  36. var hours = Math.floor(rawMins/60);
  37. var baseMins = rawMins%60;
  38. var redunMins = baseMins.toString();
  39. var mins;
  40. if (redunMins.length < 2){
  41. mins = "0" + redunMins;
  42. } else {
  43. mins = redunMins;
  44. }
  45. var results = hours + ":" + mins;
  46. return results;
  47. }
  48. if (document.getElementsByTagName("td")[7]) {
  49. var handle = document.getElementsByTagName("td")[7];
  50. handle.addEventListener( "click", function () {
  51. var time = timeMachine();
  52. var spany = handle.getElementsByTagName("span")[0];
  53. var bany = handle.getElementsByTagName("b")[0];
  54. var parts = spany.innerHTML.substring(75,88);
  55. bany.innerHTML = time;
  56. bany.style.textAlign = "center";
  57. if (spany.innerHTML.indexOf("Until") == -1){
  58. spany.innerHTML = spany.innerHTML.replace(parts, "Until Logout");
  59. }
  60. spany.style.textAlign = "center";
  61. } , false );}