Skip to content

Instantly share code, notes, and snippets.

@harishvc
Created December 30, 2015 09:32
Show Gist options
  • Save harishvc/a1b3dad9be5c40cac484 to your computer and use it in GitHub Desktop.
Save harishvc/a1b3dad9be5c40cac484 to your computer and use it in GitHub Desktop.
mapit - background.js (active and inactive tab)
var match = 'https://calendar.google.com/calendar/render'
//http://stackoverflow.com/questions/18162644/adding-a-listener-that-fires-whenever-the-user-changes-tab
//When Google Calendar browser tab is active again!!!
chrome.tabs.onActivated.addListener(function(activeInfo) {
chrome.tabs.get(activeInfo.tabId, function (tab) {
//chrome.tabs.sendMessage(activeInfo.tabId, {action: "tabactive", consolelog: tab.url.substring(0, match.length)},function(response) {});
if (tab.url.substring(0, match.length) === match) {
chrome.tabs.sendMessage(activeInfo.tabId, {action: "start"}, function(response) {});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment