<commit_before>function handle_input(e) {
    var styleEl = document.getElementById('custom-style');
    var inputEl = document.getElementById('config-area');
    var saveEl = document.getElementById('save');
    
    styleEl.innerHTML = inputEl.value;
    saveEl.disabled = false;
    
    repopulate_subtitles();
}

function repopulate_subtitles() {
    $(".most-subtitles").remove();
    
    var samples = {
        en: "<i>He doesn't have any friends in Korea so he probably doesn't even have anyone to eat with.</i>",
        de: "<i> Er hat keine Freunde in Korea, also wird er wahrscheinlich niemanden haben, mit dem er was essen kann.</i>"
    };
    
    var styleEl = document.getElementById('custom-style');
    var languages = get_used_languages();
    for (var i = 0; i < languages.length; i++) {
        var div = document.createElement("div");
        div.className = "most-subtitles most-" + languages[i];
        div.innerHTML = samples[languages[i]] ||
            "[No sample available for language " + languages[i] + ".]" +
            "<br>[Some more text.]";
        document.getElementById("common-container").appendChild(div);
    }
}

function get_used_languages() {
    result = [];
    var styleEl = document.getElementById('custom-style');
    for (var i = 0; i < styleEl.sheet.rules.length; i++) {
        var re = /\.most-([A-z][A-z])\W/g;
        var m;
        while (m = re.exec(styleEl.sheet.rules[i].selectorText + " ")) {
            if (result.indexOf(m[1]) == -1) {
                result.push(m[1]);
            }
        }
    }
    return result;
}

function restore_options() {
    var styleEl = document.getElementById('custom-style');
    var inputEl = document.getElementById('config-area');
    
    chrome.storage.sync.get(null, function(items) {
        if (items.customStyle !== undefined) {
            styleEl.innerHTML = items.customStyle;
        }
        inputEl.innerHTML = styleEl.innerHTML;
    });
    
    repopulate_subtitles();
}

function save_options() {
    var styleEl = document.getElementById('custom-style')
  
    chrome.storage.sync.set({customStyle: styleEl.innerHTML}, function() {
        var saveEl = document.getElementById('save');
        saveEl.disabled = true;
    });
}

function remove_storage() {
    chrome.storage.sync.remove('customStyle');
}

$("#config-area").on('input', handle_input);
document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('save').addEventListener('click', save_options);
document.getElementById('remove').addEventListener('click', remove_storage);
<commit_msg>Use more $ syntax<commit_after>function handle_input(e) {
    $("#custom-style")[0].innerHTML = $("#config-area")[0].value;
    $("#save")[0].disabled = false;
    
    repopulate_subtitles();
}

function repopulate_subtitles() {
    $(".most-subtitles").remove();
    
    var samples = {
        en: "<i>He doesn't have any friends in Korea so he probably doesn't even have anyone to eat with.</i>",
        de: "<i> Er hat keine Freunde in Korea, also wird er wahrscheinlich niemanden haben, mit dem er was essen kann.</i>"
    };
    
    var languages = get_used_languages();
    for (var i = 0; i < languages.length; i++) {
        var div = document.createElement("div");
        div.className = "most-subtitles most-" + languages[i];
        div.innerHTML = samples[languages[i]] ||
            "[No sample available for language " + languages[i] + ".]" +
            "<br>[Some more text.]";
        $("#common-container")[0].appendChild(div);
    }
}

function get_used_languages() {
    result = [];
    var rules = $("#custom-style")[0].sheet.rules;
    for (var i = 0; i < rules.length; i++) {
        var re = /\.most-([A-z][A-z])\W/g;
        var m;
        while (m = re.exec(rules[i].selectorText + " ")) {
            if (result.indexOf(m[1]) == -1) {
                result.push(m[1]);
            }
        }
    }
    return result;
}

function restore_options() {
    chrome.storage.sync.get(null, function(items) {
        if (items.customStyle === undefined) {
            $("#remove")[0].disabled = true;
        } else {
            $("#custom-style")[0].innerHTML = items.customStyle;
        }
        
        $("#config-area")[0].innerHTML = $("#custom-style")[0].innerHTML;
        
        repopulate_subtitles();
    });
}

function save_options() {
    var customStyle = $("#custom-style")[0].innerHTML;
    
    chrome.storage.sync.set({customStyle: customStyle}, function() {
        $("#save")[0].disabled = true;
        $("#remove")[0].disabled = false;
    });
}

function remove_storage() {
    chrome.storage.sync.remove('customStyle');
    $("#remove")[0].disabled = true;
}

$("#config-area").on('input', handle_input);
document.addEventListener('DOMContentLoaded', restore_options);
$("#save")[0].addEventListener('click', save_options);
$("#remove")[0].addEventListener('click', remove_storage);

{'fraction_non_alphanumeric': 0.16686893203883496, 'fraction_numerical': 0.0050566343042071195, 'mean_word_length': 2.857254290171607, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, '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': '7092910', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1479, 'n_words': 308}