1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 function $(id) { 6 return document.getElementById(id); 7 } 8 9 function thumbnailsGotten(data) { 10 var eightBallWindow = $('mostVisitedThumb'); 11 var rand = Math.floor(Math.random() * data.length); 12 eightBallWindow.href = data[rand].url; 13 eightBallWindow.textContent = data[rand].title; 14 eightBallWindow.style.backgroundImage = 'url(chrome://favicon/' + 15 data[rand].url + ')'; 16 } 17 18 window.onload = function() { 19 chrome.topSites.get(thumbnailsGotten); 20 } 21