Memrise Timer Controls

Adds buttons that let you configure the timing of watering sessions

目前为 2014-09-11 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Memrise Timer Controls
  3. // @description Adds buttons that let you configure the timing of watering sessions
  4. // @match http://www.memrise.com/course/*/garden/*
  5. // @match http://www.memrise.com/garden/water/*
  6. // @version 1
  7. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // @namespace https://gf.qytechs.cn/users/5238
  11. // ==/UserScript==
  12.  
  13. //unsafeWindow.watch("MEMRISE", watchLocation);
  14. // Do this at some point: http://www.memrise.com/thread/1305495/
  15.  
  16. oldstart = MEMRISE.garden.feedback.start;
  17.  
  18. function setCountdown(currentSetting) {
  19. GM_setValue("timer", currentSetting);
  20. switch (currentSetting) {
  21. case "normal":
  22. //Change button color & tooltip
  23. $('#timerToggle').css('background-color',"green").attr("title","Answer timer is set to normal.\nClick to slow the timer.");
  24. //Change website functionality
  25. MEMRISE.garden.timer.paused = false;
  26. MEMRISE.garden.timer.unpause();
  27. break;
  28. case "slow":
  29. //Change button color & tooltip
  30. $('#timerToggle').css("background-color","yellow").attr("title","Answer timer is set to slow.\nClick to disable the timer.");
  31. //Change website functionality
  32. MEMRISE.garden.timer.activate = function (a,b){
  33. MEMRISE.garden.timer.cancel();
  34. MEMRISE.garden.timer.active=true;
  35. MEMRISE.garden.timer.howlong=3*a;
  36. MEMRISE.garden.timer.time_remaining=3*a;
  37. if(b) {MEMRISE.garden.timer.callback=b;}
  38. MEMRISE.garden.timer.draw();
  39. MEMRISE.garden.$centralarea.imagesLoaded(function(){MEMRISE.garden.timer.start();});
  40. };
  41. MEMRISE.garden.timer.activate(MEMRISE.garden.timer.howlong);
  42. break;
  43.  
  44. case "disabled":
  45. //Change button color & tooltip
  46. $('#timerToggle').css('background-color',"red").attr("title","Answer timer is disabled.\nClick to enable the timer.");
  47. //Change website functionality
  48. MEMRISE.garden.timer.activate = function (a,b){
  49. MEMRISE.garden.timer.cancel();
  50. MEMRISE.garden.timer.active=true;
  51. MEMRISE.garden.timer.howlong=a;
  52. MEMRISE.garden.timer.time_remaining=a;
  53. if(b) {MEMRISE.garden.timer.callback=b;}
  54. MEMRISE.garden.timer.draw();
  55. MEMRISE.garden.$centralarea.imagesLoaded(function(){MEMRISE.garden.timer.start();});
  56. };
  57. MEMRISE.garden.timer.activate(MEMRISE.garden.timer.howlong/3);
  58. MEMRISE.garden.timer.paused = true;
  59. break;
  60. }
  61. }
  62. function setDelay(currentSetting) {
  63. GM_setValue("delay", currentSetting);
  64. if (currentSetting) {
  65. //Change button color & tooltip
  66. $('#delayToggle').css('background-color',"green").attr("title","Delay between questions is set to normal.\nClick to eliminate the delay.");
  67. //Enable the delay
  68. MEMRISE.garden.feedback.start = function (a){ oldstart(a); };
  69. }else{
  70. //Change button color & tooltip
  71. $('#delayToggle').css('background-color',"red").attr("title","No time between questions.\nClick to add a delay.");
  72. //Disable the delay
  73. MEMRISE.garden.feedback.start = function (a){ MEMRISE.garden.box.next_press(); };
  74. }
  75. }
  76.  
  77. //Create buttons
  78. $( '<div id="timerControls"><div id="timerToggle"></div><div id="delayToggle"></div></div>' ).insertBefore( ".streak" );
  79. $('#timerControls').css('width','100px');
  80. $('#timerControls div').css({width:'32px',height:'32px',margin:'8px',"background-image":"url('http://www.rslc.us/images/timer-controls.png')",'background-color':'grey'}).attr("title","The timer control script did not load correctly.");
  81. $('#timerToggle').css({float:'left', 'background-position':'32px 0px'});
  82. $('#delayToggle').css({float:'right','background-position':'0px 0px' });
  83.  
  84. //Check to see the previous setting
  85. var timerSetting = GM_getValue("timer", "normal");
  86. var delayEnabled = GM_getValue("delay", true);
  87.  
  88. setCountdown(timerSetting);
  89. setDelay(delayEnabled);
  90.  
  91. $('#timerToggle').click(function() {
  92. switch (timerSetting) {
  93. case "normal": timerSetting = "slow"; break;
  94. case "slow": timerSetting = "disabled"; break;
  95. case "disabled": timerSetting = "normal"; break;
  96. }
  97. setCountdown(timerSetting);
  98. });
  99.  
  100. $('#delayToggle').click(function() {
  101. delayEnabled = !delayEnabled;
  102. setDelay(delayEnabled);
  103. });

QingJ © 2025

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