<commit_before>const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
var Application = Cc["@mozilla.org/fuel/application;1"].getService(Components.interfaces.fuelIApplication);
Cu.import("resource:///modules/CustomizableUI.jsm");

/* require -- based off of <NAME>'s require.js */
(function(global) {
	var modules = {};
	global.require = function require(src) {
		if (modules[src])
			return modules[src];
		var scope = {require: global.require, Cu: global.Cu, Ci: global.Ci, Cc: global.Cc, exports: {}};
		var tools = {};
		Cu.import("resource://gre/modules/Services.jsm", tools);
		var baseURI = tools.Services.io.newURI(__SCRIPT_URI_SPEC__, null, null);
		var uri = tools.Services.io.newURI(src, null, baseURI);
		tools.Services.scriptloader.loadSubScript(uri.spec, scope);
		return modules[src] = scope.exports || scope.module.exports;
	};
})(this);

function loadIntoWindow(window) {
	if (window.document.documentElement.getAttribute("windowtype") !== "navigator:browser")
		return;
	try {
	require("content/addonbar.js").load(window);
	} catch (e) {
		window.console.log(e);
	}
}

function unloadFromWindow(window) {
	if (window.document.documentElement.getAttribute("windowtype") !== "navigator:browser")
		return;
		require("content/addonbar.js").unload(window);
}

var windowListener = {
  onOpenWindow: function(aWindow) {
    // Wait for the window to finish loading
    let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
    domWindow.addEventListener("load", function onLoad() {
      domWindow.removeEventListener("load", onLoad, false);
      loadIntoWindow(domWindow);
    }, false);
  },

  onCloseWindow: function(aWindow) {},
  onWindowTitleChange: function(aWindow, aTitle) {}
};

function startup(aData, aReason) {
	if (aReason === ADDON_ENABLE || aReason === ADDON_INSTALL || aReason === ADDON_UPGRADE) {
		Application.prefs.setValue("extensions.GiTAddonBar.remigrate", true);
	}
	require("content/preferences.js").load();
	require("content/statedui.js").load();

	if (aReason === ADDON_UPGRADE) {
		let version = aData.oldVersion.replace(/[A-z]/g, "").split(".");
		if (parseInt(version[0]) <= 3 && parseInt(version[1]) <= 1) {
			CustomizableUI.createWidget({id: "GiT-addon-bar-spring", type: "button"});
			let placement = CustomizableUI.getPlacementOfWidget("GiT-addon-bar-spring");
			if (placement) {
				CustomizableUI.removeWidgetFromArea("GiT-addon-bar-spring");
				CustomizableUI.addWidgetToArea("spring", placement.area, placement.position);
			}
			CustomizableUI.destroyWidget("GiT-addon-bar-spring");
		}
	}

  let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);

  // Load into any existing windows
  let windows = wm.getEnumerator("navigator:browser");
  while (windows.hasMoreElements()) {
    let domWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
    loadIntoWindow(domWindow);
  }
<commit_msg>Fixes #4 - Improperly remigrates old icons...etc.<commit_after>const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
var Application = Cc["@mozilla.org/fuel/application;1"].getService(Components.interfaces.fuelIApplication);
Cu.import("resource:///modules/CustomizableUI.jsm");

/* require -- based off of <NAME>'s require.js */
(function(global) {
	var modules = {};
	global.require = function require(src) {
		if (modules[src])
			return modules[src];
		var scope = {require: global.require, Cu: global.Cu, Ci: global.Ci, Cc: global.Cc, exports: {}};
		var tools = {};
		Cu.import("resource://gre/modules/Services.jsm", tools);
		var baseURI = tools.Services.io.newURI(__SCRIPT_URI_SPEC__, null, null);
		var uri = tools.Services.io.newURI(src, null, baseURI);
		tools.Services.scriptloader.loadSubScript(uri.spec, scope);
		return modules[src] = scope.exports || scope.module.exports;
	};
})(this);

function loadIntoWindow(window) {
	if (window.document.documentElement.getAttribute("windowtype") !== "navigator:browser")
		return;
	try {
	require("content/addonbar.js").load(window);
	} catch (e) {
		window.console.log(e);
	}
}

function unloadFromWindow(window) {
	if (window.document.documentElement.getAttribute("windowtype") !== "navigator:browser")
		return;
		require("content/addonbar.js").unload(window);
}

var windowListener = {
  onOpenWindow: function(aWindow) {
    // Wait for the window to finish loading
    let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
    domWindow.addEventListener("load", function onLoad() {
      domWindow.removeEventListener("load", onLoad, false);
      loadIntoWindow(domWindow);
    }, false);
  },

  onCloseWindow: function(aWindow) {},
  onWindowTitleChange: function(aWindow, aTitle) {}
};

function startup(aData, aReason) {
	let version = (aData.oldVersion || "").replace(/[A-z]/g, "").split(".");
	if (aReason === ADDON_ENABLE || aReason === ADDON_INSTALL
			|| (aReason === ADDON_UPGRADE && parseInt(version[0]) <= 1 && parseInt(version[1]) <= 7) ) {
		Application.prefs.setValue("extensions.GiTAddonBar.remigrate", true);
	}
	require("content/preferences.js").load();
	require("content/statedui.js").load();

	if (aReason === ADDON_UPGRADE) {
		if (parseInt(version[0]) <= 3 && parseInt(version[1]) <= 1) {
			CustomizableUI.createWidget({id: "GiT-addon-bar-spring", type: "button"});
			let placement = CustomizableUI.getPlacementOfWidget("GiT-addon-bar-spring");
			if (placement) {
				CustomizableUI.removeWidgetFromArea("GiT-addon-bar-spring");
				CustomizableUI.addWidgetToArea("spring", placement.area, placement.position);
			}
			CustomizableUI.destroyWidget("GiT-addon-bar-spring");
		}
	}

  let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);

  // Load into any existing windows
  let windows = wm.getEnumerator("navigator:browser");
  while (windows.hasMoreElements()) {
    let domWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
    loadIntoWindow(domWindow);
  }

{'fraction_non_alphanumeric': 0.16161285035240125, 'fraction_numerical': 0.0027864284543517455, 'mean_word_length': 5.1326633165829145, 'pattern_counts': {'":': 0, '<': 11, '<?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': '2179293', 'n_tokens_mistral': 2104, 'n_tokens_neox': 1981, 'n_words': 338}