Teaching

Teaching tools & scripts for a smoother classroom experience

Browser Scripts & Bookmarklets

Fullscreen Presentation

fullscreen

javascript: document?.fullscreenElement || document.querySelector('html').requestFullscreen();

Class Timer

timer

  • Each inner array of endTimes is indexed to the day of the weekday: Monday Tuesday Wednesday Thursday Friday
    • Times are in military time HH:mm
  • cleanup is the number of minutes in seconds subtracted from the end of class for cleaning up
  • edit these values in the below codeblock before updating the bookmark if the class schedule changes
javascript: (()=>{

const endTimes = [
    ['9:00', '10:05', '10:50', '12:30', '14:00'],
    ['8:40', '9:50', '10:50', '11:40', '13:30'],
    ['9:00', '10:05', '11:10'],
    ['9:00', '10:05', '10:55', '12:00'],
    ['9:00', '10:05', '10:55', '12:25'],
];
const cleanup = 5 * 60;

const today = new Date();
const day = today.getDay();
const hhmmtoSeconds = (time) => {
    const split = time.split(':');
    return 60 * (60 * parseInt(split[0]) + parseInt(split[1]));
};
    
const todayEndTimes = endTimes[day-1];
const todayEndTimeSeconds = todayEndTimes.map( time => hhmmtoSeconds(time) );
    
const hours = today.getHours();
const minutes = today.getMinutes();
const seconds = today.getSeconds();  

const formattedNow = `${ hours > 0 ? hours + ":" : "" }${ hours > 0 && minutes < 10 ? '0' + minutes : minutes }:${ seconds < 10 ? '0' + seconds : seconds }`;
const secondsNow = hours * 60 * 60 + minutes * 60 + seconds; 
    
const getEndTimeSeconds = () => {
    for ( let i = 0; i <= todayEndTimeSeconds.length; i++) {
        if (todayEndTimeSeconds[i] > secondsNow) return todayEndTimeSeconds[i];
    };
};
    const diff = getEndTimeSeconds()-secondsNow-cleanup;
    const endMins = Math.floor(diff / 60);
    const endSecs = diff % 60;
    window.location = `https://www.google.com/search?q=set+timer+for+${endMins}+minutes+${endSecs}+seconds`;
})();