<commit_before>﻿browser.on("init", function () {
    "use strict";

    // Retrieve the list of favorites and add them to the UI
    this.readFavorites = () => {
        this.roamingFolder
            .getFileAsync("favorites.json")
            .then(favFile => Windows.Storage.FileIO.readTextAsync(favFile))
            .done(favJSON => {
                // Read the list of favorites from file
                let updatedFavs = favJSON ? JSON.parse(favJSON) : [];
                let favList = [...document.querySelectorAll("#favMenu .favorite")];

                this.favorites.clear();
                updatedFavs.forEach(pair => this.favorites.set(pair[0], pair[1]));

                // Clear the favorites menu
                favList.forEach(favNode => favNode.parentNode.removeChild(favNode));

                // Propagate the favorites menu with the new list
                let i = 1;
                this.favorites.forEach((entry, url) => {
                    let favEntry = document.createElement("a");
                    favEntry.className = "favorite";
                    favEntry.textContent = entry.title;

                    favEntry.addEventListener("click", () => {
                        this.closeMenu();
                        this.navigateTo(url);
                    });

                    let delay = 0.06 + 0.03 * i++;
                    favEntry.style.transitionDelay = delay + "s";
                    this.favList.appendChild(favEntry);

                    let alt = document.createElement("div");
                    alt.className = "url";
                    alt.textContent = url;

                    favEntry.appendChild(alt);
                });
            });
    };

    // Save the list of favorites to file
    this.saveFavorites = () => {
        this.roamingFolder
            .createFileAsync("favorites.json", Windows.Storage.CreationCollisionOption.replaceExisting)
            .then(favFile => Windows.Storage.FileIO.writeTextAsync(favFile, JSON.stringify([...this.favorites])))
            .done(() => this.readFavorites());
    };

    // Scroll the favorites list to the top
    this.scrollFavoritesToTop = () => {
        this.favList.scrollTop = 0;
    };

    // Show or hide the favorites menu
    this.showFavMenu = shown => {
        this.favMenu.style.display = shown ? "block" : "none";
    };

    // Listen for the add favorite button to save the current page to the list of favorites
    this.addFavButton.addEventListener("click", () => {
        this.favorites.set(this.currentUrl, { "title": this.documentTitle });<commit_msg>eat error if favorites.json is not found<commit_after>﻿browser.on("init", function () {
    "use strict";

    // Retrieve the list of favorites and add them to the UI
    this.readFavorites = () => {
        this.roamingFolder
            .getFileAsync("favorites.json")
            .then(favFile => Windows.Storage.FileIO.readTextAsync(favFile))
            .done(
                favJSON => {
                    // Read the list of favorites from file
                    let updatedFavs = favJSON ? JSON.parse(favJSON) : [];
                    let favList = [...document.querySelectorAll("#favMenu .favorite")];

                    this.favorites.clear();
                    updatedFavs.forEach(pair => this.favorites.set(pair[0], pair[1]));

                    // Clear the favorites menu
                    favList.forEach(favNode => favNode.parentNode.removeChild(favNode));

                    // Propagate the favorites menu with the new list
                    let i = 1;
                    this.favorites.forEach((entry, url) => {
                        let favEntry = document.createElement("a");
                        favEntry.className = "favorite";
                        favEntry.textContent = entry.title;

                        favEntry.addEventListener("click", () => {
                            this.closeMenu();
                            this.navigateTo(url);
                        });

                        let delay = 0.06 + 0.03 * i++;
                        favEntry.style.transitionDelay = delay + "s";
                        this.favList.appendChild(favEntry);

                        let alt = document.createElement("div");
                        alt.className = "url";
                        alt.textContent = url;

                        favEntry.appendChild(alt);
                    });
                },
                e => {}
            );
    };

    // Save the list of favorites to file
    this.saveFavorites = () => {
        this.roamingFolder
            .createFileAsync("favorites.json", Windows.Storage.CreationCollisionOption.replaceExisting)
            .then(favFile => Windows.Storage.FileIO.writeTextAsync(favFile, JSON.stringify([...this.favorites])))
            .done(() => this.readFavorites());
    };

    // Scroll the favorites list to the top
    this.scrollFavoritesToTop = () => {
        this.favList.scrollTop = 0;
    };

    // Show or hide the favorites menu
    this.showFavMenu = shown => {
        this.favMenu.style.display = shown ? "block" : "none";
    };

    // Listen for the add favorite button to save the current page to the list of favorites
    this.addFavButton.addEventListener("click", () => {
        this.favorites.set(this.currentUrl, { "title": this.documentTitle });
{'fraction_non_alphanumeric': 0.11762523191094619, 'fraction_numerical': 0.0037105751391465678, 'mean_word_length': 1.5831336847149018, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 30, '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': '5437201', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1336, 'n_words': 296}