<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function(){
	"use strict";
	
	var scope;
	if ((typeof exports) !== "undefined"){
		scope = exports;
	}
	else {
		scope = require.register("./navigator", {});
	}
	
	const settings = require("./settings");
	const logging = require("./logging");
	const check = require("./check");
	
	scope.allProperties = [
		"appCodeName", "appName",
		"appVersion", "buildID", "oscpu", "platform",
		"product",
		"productSub", "userAgent", "vendor", "vendorSub"];
	const original = {};
	scope.allProperties.forEach(function(property){
		original[property] = window.navigator[property];
	});
	original["real Firefox version"] = window.navigator.userAgent.replace(/^.+Firefox\//, "");
	
	let changedValues = {};
	
	settings.onloaded(function(){
		changedValues = settings.navigatorDetails;
	});
	settings.on("navigatorDetails", function({newValue}){
		changedValues = newValue;
	});
	
	
	function getValue(name, stack = []){
		if (stack.indexOf(name) !== -1){
			return "[ERROR: loop in property definition]";
		}
		stack.push(name);
		
		switch (name){
			case "original value":
				return original[stack[stack.length - 2]];
			case "random":
				return String.fromCharCode(Math.floor(65 + 85 * Math.random()));
			default:
				if (changedValues.hasOwnProperty(name)){
					return parseString(changedValues[name], stack.slice());
				}
				else {
					return original[name];
				}
		}
	}
	function parseString(string, stack){
		return string.replace(/{([a-z[\]_. -]*)}/ig, function(m, name){
			return getValue(name, stack.slice());
		});
	}
	
	scope.getNavigatorValue = function getNavigatorValue(name){
		return getValue(name);
	};
	
	function changeHTTPHeader(details){
		const url = new URL(details.url);
		if (
			settings.get("protectNavigator", url) &&
			check.check({url}).mode !== "allow" &&
			(
				!settings.protectedAPIFeatures.hasOwnProperty("userAgent") ||
				settings.protectedAPIFeatures.userAgent
			)
		){
			for (var header of details.requestHeaders){<commit_msg>userAgent feature could not be disabled<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function(){
	"use strict";
	
	var scope;
	if ((typeof exports) !== "undefined"){
		scope = exports;
	}
	else {
		scope = require.register("./navigator", {});
	}
	
	const settings = require("./settings");
	const logging = require("./logging");
	const check = require("./check");
	
	scope.allProperties = [
		"appCodeName", "appName",
		"appVersion", "buildID", "oscpu", "platform",
		"product",
		"productSub", "userAgent", "vendor", "vendorSub"];
	const original = {};
	scope.allProperties.forEach(function(property){
		original[property] = window.navigator[property];
	});
	original["real Firefox version"] = window.navigator.userAgent.replace(/^.+Firefox\//, "");
	
	let changedValues = {};
	
	settings.onloaded(function(){
		changedValues = settings.navigatorDetails;
	});
	settings.on("navigatorDetails", function({newValue}){
		changedValues = newValue;
	});
	
	
	function getValue(name, stack = []){
		if (stack.indexOf(name) !== -1){
			return "[ERROR: loop in property definition]";
		}
		stack.push(name);
		
		switch (name){
			case "original value":
				return original[stack[stack.length - 2]];
			case "random":
				return String.fromCharCode(Math.floor(65 + 85 * Math.random()));
			default:
				if (changedValues.hasOwnProperty(name)){
					return parseString(changedValues[name], stack.slice());
				}
				else {
					return original[name];
				}
		}
	}
	function parseString(string, stack){
		return string.replace(/{([a-z[\]_. -]*)}/ig, function(m, name){
			return getValue(name, stack.slice());
		});
	}
	
	scope.getNavigatorValue = function getNavigatorValue(name){
		return getValue(name);
	};
	
	function changeHTTPHeader(details){
		const url = new URL(details.url);
		if (
			settings.get("protectNavigator", url) &&
			check.check({url}).mode !== "allow" &&
			(
				!settings.protectedAPIFeatures.hasOwnProperty("userAgent @ navigator") ||
				settings.protectedAPIFeatures["userAgent @ navigator"]
			)
		){
			for (var header of details.requestHeaders){
{'fraction_non_alphanumeric': 0.16640325129826145, 'fraction_numerical': 0.004515692029803568, 'mean_word_length': 4.039817974971559, 'pattern_counts': {'":': 4, '<': 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': '7082498', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1365, 'n_words': 322}