我刚刚构建了一个简单的 chrome 扩展来显示特定关键字的推文。它工作正常。如果用户单击它显示的扩展图标,则每次有新推文可用时。
但是有没有办法在扩展图标中显示一些通知以指示检索到新数据?
这是我的javascript代码
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);
}
这是我的html代码
<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>
这是 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/*"
]
}