<commit_before>(function() {
	main = function() {
		this.logDebug = function(msg) {
			console.log("[background] " + msg);
		};

		this.KEY_URL_INFOS = "key_urlInfos";

		// A handler to handle BeforeRequest
		this.requestBlockFunction = function(details) {
			this.logDebug("Blocked URL: " + details.url);
			return {cancel: true};
		};

		// url: "http://www.google.com/", etc.
		this.formatUrl = function(url) {
			var re = /^https?:\/\/([\w.]+)\/.*/;
			return url.replace(re, "*://$1/*");
		};

		chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
			if (request.action) {
				switch (request.action) {
					case "startTrack":
						this.logDebug("startTrack");
						var key = this.KEY_URL_INFOS;
						var formatUrl = this.formatUrl;
						var requestBlockFunction = this.requestBlockFunction;
						chrome.storage.sync.get(key, function(items) {
							var urlInfos = JSON.parse(items[key]);
							var urls = [];
							urlInfos.forEach(function(urlInfo, index) {
								urls.push(formatUrl(urlInfo.url));  // "*://host/*"
							}, this);

							if (urls.length > 0) {
								chrome.webRequest.onBeforeRequest.addListener(
									requestBlockFunction,<commit_msg>Add a comment<commit_after>(function() {
	main = function() {
		this.logDebug = function(msg) {
			console.log("[background] " + msg);
		};

		this.KEY_URL_INFOS = "key_urlInfos";

		// A handler to handle BeforeRequest
		this.requestBlockFunction = function(details) {
			this.logDebug("Blocked URL: " + details.url);
			return {cancel: true};
		};

		// url: "http://www.google.com/", etc.
		//  ->> "*://www.google.com/*", etc.
		this.formatUrl = function(url) {
			var re = /^https?:\/\/([\w.]+)\/.*/;
			return url.replace(re, "*://$1/*");
		};

		chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
			if (request.action) {
				switch (request.action) {
					case "startTrack":
						this.logDebug("startTrack");
						var key = this.KEY_URL_INFOS;
						var formatUrl = this.formatUrl;
						var requestBlockFunction = this.requestBlockFunction;
						chrome.storage.sync.get(key, function(items) {
							var urlInfos = JSON.parse(items[key]);
							var urls = [];
							urlInfos.forEach(function(urlInfo, index) {
								urls.push(formatUrl(urlInfo.url));  // "*://host/*"
							}, this);

							if (urls.length > 0) {
								chrome.webRequest.onBeforeRequest.addListener(
									requestBlockFunction,
{'fraction_non_alphanumeric': 0.17095063239494085, 'fraction_numerical': 0.0016319869441044472, 'mean_word_length': 2.9106858054226477, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, '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': '181644', 'n_tokens_mistral': 1025, 'n_tokens_neox': 803, 'n_words': 141}