Last active
August 29, 2015 14:08
-
-
Save esserj/b99fb49480961026aec0 to your computer and use it in GitHub Desktop.
Tickspot timer reminder bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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