<commit_before>var EXPORTED_SYMBOLS = [];

const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;

Components.utils.import("resource://gre/modules/Services.jsm");

const gPrefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
const gPrefBranch = gPrefService.getBranch(null).QueryInterface(Ci.nsIPrefBranch2);
const idleService = Cc["@mozilla.org/widget/idleservice;1"].getService(Ci.nsIIdleService)

var timeout = 0;

var idleObserver = {
  observe: function(subject, topic, data) {
    idleService.removeIdleObserver(idleObserver, timeout);
    var nsIAppStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
    nsIAppStartup.quit(nsIAppStartup.eForceQuit);
  }
};


try {
  timeout = gPrefBranch.getIntPref("extensions.webconverger.kioskresetstation");
  if (timeout > 0) {
    idleService.addIdleObserver(idleObserver, timeout); // timeout is in minutes
  }
} catch (ex) {}

var HTTPObserver = {
  observe: function observe(subject, topic, data) {
    switch (topic) {
    case "http-on-modify-request":
      var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
      if (httpChannel.URI.spec.indexOf("https://www.google.com/search") == 0 &&
        httpChannel.URI.spec.indexOf("safe=strict") == -1) {
        httpChannel.redirectTo(Services.io.newURI(httpChannel.URI.spec + "&safe=strict", null, null));
      }
    }
  }
}

try {
  if (gPrefBranch.getBoolPref("extensions.webconverger.forcesafesearch")) {
    Services.obs.addObserver(HTTPObserver, "http-on-modify-request", false);
  }
} catch (ex) {}<commit_msg>Complete safe search for google, bing and yahoo worldwide<commit_after>var EXPORTED_SYMBOLS = [];

const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;

Components.utils.import("resource://gre/modules/Services.jsm");

const gPrefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
const gPrefBranch = gPrefService.getBranch(null).QueryInterface(Ci.nsIPrefBranch2);
const idleService = Cc["@mozilla.org/widget/idleservice;1"].getService(Ci.nsIIdleService)

var timeout = 0;

var idleObserver = {
  observe: function(subject, topic, data) {
    idleService.removeIdleObserver(idleObserver, timeout);
    var nsIAppStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
    nsIAppStartup.quit(nsIAppStartup.eForceQuit);
  }
};


try {
  timeout = gPrefBranch.getIntPref("extensions.webconverger.kioskresetstation");
  if (timeout > 0) {
    idleService.addIdleObserver(idleObserver, timeout); // timeout is in minutes
  }
} catch (ex) {}

var HTTPObserver = {
  observe: function observe(subject, topic, data) {
    switch (topic) {
    case "http-on-modify-request":
      var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
      if (/.*\.google\..*/.test(httpChannel.URI.host)) {
        if (/^(\/custom|\/search|\/images\/complete)/.test(httpChannel.URI.path)) {
          if (httpChannel.URI.spec.indexOf("safe=strict") == -1) {
            httpChannel.redirectTo(Services.io.newURI(httpChannel.URI.spec + "&safe=strict", null, null));
          }
        }
        return;
      }
      if (/.*\.yahoo\..*/.test(httpChannel.URI.host)) {
        if (/^(\/search)/.test(httpChannel.URI.path)) {
          if (httpChannel.URI.spec.indexOf("vm=r") == -1) {
            httpChannel.redirectTo(Services.io.newURI(httpChannel.URI.spec + "'&vm=r", null, null));
          }
        }
        return;
      }
      if (/.*\.bing\..*/.test(httpChannel.URI.host)) {
        if (/^(\/search|\/videos|\/images|\/news)/.test(httpChannel.URI.path)) {
          if (httpChannel.URI.spec.indexOf("adlt=strict") == -1) {
            httpChannel.redirectTo(Services.io.newURI(httpChannel.URI.spec + "'&adlt=strict", null, null));
          }
        }
        return;
      }
    }
  }
}

try {
  if (gPrefBranch.getBoolPref("extensions.webconverger.forcesafesearch")) {
    Services.obs.addObserver(HTTPObserver, "http-on-modify-request", false);
  }
} catch (ex) {}
{'fraction_non_alphanumeric': 0.1587185130838836, 'fraction_numerical': 0.004157495720224994, 'mean_word_length': 3.6903669724770642, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '6588409', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1384, 'n_words': 197}