I am new to developing chrome extensions. I simply want to alert the user when tab switch / window switch takes place. I have made a content_script for all URLs.
I am using chrome API
chrome.tabs.query
to get the URL content.
My manifest.json
file is as :
{
//first three required lines
"manifest_version": 2,
"name" : "Epoch",
"version" : "1.0",
"description":"Chrome extension for alert on tab switch",
"author":"sharique",
"permissions": ["tabs"],
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": ["content.js"]
}
],
"browser_action":{
"default_popup":"popup.html"
}
}
content.js
is as :
chrome.windows.onFocusChanged.addListener(function() {
chrome.tabs.query({
active: true,
currentWindow: true
},
function(tabs) {
var tabURL = tabs[0].url;
var current_tab = [];
current_tab = tabURL.split('/');
alert("You are switched to : " + current_tab[2]);
});
});
popup.html
is blank now.
I read it here that there is a bug into this listener
. So is there any another way to detect tab changes in chrome ?
Going throw chrome extension
document is pretty hectic, please suggest me some methods or provide some links in the comment so that I can proceed my maiden development to chrome extension.
Thank you.