Javascript bookmarks generator not generate working code

I need to create a Javascript count down timer bookmarklet.

I’ve created a script:

 <head>
    <script type="text/javascript">
       function startTimer(duration, display) {
    var timer = duration, minutes, seconds;
    setInterval(function () {
        minutes = parseInt(timer / 60, 10)
        seconds = parseInt(timer % 60, 10);

        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;

        display.textContent = minutes + ":" + seconds;

        if (--timer < 0) {
            timer = duration;
        }
    }, 1000);
}

window.onload = function () {
    var fiveMinutes = 60 * 5,
        display = document.querySelector('#time');
    startTimer(fiveMinutes, display);
};
    </script>
</head>
<body>
    <div>Registration closes in <span id="time">05:00</span> minutes!</div>
</body>
</html>

Normally it works but when I paste it into: http://mrcoles.com/bookmarklet/
and copy the generated code, it stops working. Any suggestions?

bookmark.html:

<A HREF="javascript:(function()%7Bfunction%20callback()%7B(function(%24)%7Bvar%20jQuery%3D%24%3Bfunction%20startTimer(duration%2C%20display)%20%7Bvar%20timer%20%3D%20duration%2C%20minutes%2C%20seconds%3BsetInterval(function%20()%20%7Bminutes%20%3D%20parseInt(timer%20%2F%2060%2C%2010)seconds%20%3D%20parseInt(timer%20%25%2060%2C%2010)%3Bminutes%20%3D%20minutes%20%3C%2010%20%3F%20%220%22%20%2B%20minutes%20%3A%20minutes%3Bseconds%20%3D%20seconds%20%3C%2010%20%3F%20%220%22%20%2B%20seconds%20%3A%20seconds%3Bdisplay.textContent%20%3D%20minutes%20%2B%20%22%3A%22%20%2B%20seconds%3Bif%20(--timer%20%3C%200)%20%7Btimer%20%3D%20duration%3B%7D%7D%2C%201000)%3B%7Dwindow.onload%20%3D%20function%20()%20%7Bvar%20fiveMinutes%20%3D%2060%20*%205%2Cdisplay%20%3D%20document.querySelector('%23time')%3BstartTimer(fiveMinutes%2C%20display)%3B%7D%7D)(jQuery.noConflict(true))%7Dvar%20s%3Ddocument.createElement(%22script%22)%3Bs.src%3D%22https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fjquery%2F1.7.1%2Fjquery.min.js%22%3Bif(s.addEventListener)%7Bs.addEventListener(%22load%22%2Ccallback%2Cfalse)%7Delse%20if(s.readyState)%7Bs.onreadystatechange%3Dcallback%7Ddocument.body.appendChild(s)%3B%7D)()" ADD_DATE="1432802992" LAST_MODIFIED="1432803063">MS Check V1</A>

 <div>Registration closes in <span id="time">05:00</span> minutes!</div>


Source: bookmarks

Leave a Reply