diff --git a/content/reddit/redditBar.xml b/content/reddit/redditBar.xml
index 8865d47..02d0f50 100644
--- a/content/reddit/redditBar.xml
+++ b/content/reddit/redditBar.xml
@@ -5,6 +5,7 @@
<binding id="reddit-content-ui" extends="chrome://socialite/content/socialiteBar.xml#socialite-site-content-ui">
<content>
+
<xul:hbox anonid="reddit-content-ui-container" class="socialite-login-state" xbl:inherits="isloggedin" flex="1" align="center">
<xul:box tooltip="_child">
<!-- A parent box element seems to be necessary to make tooltips work.-->
@@ -14,6 +15,7 @@
<xul:description anonid="descriptionTitle" class="socialite-title" flex="1"/>
<xul:label anonid="labelSubreddit" class="reddit-subreddit"/>
<xul:spacer flex="9999"/>
+
<xul:hbox anonid="boxButtons" class="buttonbox" align="stretch">
<xul:button anonid="buttonLike" class="socialite-notification-button socialite-logged-in" type="checkbox" label="&like.label;" accesskey="&like.accesskey;" autoCheck="false"/>
<xul:button anonid="buttonDislike" class="socialite-notification-button socialite-logged-in" type="checkbox" label="&dislike.label;" accesskey="&dislike.accesskey;" autoCheck="false"/>
@@ -31,13 +33,14 @@
</xul:hbox>
</xul:hbox>
</content>
-
- <resources>
+
+ <resources>
<stylesheet src="chrome://global/skin/button.css"/>
<stylesheet src="chrome://socialite/skin/socialite.css"/>
<stylesheet src="chrome://socialite/skin/socialite_platform.css"/>
<stylesheet src="chrome://socialite/skin/reddit.css"/>
- </resources>
+ </resources>
+
<implementation>
<field name="afterBound"/>
@@ -174,6 +177,7 @@
// Like button
if (this.linkInfo.localState.isLiked == true) {
+
this.buttonLike.image = "chrome://socialite/content/reddit/upmod.png";
this.buttonLike.checked = true;
} else {
@@ -210,13 +214,14 @@
// Helper for similar buttons to follow
var self = this;
function updateButton(button, image, text) {
+
if (self.compactDisplay) {
if (button._oldClassName == null) {
button._oldClassName = button.className;
button.className = button.className + " socialite-button-compact socialite-button-iconic";
}
if (text) { button.tooltipText = text; }
- if (image) { button.image = image; }
+ if (image) {button.image = image;}
} else {
if (button._oldClassName != null) {
button.className = button._oldClassName;
@@ -269,11 +274,12 @@
<children/>
</xul:hbox>
</content>
-
+
<resources>
<stylesheet src="chrome://socialite/skin/socialite.css"/>
<stylesheet src="chrome://socialite/skin/reddit.css"/>
</resources>
+
<implementation>
<field name="afterBound"/>
diff --git a/content/siteInfoBox.xml b/content/siteInfoBox.xml
index e2bdde5..883d12d 100644
--- a/content/siteInfoBox.xml
+++ b/content/siteInfoBox.xml
@@ -39,16 +39,17 @@
}
</constructor>
- <destructor>
- this.destroySiteInfoBox();
- </destructor>
-
- <method name="destroySiteInfoBox">
+ <method name="destroySiteInfoBox">
<body>
if (this._removeFaviconWatch) { this._removeFaviconWatch(); }
</body>
</method>
+ <destructor>
+ this.destroySiteInfoBox();
+ </destructor>
+
+
<method name="updateSiteName">
<body>
this.name = this.site.siteName;
@@ -141,4 +142,4 @@
</handler>
</handlers>
</binding>
-</bindings>
\ No newline at end of file
+</bindings>
diff --git a/content/socialiteBar.xml b/content/socialiteBar.xml
index 57bfd23..585b713 100644
--- a/content/socialiteBar.xml
+++ b/content/socialiteBar.xml
@@ -27,7 +27,7 @@
oncommand="document.getBindingParent(this).closeClicked();"/>
</xul:hbox>
</content>
-
+
<resources>
<stylesheet src="chrome://global/skin/notification.css"/>
</resources>
@@ -114,11 +114,11 @@
oncommand="document.getBindingParent(this).closeClicked();"/>
</xul:hbox>
</content>
-
+
<resources>
<stylesheet src="chrome://socialite/skin/socialite.css"/>
</resources>
-
+
<implementation>
<field name="url"/>
@@ -262,11 +262,11 @@
oncommand="document.getBindingParent(this).closeClicked();"/>
</xul:hbox>
</content>
-
+
<resources>
<stylesheet src="chrome://socialite/skin/socialite.css"/>
</resources>
-
+
<implementation>
<field name="url"/>
@@ -320,10 +320,11 @@
</binding>
<binding id="socialite-site-ui">
+
<resources>
<stylesheet src="chrome://socialite/skin/socialite_platform.css"/>
</resources>
-
+
<implementation>
<field name="siteID"/>
@@ -380,13 +381,13 @@
</xul:toolbarbutton>
</xul:hbox>
</content>
-
+
<resources>
<stylesheet src="chrome://socialite/skin/socialite.css"/>
<stylesheet src="chrome://socialite/skin/socialite_platform.css"/>
<stylesheet src="chrome://global/skin/notification.css"/>
</resources>
-
+
<implementation>
<field name="siteItems"/>
<field name="selectedSite"/>
diff --git a/install.rdf b/install.rdf
index 90a9555..4fe031c 100644
--- a/install.rdf
+++ b/install.rdf
@@ -5,10 +5,10 @@
<RDF:Description RDF:about="rdf:#$tddXp3"
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
em:minVersion="3.0"
- em:maxVersion="3.5.*" />
+ em:maxVersion="4.*" />
<RDF:Description RDF:about="urn:mozilla:install-manifest"
em:id="socialite@chromakode"
- em:version="1.3.3.8pre1"
+ em:version="1.4"
em:type="2"
em:iconURL="chrome://socialite/skin/socialite.png"
em:optionsURL="chrome://socialite/content/socialitePreferences.xul">
diff --git a/modules/migration.jsm b/modules/migration.jsm
index 5b3a058..c18e21d 100644
--- a/modules/migration.jsm
+++ b/modules/migration.jsm
@@ -7,16 +7,20 @@ let versionCompare = Components.classes["@mozilla.org/xpcom/version-comparator;1
.getService(Components.interfaces.nsIVersionComparator)
.compare;
-let extensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
- .getService(Components.interfaces.nsIExtensionManager);
+let extensionManager =null;
+try{
+ extensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
+ .getService(Components.interfaces.nsIExtensionManager);
+}catch(err){
+ Components.utils.import("resource://gre/modules/AddonManager.jsm");
+}
+
let EXTENSION_ID = "socialite@chromakode";
-var SocialiteMigration = {
- perform: function() {
- let currentVersion = extensionManager.getItemForID(EXTENSION_ID).version;
-
- let lastVersion;
+
+function migrate(currentVersion){
+ let lastVersion;
if (Socialite.preferences.prefHasUserValue("lastVersion")) {
lastVersion = Socialite.preferences.getCharPref("lastVersion");
} else {
@@ -49,5 +53,18 @@ var SocialiteMigration = {
// Update the record of the last version seen
Socialite.preferences.setCharPref("lastVersion", currentVersion);
}
+}
+
+function callback(addon){
+migrate(addon.version);
+}
+
+var SocialiteMigration = {
+ perform: function() {
+ try{
+ AddonManager.getAddonByID(EXTENSION_ID,callback);
+ }catch(err){
+ migrate(extensionManager.getItemForID(EXTENSION_ID).version);
+ }
}
-};
\ No newline at end of file
+};
diff --git a/modules/reddit/authentication.jsm b/modules/reddit/authentication.jsm
index f6121fa..6d55972 100644
--- a/modules/reddit/authentication.jsm
+++ b/modules/reddit/authentication.jsm
@@ -101,28 +101,31 @@ function extractAuthInfo(document) {
username: extractUsername(document),
modhash: extractModHash(document)
};
+
authInfo.isLoggedIn = (authInfo.username != false) && (authInfo.username != null) && (authInfo.modhash != "");
return authInfo;
}
function extractModHash(document) {
try {
- let globalsCode = document.getElementsByTagName("script")[0].textContent;
+ let globalsCode = document.getElementsByTagName("script")[1].textContent;
const getModHash = /modhash\s*(?:\:|=)\s*'(\w*)'/;
return globalsCode.match(getModHash)[1];
} catch (e) {
+
logger.log("reddit_auth", this.siteURL, "Unable to parse page for user hash: " + e.toString());
return null;
}
}
function extractUsername(document) {
+
// Get the username
try {
- let globalsCode = document.getElementsByTagName("script")[0].textContent;
+ let globalsCode = document.getElementsByTagName("script")[1].textContent;
const getUsername = /logged\s*(?:\:|=)\s*('(\w+)'|false)/;
-
+
let username;
let [match, outer, inner] = globalsCode.match(getUsername);
if (outer == "false") {
diff --git a/modules/utils/action/action.jsm b/modules/utils/action/action.jsm
index 4937c89..aaec9a7 100644
--- a/modules/utils/action/action.jsm
+++ b/modules/utils/action/action.jsm
@@ -64,6 +64,7 @@ ActionType.prototype = {
addToArgs: function(args) {
// Arguments contain the arguments passed to this function, with this action object at the end.
+
var newargs = Array.prototype.splice.call(args, 0) || [];
if ((newargs.length == 0) || (newargs[newargs.length-1] != this)) {
newargs.push(this);
@@ -88,14 +89,14 @@ ActionType.prototype = {
success: function() {
logger.log("action", this.name + " succeeded");
let result = this.doCallback(this.successCallback, arguments);
- this.doCallback(this.finallyCallback);
+ this.doCallback(this.finallyCallback,arguments);
return result;
},
failure: function() {
logger.log("action", this.name + " failed");
let result = this.doCallback(this.failureCallback, arguments);
- this.doCallback(this.finallyCallback);
+ this.doCallback(this.finallyCallback,arguments);
return result;
},
diff --git a/modules/utils/log.jsm b/modules/utils/log.jsm
index c0d1749..37c7ad3 100644
--- a/modules/utils/log.jsm
+++ b/modules/utils/log.jsm
@@ -12,6 +12,7 @@ logSettings = null;
logHistory = [];
function init(appname, settings) {
+
if (!logInitialized) {
if (settings) {
logSettings = settings;
@@ -42,6 +43,7 @@ function log() {
} else if (arguments.length == 3) {
entry = {section: arguments[0], identifier: arguments[1], msg: arguments[2]};
}
+
if (logSettings.enabled) {
let logText = formatEntry(entry);