<commit_before>function fetchChanges() {
    console.debug("fetching changes...")
    chrome.browserAction.setBadgeBackgroundColor({ color: "#F00" });
    var query = localStorage["query"] || ["is:open", "reviewer:self", "-owner:self"].join('+');
    queryChangeList(query).then(
        function(result) {
            console.debug("got changes:", result.length);
            chrome.storage.local.set({ 'changes': result });
        }, function(e) {
            console.warn("failed to fetch changes:", e.message);
            delete chrome.storage.local.unreadCount;
        });
}

function updateIcon(changes) {
    try {
        var unread = changes.filter(function(value, index, array) {return !value.reviewed});
    } catch (e) {
    }
    chrome.browserAction.setBadgeText({ text: unread && unread.length.toString() || "..." });
}

function onAlarm(alarm) {
    console.debug('background.onAlarm...');
    fetchChanges();
}

function onStartup() {
    console.debug('background.onStartup...');
    chrome.storage.local.get("changes", function(items) {
        updateIcon(items.changes);
    });
    fetchChanges();
    chrome.alarms.create('refresh', {periodInMinutes: 15});
    chrome.browserAction.setBadgeBackgroundColor({color: "#000"});
}

function onNavigate(details) {
    fetchChanges();
}<commit_msg>Added favicon support.<commit_after>function fetchChanges() {
    console.debug("fetching changes...")
    chrome.browserAction.setBadgeBackgroundColor({ color: "#F00" });
    var query = localStorage["query"] || ["is:open", "reviewer:self", "-owner:self"].join('+');
    queryChangeList(query).then(
        function(result) {
            console.debug("got changes:", result.length);
            chrome.storage.local.set({ 'changes': result });
        }, function(e) {
            console.warn("failed to fetch changes:", e.message);
            delete chrome.storage.local.unreadCount;
        });
}

function updateIcon(changes) {
    try {
        var unread = changes.filter(function(value, index, array) {return !value.reviewed});
    } catch (e) {
    }
    chrome.browserAction.setBadgeText({ text: unread && unread.length.toString() || "..." });
}

function onAlarm(alarm) {
    console.debug('background.onAlarm...');
    fetchChanges();
}

function favicon(url) {
    var split = url.split('://');
    var host = split.pop();
    if (!host) throw new Error;
    var scheme = split.pop();
    return (scheme ? scheme + '://' : "") + host.split('/').shift() + "/favicon.ico";
}

function onStartup() {
    console.debug('background.onStartup...');

    try {
        chrome.browserAction.setIcon({path: favicon(localStorage["api_endpoint"])});
    } catch (e) {
    }

    chrome.storage.local.get("changes", function(items) {
        updateIcon(items.changes);
    });
    fetchChanges();
    chrome.alarms.create('refresh', {periodInMinutes: 15});
    chrome.browserAction.setBadgeBackgroundColor({color: "#000"});
}

function onNavigate(details) {
    fetchChanges();
}
{'fraction_non_alphanumeric': 0.17639213071023674, 'fraction_numerical': 0.004668222740913638, 'mean_word_length': 3.291845493562232, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2792578', 'n_tokens_mistral': 917, 'n_tokens_neox': 883, 'n_words': 156}