var warning = function(){
  var time = /(..)(:..)/.exec(new Date());     // The prettyprinted time.
  var hour = time[1] % 12 || 12;               // The prettyprinted hour.
  var period = time[1] < 12 ? 'a.m.' : 'p.m.'; // The period of the day.
  var notification = window.webkitNotifications.createNotification(
    'mi.png',                      // The image.
    '小米Robber', // The title.
    '抢到了！ 赶紧填验证码！'      // The body.
  );
  notification.show();
}

//listen messages from content script
/*chrome.runtime.onMessage.addListener(
	function(request, sender, sendResponse) {
		if(request.name === "tip"){
			warning();
		}
	}
);*/

//listen messages from 
/*chrome.webNavigation.onCompleted.addListener(function(e) {
	alert('compete');

});*/

chrome.webNavigation.onDOMContentLoaded.addListener(function(e) {
	//if the navigation happens in the tab content window
	if(e.frameId == 0){
		if(e.url.indexOf('baidu.com')!=-1){
			chrome.tabs.executeScript(null, {code:"$('#su').val('hi baidu~')"});
		}
	}
});


