]> git.wh0rd.org Git - chrome-ext/clearhistory-advance-fork.git/commitdiff
fix timer init
authorMike Frysinger <vapier@gentoo.org>
Sun, 3 Feb 2013 04:44:52 +0000 (23:44 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 2 Mar 2013 22:49:17 +0000 (17:49 -0500)
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.

javascript/clearhistory.js

index 7c9596f943ec287b28890ce8dd026176be9cb587..d05a2f694f9581438c57bcad119b50bd9d354583 100644 (file)
@@ -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) {