<commit_before>/*
This one is based on the example seen in https://github.com/mdn/webextensions-examples/tree/master/forget-it 
Store the currently selected settings using browser.storage.local.
*/
function storeSettings() {

  function getReload() {
    const reload = document.querySelector("#reload");
    return reload.checked;
  }

  function getNotification() {
    const notification = document.querySelector("#notification");
    return notification.checked;
  }

  const reload = getReload();
  const notification = getNotification();
  browser.storage.local.set({
    reload,
    notification
  });
}
/*
Internationalization of options page works with
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/i18n
*/

function localizeOptions() {

  function replace_i18n(obj, tag) {
    let message = tag.replace(/__MSG_(\w+)__/g, function(match, v1) {
        return v1 ? browser.i18n.getMessage(v1) : '';
    });

    if(message != tag) obj.innerHTML = message;
  }

    let data = document.querySelectorAll('[data-i18n]');

    for (let index in data) if (data.hasOwnProperty(index)) {
        let obj = data[index];
        let tag = obj.getAttribute('data-i18n').toString();

        replace_i18n(obj, tag);
    }

}

/*
Update the options UI with the settings values retrieved from storage,
or the default settings if the stored settings are empty.<commit_msg>Fixes security issue<commit_after>/*
This one is based on the example seen in https://github.com/mdn/webextensions-examples/tree/master/forget-it 
Store the currently selected settings using browser.storage.local.
*/
function storeSettings() {

  function getReload() {
    const reload = document.querySelector("#reload");
    return reload.checked;
  }

  function getNotification() {
    const notification = document.querySelector("#notification");
    return notification.checked;
  }

  const reload = getReload();
  const notification = getNotification();
  browser.storage.local.set({
    reload,
    notification
  });
}
/*
Internationalization of options page works with
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/i18n
*/

function localizeOptions() {

  function replace_i18n(obj, tag) {
    let message = tag.replace(/__MSG_(\w+)__/g, function(match, v1) {
        return v1 ? browser.i18n.getMessage(v1) : '';
    });

    if(message != tag) obj.textContent = message;
  }

    let data = document.querySelectorAll('[data-i18n]');

    for (let index in data) if (data.hasOwnProperty(index)) {
        let obj = data[index];
        let tag = obj.getAttribute('data-i18n').toString();

        replace_i18n(obj, tag);
    }

}

/*
Update the options UI with the settings values retrieved from storage,
or the default settings if the stored settings are empty.
{'fraction_non_alphanumeric': 0.12261089073205914, 'fraction_numerical': 0.010818608005769925, 'mean_word_length': 3.615640599001664, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '4509282', 'n_tokens_mistral': 842, 'n_tokens_neox': 805, 'n_words': 213}