Last active
June 28, 2017 18:09
-
-
Save AntonioRigo/fae2536dbf5b7626c509102b2226353c to your computer and use it in GitHub Desktop.
Ads a toggle in memrise.com to control the timer. You can click on the timer to pause/unpause the timer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Memrise Timer Toggle | |
// @description Ads a toggle to control the timer. You can click on the timer to pause/unpause the timer. | |
// @match https://www.memrise.com/course/*/garden/* | |
// @match https://www.memrise.com/garden/water/* | |
// @match https://www.memrise.com/garden/review/* | |
// @version 0.1.2 | |
// @grant none | |
// @namespace https://gist.github.com/AntonioRigo/fae2536dbf5b7626c509102b2226353c | |
// @updateURL https://gist.github.com/AntonioRigo/fae2536dbf5b7626c509102b2226353c/raw/7e830938f94e4c4370e2e69c9f4a2142f008761e/memrise-timer-toggle.user.js | |
// @downloadURL https://gist.github.com/AntonioRigo/fae2536dbf5b7626c509102b2226353c/raw/7e830938f94e4c4370e2e69c9f4a2142f008761e/memrise-timer-toggle.user.js | |
// ==/UserScript== | |
var onLoad = function($) { | |
$("#left-area").append( `<p id="timer-switch">Pause timer</p>` ); | |
document.getElementById("right-area").addEventListener ( | |
"click", ToggleTimer, false | |
); | |
document.getElementById("timer-switch").addEventListener ( | |
"click", ToggleTimer, false | |
); | |
function ToggleTimer (zEvent) { | |
if (MEMRISE.garden.timer.paused) { | |
MEMRISE.garden.timer.unpause(); | |
document.getElementById("timer-switch").innerHTML='Pause timer'; | |
console.log('unpaused'); | |
} else { | |
MEMRISE.garden.timer.pause(); | |
document.getElementById("timer-switch").innerHTML='Unpause timer'; | |
console.log('paused'); | |
} | |
} | |
}; | |
var injectWithJQ = function(f) { | |
var script = document.createElement('script'); | |
script.textContent = '$(' + f.toString() + '($));'; | |
document.body.appendChild(script); | |
}; | |
injectWithJQ(onLoad); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment