Skip to content

Instantly share code, notes, and snippets.

@esserj
Last active August 29, 2015 14:08
Show Gist options
  • Save esserj/b99fb49480961026aec0 to your computer and use it in GitHub Desktop.
Save esserj/b99fb49480961026aec0 to your computer and use it in GitHub Desktop.
Tickspot timer reminder bookmarklet
javascript:function _bm_clearTimer() { if (_bm_timerIntervalId !== undefined){ clearInterval(_bm_timerIntervalId); } }; _bm_clearTimer(); var _bm_timerIntervalId, _bm_notify = function (msg) { if (Notification.permission === 'granted') { var n = new Notification('Tickspot notification', {body: msg, icon:'favicon.png', lang: 'EN-US'});n.onclick = function () { window.focus(); this.cancel(); } } else if(Notification.permission !== 'denied') { Notification.requestPermission(function (permission) { Notification.permission = permission; _bm_notify(msg); }) } }, _bm_timerTest = function () { if ($('.entries.timer .entry').length <= 0) { _bm_notify('No running timer found!'); }}, _bm_prompt = prompt('Every how many minutes would you like to receive notifications? disable with -1.', '5'); if (_bm_prompt === '-1') {_bm_clearTimer(); _bm_notify('Timer reminder deactivated'); } else { _bm_timerIntervalId = setInterval(_bm_timerTest, _bm_prompt * 60*1000); _bm_notify('Timer reminder activated');}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment