forked from orbitbot/chrome-extensions-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewTab.js
More file actions
20 lines (17 loc) · 625 Bytes
/
newTab.js
File metadata and controls
20 lines (17 loc) · 625 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function $(id) {
return document.getElementById(id);
}
function thumbnailsGotten(data) {
var eightBallWindow = $('mostVisitedThumb');
var rand = Math.floor(Math.random() * data.length);
eightBallWindow.href = data[rand].url;
eightBallWindow.textContent = data[rand].title;
eightBallWindow.style.backgroundImage = 'url(chrome://favicon/' +
data[rand].url + ')';
}
window.onload = function() {
chrome.topSites.get(thumbnailsGotten);
}