var NOTIFICATION_ID = 'wayw';

chrome.browserAction.setBadgeBackgroundColor({'color': '#0000FF'});
chrome.browserAction.setBadgeText({text: "?"});

var next_check_time = new Date();
var delay_seconds = function(seconds) {
    next_check_time = new Date();
    next_check_time.setSeconds(next_check_time.getSeconds() + seconds);
}

console.log('aaa');
chrome.runtime.onInstalled.addListener(function() {
    console.log("Installed.");

    setInterval(check_status, 30*1000); // 30 seconds
    check_status();

    chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex) {
        if (notificationId == NOTIFICATION_ID) {
            delay_seconds(30*60); // 30 minutes

            if (buttonIndex == 0) {
                var url = chrome.extension.getURL('popup.html');
                var options = 'width=325,height=325,top=200,left=450';
                window.popUpWindow = window.open(url, "Where Are You Working?", options);
            }

            chrome.notifications.clear(notificationId, function(wasCleared) {
            });
        }
    });

    chrome.notifications.onClosed.addListener(function(notificationId, byUser) {
        if (notificationId == NOTIFICATION_ID && byUser) {
            delay_seconds(5*60); // 5 minutes
            chrome.notifications.clear(notificationId, function(wasCleared) {
            });
        }
    });
});

console.log('bbb');
function check_status() {
    var now = new Date();

    year = now.getFullYear();
    month = now.getMonth() + 1;
    if (month < 10) {
        month = '0' + month;
    }
    day = now.getDate();
    if (day < 10) {
        day = '0' + day;
    }

    var date_str = year + '-' + month + '-' + day;
    var key = 'date-' + date_str;

    if (key in localStorage) {
        chrome.browserAction.setBadgeBackgroundColor({'color': '#00FF00'});
        chrome.browserAction.setBadgeText({text: "ok"});
    } else {
        chrome.browserAction.setBadgeBackgroundColor({'color': '#FF0000'});
        chrome.browserAction.setBadgeText({text: "X"});

        if (now.getHours() > 9 && now > next_check_time) {
            var opt = {
                type: "basic",
                title: "Where Are You Working?",
                message: "Please provide your location details.",
                iconUrl: "images/icon.png",
                buttons: [{title:'Report Now', iconUrl:'images/pencil.png'},
                          {title:'Ask Me Again Later', iconUrl:'images/clock.png'}]
            }

            console.log('show notification');
            // chrome.notifications.clear(NOTIFICATION_ID, function(wasCleared) {
            //     console.log('cleared ' + wasCleared);
            // });
            chrome.notifications.create(NOTIFICATION_ID, opt, function(notificationId) {
                console.log('create ' + notificationId);
            });
        }
    }
}

console.log('ccc');

@@ -328,28 +328,8 @@
 %0A%7D%0A%0A
-console.log('aaa');%0A
 chro
@@ -380,1018 +380,12 @@
 ) %7B%0A
-    console.log(%22Installed.%22);%0A%0A    setInterval(check_status, 30*1000); // 30 seconds%0A    check_status();%0A%0A    chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex) %7B%0A        if (notificationId == NOTIFICATION_ID) %7B%0A            delay_seconds(30*60); // 30 minutes%0A%0A            if (buttonIndex == 0) %7B%0A                var url = chrome.extension.getURL('popup.html');%0A                var options = 'width=325,height=325,top=200,left=450';%0A                window.popUpWindow = window.open(url, %22Where Are You Working?%22, options);%0A            %7D%0A%0A            chrome.notifications.clear(notificationId, function(wasCleared) %7B%0A            %7D);%0A        %7D%0A    %7D);%0A%0A    chrome.notifications.onClosed.addListener(function(notificationId, byUser) %7B%0A        if (notificationId == NOTIFICATION_ID && byUser) %7B%0A            delay_seconds(5*60); // 5 minutes%0A            chrome.notifications.clear(notificationId, function(wasCleared) %7B%0A            %7D);%0A        %7D%0A    %7D);%0A%7D);%0A%0Aconsole.log('bbb');
+%7D);%0A
 %0Afun
@@ -1490,57 +1490,8 @@
     
- console.log('show notification');%0A            //
  chr
@@ -1565,19 +1565,16 @@
         
- //
      con
@@ -1623,11 +1623,8 @@
     
- //
  %7D);
@@ -1810,23 +1810,874 @@
 %7D%0A%0Ac
-onsole.log('ccc');
+hrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex) %7B%0A    if (notificationId == NOTIFICATION_ID) %7B%0A        delay_seconds(30*60); // 30 minutes%0A%0A        if (buttonIndex == 0) %7B%0A            var url = chrome.extension.getURL('popup.html');%0A            var options = 'width=325,height=325,top=200,left=450';%0A            window.popUpWindow = window.open(url, %22Where Are You Working?%22, options);%0A        %7D%0A%0A        chrome.notifications.clear(notificationId, function(wasCleared) %7B%0A        %7D);%0A    %7D%0A%7D);%0A%0Achrome.notifications.onClosed.addListener(function(notificationId, byUser) %7B%0A    if (notificationId == NOTIFICATION_ID && byUser) %7B%0A        delay_seconds(5*60); // 5 minutes%0A        chrome.notifications.clear(notificationId, function(wasCleared) %7B%0A        %7D);%0A    %7D%0A%7D);%0A%0AsetInterval(check_status, 30*1000); // 30 seconds%0Acheck_status();%0A
 %0A

fix up issue with using wrong listener for registering background setinterval