diff --git a/content/treestyletab/treestyletab.xul b/content/treestyletab/treestyletab.xul
index e0bee6ce..4dafd284 100644
--- a/content/treestyletab/treestyletab.xul
+++ b/content/treestyletab/treestyletab.xul
@@ -16,7 +16,6 @@
-
diff --git a/content/treestyletab/res/UninstallationListener.js b/modules/lib/UninstallationListener.js
similarity index 83%
rename from content/treestyletab/res/UninstallationListener.js
rename to modules/lib/UninstallationListener.js
index 92fceafa..c8fb7959 100644
--- a/content/treestyletab/res/UninstallationListener.js
+++ b/modules/lib/UninstallationListener.js
@@ -13,6 +13,24 @@
original:
http://github.com/piroor/fxaddonlibs/blob/master/UninstallationListener.js
*/
+
+/* To work as a JS Code Module */
+if (typeof window == 'undefined' ||
+ (window && typeof window.constructor == 'function')) {
+ this.EXPORTED_SYMBOLS = ['UninstallationListener'];
+
+ // If namespace.jsm is available, export symbols to the shared namespace.
+ // See: http://github.com/piroor/fxaddonlibs/blob/master/namespace.jsm
+ try {
+ let ns = {};
+ Components.utils.import('resource://my-modules/namespace.jsm', ns);
+ /* var */ window = ns.getNamespaceFor('piro.sakura.ne.jp');
+ }
+ catch(e) {
+ window = {};
+ }
+}
+
(function() {
const currentRevision = 2;
@@ -165,3 +183,7 @@
}
};
})();
+
+if (window != this) { // work as a JS Code Module
+ this.UninstallationListener = window['piro.sakura.ne.jp'].UninstallationListener;
+}
diff --git a/modules/window.js b/modules/window.js
index b7af1115..d6c48627 100644
--- a/modules/window.js
+++ b/modules/window.js
@@ -42,6 +42,9 @@ Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this, "prefs",
'resource://treestyletab-modules/lib/prefs.js');
+XPCOMUtils.defineLazyModuleGetter(this, 'UninstallationListener',
+ 'resource://treestyletab-modules/lib/UninstallationListener.js');
+
XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
Components.utils.import('resource://treestyletab-modules/base.js');
@@ -410,7 +413,7 @@ TreeStyleTabWindow.prototype = {
prefs.clearPref(pref+'.backup');
}
}.bind(this);
- new this.window['piro.sakura.ne.jp'].UninstallationListener({
+ new UninstallationListener({
id : 'treestyletab@piro.sakura.ne.jp',
onuninstalled : restorePrefs,
ondisabled : restorePrefs