Skip to content

Instantly share code, notes, and snippets.

@cocoabox
Last active April 4, 2020 10:13
Show Gist options
  • Save cocoabox/9b02e0dd81502f0ab9f46a1c270b0572 to your computer and use it in GitHub Desktop.
Save cocoabox/9b02e0dd81502f0ab9f46a1c270b0572 to your computer and use it in GitHub Desktop.
javascript:void(function(){function e(e){let i="",o="",t="";return e>3600&&(e-=3600*(i=Math.floor(e/3600)),i=`${i} hrs`),e>60&&(e-=60*(o=Math.floor(e/60)),o=`${o} min`),e&&(t=`${e} sec`),[i,o,t].join(" ").trim()}function i(){window.__close_timer.timer&&window.clearInterval(window.__close_timer.timer),window.__close_timer.timer="",window.__close_timer.active=!1,window.__close_timer.sec=0,window.__close_timer.title=""}if(void 0===window.__close_timer&&(window.__close_timer={}),window.__close_timer.active){let o=e(window.__close_timer.sec);return window.confirm(`%E2%8F%B2 :${o}\n%F0%9F%9A%AB%E2%8F%B2?`)?(document.title=window.__close_timer.title,void i()):void 0}let o="10m",t=document.querySelector("video");if(t){o=e(Math.floor(t.duration-t.currentTime)+5)}let _=window.prompt("%E2%8F%B2%F0%9F%92%A4 %E2%86%92%E2%9D%8C",o).trim();if(!_)return;let r=_.toLowerCase().match(/^(([0-9\.]+)\s*(hours|hour|hrs|hr|h))?\s*(([0-9\.]+)\s*(minute|minute|mins|min|m))?\s*(([0-9\.]+)\s*(seconds|second|secs|sec|s))?$/),n=0;r[2]&&(n+=3600*parseFloat(r[2])),r[5]&&(n+=60*parseFloat(r[5])),r[8]&&(n+=parseInt(r[8])),n=Math.floor(n),window.__close_timer.title=document.title,window.__close_timer.sec=n,window.__close_timer.timer=window.setInterval(function(){if(window.__close_timer.sec-=1,window.__close_timer.sec<=0)return i(),void window.close();let o=e(window.__close_timer.sec);document.title=`%E2%8F%B2 [${o}] - ${window.__close_timer.title}`},1e3),window.__close_timer.active=!0}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment