0
我剛剛構建了一個簡單的擴展程序來顯示特定關鍵字的推文。它工作正常。每次有新的推文時,如果用戶點擊了它顯示的擴展名圖標。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/*"
]
}
是的,有。但[你有什麼嘗試?](http://www.whathaveyoutried.com/) – Cerbrus
我已更新我的代碼上面 – iJade
是的,通過[長輪詢或套接字](http://techoctave.com/c7/posts/ 60簡單長輪詢-例如與 - 的JavaScript和 - jquery的)。我建議你試試看,如果你在實施時遇到任何問題,請再次提問。 – jjperezaguinaga