(function(browserchrome, $) { var htmlTemplate = '
Tab Title
http://google.com/
' browserchrome.update = function() { $('[data-screenshot-url]').each(function(index, element) { var elem = $(element); if (!elem.data('has-chrome')) { // Create chrome var createdHtml = $(htmlTemplate); // Add the new chrome to the page where the image was elem.replaceWith(createdHtml); // Add the image to the new browser chrome html createdHtml.append(elem); // Set the tab title var tabTitle = elem.attr('title') || elem.data('tab-title'); createdHtml.find('.tab-title').text(tabTitle); // Pick the protocol and set the url var url = elem.data('screenshot-url'); if (url.substring(0, 6) === 'https:') { createdHtml.find('.protocol-http').hide(); createdHtml.find('.protocol-https').show(); url = url.substring(5); } else { createdHtml.find('.protocol-http').hide(); createdHtml.find('.protocol-https').show(); url = url.substring(4); } createdHtml.find('.url-text').text(url); elem.data('has-chrome', 'true'); } }); }; }(window.browserchrome = window.browserchrome || {}, window.jQuery));