Reputation: 37
i want my extension to capture any url that is created and alert it am totally new to chrome extensions it is my first extension ^_^ here is the manifest.json file:
{
"name":"modz",
"manifest_version":2,
"version":"1.0",
"description":"this ext. will help you record all the urls you have visited",
"browser_action":
{
"default_icon":"icon.png",
"default_popup":"popup.html"
},
"permissions":[
"tabs"
]
}
and this is the html and it is containing the scrpit:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
chrome.tabs.onCreated.addListener(function ( tab ){
alert(tab.url);
});
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
alert(changeInfo.url);
});
chrome.tabs.onActivated.addListener(function(activeInfo) {
chrome.tabs.get(activeInfo.tabId, function(tab){
console.log(tab.url);
});
});
</script>
<style type="text/css">
body{
width:440px;
}
</style>
</head>
<body>
<div id="hello">hi this is the pop up </div>
</body>
</html>
thanks in advance
Upvotes: 1
Views: 1714
Reputation:
Try putting that script code in background.js instead, and add this to your manifest:
"background": {
"scripts": ["background.js"]
}
popup.html only runs when the user clicks the browser action icon. background.js will be running throughout the session.
Check out this extension guide if you haven't already: https://developer.chrome.com/extensions/overview
Upvotes: 1