Memrise Timer Controls

Adds buttons that let you configure the timing of watering sessions

  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. // @namespace https://gf.qytechs.cn/users/5238-carpiediem
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // ==/UserScript==
  12.  
  13. oldstart = MEMRISE.garden.feedback.start;
  14.  
  15. function setCountdown(currentSetting) {
  16. GM_setValue("timer", currentSetting);
  17. switch (currentSetting) {
  18. case "normal":
  19. //Change button color & tooltip
  20. $('#timerToggle').css('background-color',"green").attr("title","Answer timer is set to normal.\nClick to slow the timer.");
  21. //Change website functionality
  22. MEMRISE.garden.timer.paused = false;
  23. MEMRISE.garden.timer.unpause();
  24. break;
  25. case "slow":
  26. //Change button color & tooltip
  27. $('#timerToggle').css("background-color","yellow").attr("title","Answer timer is set to slow.\nClick to disable the timer.");
  28. //Change website functionality
  29. MEMRISE.garden.timer.activate = function (a,b){
  30. MEMRISE.garden.timer.cancel();
  31. MEMRISE.garden.timer.active=true;
  32. MEMRISE.garden.timer.howlong=3*a;
  33. MEMRISE.garden.timer.time_remaining=3*a;
  34. if(b) {MEMRISE.garden.timer.callback=b;}
  35. MEMRISE.garden.timer.draw();
  36. MEMRISE.garden.$centralarea.imagesLoaded(function(){MEMRISE.garden.timer.start();});
  37. };
  38. MEMRISE.garden.timer.activate(MEMRISE.garden.timer.howlong);
  39. break;
  40.  
  41. case "disabled":
  42. //Change button color & tooltip
  43. $('#timerToggle').css('background-color',"red").attr("title","Answer timer is disabled.\nClick to enable the timer.");
  44. //Change website functionality
  45. MEMRISE.garden.timer.activate = function (a,b){
  46. MEMRISE.garden.timer.cancel();
  47. MEMRISE.garden.timer.active=true;
  48. MEMRISE.garden.timer.howlong=a;
  49. MEMRISE.garden.timer.time_remaining=a;
  50. if(b) {MEMRISE.garden.timer.callback=b;}
  51. MEMRISE.garden.timer.draw();
  52. MEMRISE.garden.$centralarea.imagesLoaded(function(){MEMRISE.garden.timer.start();});
  53. };
  54. MEMRISE.garden.timer.activate(MEMRISE.garden.timer.howlong/3);
  55. MEMRISE.garden.timer.paused = true;
  56. break;
  57. }
  58. }
  59. function setDelay(currentSetting) {
  60. GM_setValue("delay", currentSetting);
  61. if (currentSetting) {
  62. //Change button color & tooltip
  63. $('#delayToggle').css('background-color',"green").attr("title","Delay between questions is set to normal.\nClick to eliminate the delay.");
  64. //Enable the delay
  65. MEMRISE.garden.feedback.start = function (a){ oldstart(a); };
  66. }else{
  67. //Change button color & tooltip
  68. $('#delayToggle').css('background-color',"red").attr("title","No time between questions.\nClick to add a delay.");
  69. //Disable the delay
  70. MEMRISE.garden.feedback.start = function (a){ MEMRISE.garden.box.next_press(); };
  71. }
  72. }
  73.  
  74. //Create buttons
  75. $( '<div id="timerControls"><div id="timerToggle"></div><div id="delayToggle"></div></div>' ).insertBefore( ".streak" );
  76. $('#timerControls').css('width','100px');
  77. $('#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.");
  78. $('#timerToggle').css({float:'left', 'background-position':'32px 0px'});
  79. $('#delayToggle').css({float:'right','background-position':'0px 0px' });
  80.  
  81. //Check to see the previous setting
  82. var timerSetting = GM_getValue("timer", "normal");
  83. var delayEnabled = GM_getValue("delay", true);
  84.  
  85. setCountdown(timerSetting);
  86. setDelay(delayEnabled);
  87.  
  88. $('#timerToggle').click(function() {
  89. switch (timerSetting) {
  90. case "normal": timerSetting = "slow"; break;
  91. case "slow": timerSetting = "disabled"; break;
  92. case "disabled": timerSetting = "normal"; break;
  93. }
  94. setCountdown(timerSetting);
  95. });
  96.  
  97. $('#delayToggle').click(function() {
  98. delayEnabled = !delayEnabled;
  99. setDelay(delayEnabled);
  100. });

QingJ © 2025

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