NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Stoppuhr // @namespace ... // @version 0.1 // @description Stoppuhr mit Start- und Stoppbutton // @author S.K. // @grant none // ==/UserScript== var sScript = ` var c = 0; var t; var timer_is_on = 0; function timedCount() { document.getElementById('txt').value = c; c = c + 1; t = setTimeout(function(){timedCount()}, 1000); } function fn_starte_Countdown() { if ( !timer_is_on ) { timer_is_on = 1; timedCount(); } } function fn_stoppe_Countdown() { clearTimeout(t); timer_is_on = 0; } `; var sHTML = ` <form> <input type="button" value="starte Countdown" onclick="fn_starte_Countdown()" /> <input type="text" id="txt" /> <input type="button" value="stoppe Countdown" onclick="fn_stoppe_Countdown()" /> </form> <p> Zum starten des Countdowns, auf den Button 'starte Countdown' klicken. <br> Zum stoppen des Countdowns, auf den Button 'stoppe Countdown' klicken. <br> Der Countdown beginnt bei 0 und erhöht sich jede Sekunde um 1. </p> `; script = frames[0].createElement('script'); script.innerHTML = sScript; frames[0].document.head.appendChild(script); frames[0].document.body.innerHTML += sHTML;