X-Git-Url: https://git.wh0rd.org/?p=chrome-ext%2Fclearhistory-advance-fork.git;a=blobdiff_plain;f=javascript%2Fclearhistory.js;h=b40f5958a187ef542f93230b1dd081a55a49f4df;hp=28eb2b060676ec161b554e177389f5316b24885a;hb=614dea955c957d58c79da346fa36fec176c59728;hpb=0fa4918dbbbcdc447b3918275fcb192349264364 diff --git a/javascript/clearhistory.js b/javascript/clearhistory.js index 28eb2b0..b40f595 100644 --- a/javascript/clearhistory.js +++ b/javascript/clearhistory.js @@ -65,6 +65,9 @@ function clearDownloads(s) { * Callback for when history deletion is successful */ function didClearHistory(s) { + if (s.notify !== CONSTANTS.YES) + return; + var time = ~~(s.time) || CONSTANTS.DEFAULT_TIME; time = getUnitsForTime(time); var timeMsg = (time.time === -1) ? 'notificationTimeAll' : @@ -72,14 +75,17 @@ function didClearHistory(s) { 'notificationTimeOlder'; var timeString = chrome.i18n.getMessage(timeMsg, [time.time, time.units]); var message = chrome.i18n.getMessage('notificationBody', timeString); - var notification = webkitNotifications.createNotification( - chrome.extension.getURL('/images/icon48.png'), - chrome.i18n.getMessage('notificationTitle'), - message); - notification.show(); - setTimeout(function() { - notification.cancel(); - }, 5000); + var options = { + type: 'basic', + title: chrome.i18n.getMessage('notificationTitle'), + message: message, + iconUrl: chrome.extension.getURL('/images/icon128.png'), + }; + + var id = 'clearhistory advance notify'; + chrome.notifications.clear(id, function(wasCleared) { + chrome.notifications.create(id, options, function(){}); + }); } /** @@ -122,7 +128,7 @@ function clearAll(s) { function runCleaner() { var keys = [ - 'cookies', 'downloads', 'time', 'timeStart', + 'cookies', 'downloads', 'time', 'timeStart', 'notify', ]; chrome.storage.sync.get(keys, function(s) { if (s.cookies === CONSTANTS.YES) {