<commit_before>/**
 * Twitter Refresh
 * @author <NAME>
 * @version 1.0
 */
var TwitterRefresh = {

	init: function () {
		var self = this;

		function getNewItemsBar() {
			var newItemsBar = document.getElementsByClassName("js-new-items-bar-container");

			if (newItemsBar.length) {
				document.removeEventListener("DOMSubtreeModified", getNewItemsBar);
				self.setNewItemsBar(newItemsBar[0]);
			}
		}

		// Listen for changes to the document in order to find the new-items bar
		document.addEventListener("DOMSubtreeModified", getNewItemsBar);

		return this;
	},

	addToggleButton: function() {
		var globalActions = document.getElementById("global-actions");

		if (globalActions) {
			var li   = document.createElement("li");
			var a    = document.createElement("a");
			var icon = document.createElement("span");
			var text = document.createElement("span");

			this.refreshIcon = icon;
			this.setColorOfRefreshIcon();

			// Setup elements
			icon.className = "Icon Icon--refresh Icon--large";
			text.className = "text";
			a.className    = "js-tooltip js-dynamic-tooltip";
			a.setAttribute("href", "#");
			a.setAttribute("data-nav", "auto-refresh");
			a.setAttribute("data-placement", "bottom");
			a.addEventListener("click", this.toggleAutoRefresh.bind(this));

			// Append elements to the document
			text.appendChild(document.createTextNode("Auto-Refresh"));
			a.appendChild(icon);
			a.appendChild(text);
			li.appendChild(a);
			globalActions.appendChild(li);
		}
	},

	enabled: function (setting) {

		if (setting === true) {
			localStorage.setItem("twitterAutoRefresh", "true");
			this.refreshTimeline();
			return true;
		} else if (setting === false) {
			localStorage.setItem("twitterAutoRefresh", "false");
			return false;
		}

		return localStorage.getItem("twitterAutoRefresh") === "false" ? false : true;
	},

	refreshTimeline: function () {
		var newTweets = this.newItemsBar.getElementsByClassName("js-new-tweets-bar");

		if (newTweets.length && this.enabled()) {
			newTweets[0].click();
		}
	},

	setColorOfRefreshIcon: function () {

		if (this.enabled()) {
			this.refreshIcon.style.color = "";
		} else {
			this.refreshIcon.style.color = "#CCCCCC";<commit_msg>Fixed an issue where home icon status was not updating correctly<commit_after>/**
 * Twitter Refresh
 * @author <NAME>
 * @version 1.0
 */
var TwitterRefresh = {

	init: function () {
		var self = this;

		function getNewItemsBar() {
			var newItemsBar = document.getElementsByClassName("js-new-items-bar-container");

			if (newItemsBar.length) {
				document.removeEventListener("DOMSubtreeModified", getNewItemsBar);
				self.setNewItemsBar(newItemsBar[0]);
			}
		}

		// Listen for changes to the document in order to find the new-items bar
		document.addEventListener("DOMSubtreeModified", getNewItemsBar);

		return this;
	},

	addToggleButton: function() {
		var globalActions = document.getElementById("global-actions");

		if (globalActions) {
			var li   = document.createElement("li");
			var a    = document.createElement("a");
			var icon = document.createElement("span");
			var text = document.createElement("span");

			this.refreshIcon = icon;
			this.setColorOfRefreshIcon();

			// Setup elements
			icon.className = "Icon Icon--refresh Icon--large";
			text.className = "text";
			a.className    = "js-tooltip js-dynamic-tooltip";
			a.setAttribute("href", "#");
			a.setAttribute("data-nav", "auto-refresh");
			a.setAttribute("data-placement", "bottom");
			a.addEventListener("click", this.toggleAutoRefresh.bind(this));

			// Append elements to the document
			text.appendChild(document.createTextNode("Toggle Auto-Refresh"));
			a.appendChild(icon);
			a.appendChild(text);
			li.appendChild(a);
			globalActions.appendChild(li);
		}
	},

	enabled: function (setting) {

		if (setting === true) {
			localStorage.setItem("twitterAutoRefresh", "true");
			this.refreshTimeline();
			return true;
		} else if (setting === false) {
			localStorage.setItem("twitterAutoRefresh", "false");
			return false;
		}

		return localStorage.getItem("twitterAutoRefresh") === "false" ? false : true;
	},

	refreshTimeline: function () {
		var newTweets = this.newItemsBar.getElementsByClassName("js-new-tweets-bar");

		if (newTweets.length && this.enabled()) {

			window.setTimeout(function () {
				var clickEvent = new MouseEvent("click", {
					view:       window,
					bubbles:    true,
					cancelable: true
				});
				newTweets[0].dispatchEvent(clickEvent);
			}, 100);
		}
	},

	setColorOfRefreshIcon: function () {

		if (this.enabled()) {
			this.refreshIcon.style.color = "";
		} else {
			this.refreshIcon.style.color = "#CCCCCC";
{'fraction_non_alphanumeric': 0.1480925846549507, 'fraction_numerical': 0.002357479639948564, 'mean_word_length': 3.9490986214209967, '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': '5585148', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1402, 'n_words': 286}