得到的結果和新分頁看到的"最常瀏覽的網站"是一樣的.
manifest.json
{
"manifest_version": 2,
"name": "ironman6",
"version": "1.0",
"browser_action": {
"default_popup": "index.html"
},
"permissions": [
"topSites"
]
}
index.html
<title>ironman6</title>
<style>body {width: 500px;}</style>
<div id="content"></div>
<script src="app.js"></script>
app.js
var content = document.querySelector('#content');
chrome.topSites.get(function(MostVisitedURL){
var output = [];
for (var i = 0; i < MostVisitedURL.length; i++) {
var data = MostVisitedURL[i];
output.push('<p><a href="' + data.url + '">' + data.title + '</a></p>');
};
content.innerHTML = output.join('');
});