From: Mike Frysinger Date: Sun, 3 Feb 2013 04:44:52 +0000 (-0500) Subject: fix timer init X-Git-Tag: v1.5.1~1 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=defd9f796806069c850afdd4617049ec0d994bc1;p=chrome-ext%2Fclearhistory-advance-fork.git fix timer init Don't keep re-initializing the timer every time the event page gets loaded otherwise we keep clearing the history every 10 minutes rather than once a day. --- diff --git a/javascript/clearhistory.js b/javascript/clearhistory.js index 7c9596f..d05a2f6 100644 --- a/javascript/clearhistory.js +++ b/javascript/clearhistory.js @@ -119,10 +119,15 @@ chrome.browserAction.onClicked.addListener(function(tab) { runCleaner(); }); -chrome.alarms.create(CONSTANTS.CLEANER_ALARM, { - // First fire 10 minutes from now. - 'when': Date.now() + (10 * 60 * 1000), - 'periodInMinutes': 24 * 60 +chrome.alarms.get(CONSTANTS.CLEANER_ALARM, function(a) { + if (a) + return; + + chrome.alarms.create(CONSTANTS.CLEANER_ALARM, { + // First fire 10 minutes from now. + 'when': Date.now() + (10 * 60 * 1000), + 'periodInMinutes': 24 * 60 + }); }); chrome.alarms.onAlarm.addListener(function(alarm) {