Reputation: 23801
I just built a simple chrome extension to show tweets for a particular key word. It works fine. Every time a new tweet is available if the user clicks on the extension icon it shows up.
But is there a way to show some notification in the extension icon to indicate that new data is retrieved?
Here is my javascript code
var req=null;
window.onload = function() {
req = new XMLHttpRequest();
req.open("GET", "http://search.twitter.com/search.atom?q=20SongsThatILike", true);
req.onload = showTweets;
req.send(null);
}
function showTweets() {
var title=req.responseXML.getElementsByTagName('title')[1].childNodes[0];
var author=req.responseXML.getElementsByTagName('author')[1].childNodes[0].childNodes[0];
document.body.appendChild(title);
}
Here is my html code
<html>
<head>
<title>Getting Started Extension's Popup</title>
<style>
body {
min-width:357px;
overflow-x:hidden;
}
img {
margin:5px;
border:2px solid black;
vertical-align:middle;
width:75px;
height:75px;
}
</style>
<!-- JavaScript and HTML must be in separate files for security. -->
<script src="script.js"></script>
</head>
<body>
</body>
</html>
And here is the manifest.json
{
"name": "My First Extension",
"version": "1.0",
"manifest_version": 2,
"description": "The first extension that I made.",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"http://search.twitter.com/*"
]
}
Upvotes: 0
Views: 674
Reputation: 43
you can use
chrome.browserAction.setBadgeText({text: '<number_of_new_teets>'});
this code will put a number on icon of y
Upvotes: 3