Bookmarklet shown when pushed

Viewed 14

How Would i make it so when I push the F key the will show up but when I push it again it will go away. Could this be done through Java?

javascript: (function () {
var head = document.head || document.getElementsByTagName("head")[0];
var body = document.body || document.getElementsByTagName("body")[0];
var counter = document.createElement("div");
counter.setAttribute("id", "fpscounter");
counter.setAttribute("class", "fpscounter");
var style = document.createElement("style");
var css =
    ".fpscounter { position: fixed; z-index: 9999999; bottom: 10px; right: 10px; min-width: 40px; padding: 5px 10px; background-color: #000000; font-family: 'Arial'; font-size: 24px; font-weight: normal; color: #00ff00; text-align: center; border-radius: 5px; }";
style.type = "text/css";
if (style.styleSheet) {
    style.styleSheet.cssText = css;
} else {
    style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
body.appendChild(counter);
var measure = (function () {
    var measurements = [];
    var sixtyFramesAgo, now, fps;
    var counter = document.getElementById("fpscounter");
    return function () {
        now = new Date().getTime();
        measurements.push(now);
        if (measurements.length >= 75) {
            measurements = measurements.slice(measurements.length - 61);
            sixtyFramesAgo = measurements[0];
            fps = Math.floor(60 / ((now - sixtyFramesAgo) / 1000));
            counter.textContent = fps;
        }
        window.requestAnimationFrame(measure);
    };
})();
measure();
0 Answers
Related