Teaching

Teaching tools & scripts for a smoother classroom experience

Browser Scripts & Bookmarklets

Open Object PDF resources in new tabs

Open first pdf

open pdf

javascript: [...document.querySelectorAll('object[type="application/pdf"]')].forEach(obj => window.open(obj.data, '_blank'));

Open pdfs sequentially on every click

open pdfs

javascript:(() => {
  let m = document.head.querySelector('meta[name="pdfidx"]');
  if (!m) {
    m = document.createElement('meta');
    m.name = 'pdfidx';
    m.content = 0;
    document.head.appendChild(m);
  }

  const urls = [...document.querySelectorAll('object[type="application/pdf"],embed[type="application/pdf"]')]
    .map(o => o.data || o.src)
    .filter(Boolean);

  const i = +m.content || 0;

  if (i >= urls.length) {
    m.content = 0;
    alert(`opened all ${urls.length}, counter reset`);
    return;
  }

  window.open(urls[i], '_blank');
  m.content = i + 1;
  document.title = `[${i + 1}/${urls.length}] ` + document.title.replace(/^\[\d+\/\d+\] /, '');
})();

Convert Google Slides Presentation to fill window (mobile present)

📱 present

javascript: (()=>{
  const copy = content => {    
      const tempInput = document.createElement("textarea");
      document.body.appendChild(tempInput);
      tempInput.setAttribute("id", "temporary_input_clipboard");
      document.getElementById("temporary_input_clipboard").value = content;
      tempInput.select();
      document.execCommand("copy");
      document.body.removeChild(tempInput);
  }
  const loc = window.location;
  const host = loc.host, pathname = loc.pathname, url = loc.href;
  
  if (host === 'docs.google.com' && pathname.includes("/presentation")) {
      const path = pathname.match(/\/presentation\/d\/.*\//)[0];
      presentation = 'https://' + host + path + 'mobilepresent';
      copy(presentation);
      window.location.href = presentation;
  };
})();

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 = [
    ['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', '13:23'],
    ['9:00', '10:05', '10:55', '12:25'],
];
const cleanup = 3 * 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`;
})();