<commit_before>submitHit();

chrome.runtime.sendMessage({requestSettings: true}, function(res) {
	freedom = res.freedom;
	distractions = res.distractions;
	blockIfFree();
	fetchVisits();
});

function fetchVisits() {
	chrome.runtime.sendMessage({requestVisits: true}, function(res) {
		console.log(res);

		var counterBox = document.getElementById('turkey-counter');
		if (counterBox != null) {
			var counterMetric = document.createTextNode("You've visited YouTube " + res.visits.length + " times today.");
			counterBox.appendChild(counterMetric);
		}

		var graphsBox = document.getElementById('turkey-graphs');
		if (graphsBox != null) {
			var timeList = [];
			for (var i = 0; i < res.visits.length; i++) {
				var time = getTimeStringFromTimestamp(res.visits[i].visitTime);
				if (timeList.length === 0) {
					timeList.push(time);
				} else if (timeList.length > 0 && time != timeList[timeList.length-1]) {
					timeList.push(time);
				}
			}
			var timeMetric = document.createTextNode("Your visits occurred at these times: " + timeList.join(", "));
			graphsBox.appendChild(timeMetric);
		}
	});
}

document.getElementById('content').addEventListener('DOMSubtreeModified', blockOnDebouncedDOMEvents);

function blockOnDebouncedDOMEvents() {
	console.log("detected dom subtree modifiedcation");
	var content = document.getElementById('content');
	if (content != null) {
		content.removeEventListener('DOMSubtreeModified', blockOnDebouncedDOMEvents);
		setTimeout(function () {
				blockIfFree();<commit_msg>divide by 2 to mitigate dupes, show counter in masthead<commit_after>submitHit();

chrome.runtime.sendMessage({requestSettings: true}, function(res) {
	freedom = res.freedom;
	distractions = res.distractions;
	blockIfFree();
	fetchVisits();
});

function fetchVisits() {
	chrome.runtime.sendMessage({requestVisits: true}, function(res) {
		console.log(res);

		var logoBox = document.getElementById("yt-masthead").getElementsByClassName("yt-masthead-logo-container")[0];
		if (logoBox != null) {
			var logoMetric = document.createTextNode(res.visits.length/2);
			var logoMetricBox = document.createElement("div");
			logoMetricBox.setAttribute("style", "margin: 5px; background-color: #cc181e; color: #FFFFFF; display: inline; border-radius: 3px; padding: 5px; position:relative; top: 2px; font-weight: bold;");
			logoMetricBox.appendChild(logoMetric)
			logoBox.appendChild(logoMetricBox);
		}

		var counterBox = document.getElementById('turkey-counter');
		if (counterBox != null) {
			var counterMetric = document.createTextNode("You've visited YouTube " + res.visits.length/2 + " times today.");
			counterBox.appendChild(counterMetric);
		}

		var graphsBox = document.getElementById('turkey-graphs');
		if (graphsBox != null) {
			var timeList = [];
			for (var i = 0; i < res.visits.length; i++) {
				var time = getTimeStringFromTimestamp(res.visits[i].visitTime);
				if (timeList.length === 0) {
					timeList.push(time);
				} else if (timeList.length > 0 && time != timeList[timeList.length-1]) {
					timeList.push(time);
				}
			}
			var timeMetric = document.createTextNode("Your visits occurred at these times: " + timeList.join(", "));
			graphsBox.appendChild(timeMetric);
		}
	});
}

document.getElementById('content').addEventListener('DOMSubtreeModified', blockOnDebouncedDOMEvents);

function blockOnDebouncedDOMEvents() {
	console.log("detected dom subtree modifiedcation");
	var content = document.getElementById('content');
	if (content != null) {
		content.removeEventListener('DOMSubtreeModified', blockOnDebouncedDOMEvents);
		setTimeout(function () {
				blockIfFree();
{'fraction_non_alphanumeric': 0.14301490889011595, 'fraction_numerical': 0.005245720596355604, 'mean_word_length': 5.140677966101695, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4448191', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1082, 'n_words': 216}