<commit_before>
var plugin = document.getElementById ("desktop-webapp-plugin");

plugin.setIconLoaderCallback (function (url) {
    chrome.windows.getAll({populate : true}, function (window_list) {
	var found = false;

        for (var i = 0; i < window_list.length && !found; i++) {
	    var this_window = window_list[i];
	    var tabs = this_window.tabs;

	    for (var j = 0; j < tabs.length; j++) {
		if (tabs[j].url == url) {
		    chrome.tabs.update (tabs[j].id, { active: true }, function (tab) {
			chrome.tabs.captureVisibleTab (this_window.id, { format: "png" }, function (data_url) {
			    console.log (data_url);
			    plugin.setIconForURL (url, data_url);
			});
		    });

		    found = true;
		    break;
		}
	    }
	}
    });

    return 0;
});

function getIconUrl (info)
{
    if (!info.icons || info.icons.length == 0) {
	return "";
    }

    var largest = { size:0 };
    for (var i = 0; i < info.icons.length; i++) {
	var icon = info.icons[i];
	if (icon.size > largest.size) {
	    largest = icon;
	}
    }
    return largest.url;
}

function getImageDataURL(url, callback) {
    var img = new Image();
    img.onload = function() {
        // Convert using a <canvas> and then invoke the callback
        var canvas = document.createElement('canvas');
        canvas.width = img.width;
        canvas.height = img.height;<commit_msg>Just return when nothing else to do<commit_after>
var plugin = document.getElementById ("desktop-webapp-plugin");

plugin.setIconLoaderCallback (function (url) {
    chrome.windows.getAll({populate : true}, function (window_list) {
        for (var i = 0; i < window_list.length && !found; i++) {
	    var this_window = window_list[i];
	    var tabs = this_window.tabs;

	    for (var j = 0; j < tabs.length; j++) {
		if (tabs[j].url == url) {
		    chrome.tabs.update (tabs[j].id, { active: true }, function (tab) {
			chrome.tabs.captureVisibleTab (this_window.id, { format: "png" }, function (data_url) {
			    console.log (data_url);
			    plugin.setIconForURL (url, data_url);
			});
		    });

		    return;
		}
	    }
	}
    });
});

function getIconUrl (info)
{
    if (!info.icons || info.icons.length == 0) {
	return "";
    }

    var largest = { size:0 };
    for (var i = 0; i < info.icons.length; i++) {
	var icon = info.icons[i];
	if (icon.size > largest.size) {
	    largest = icon;
	}
    }
    return largest.url;
}

function getImageDataURL(url, callback) {
    var img = new Image();
    img.onload = function() {
        // Convert using a <canvas> and then invoke the callback
        var canvas = document.createElement('canvas');
        canvas.width = img.width;
        canvas.height = img.height;
{'fraction_non_alphanumeric': 0.15244129705553486, 'fraction_numerical': 0.004099888184867686, 'mean_word_length': 2.6417910447761193, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1663622', 'n_tokens_mistral': 950, 'n_tokens_neox': 873, 'n_words': 226}