Social Fixer Hacks
All diffs are currently relative to socialfixer.user.js v7.601. For readability,
leading whitespace has been trimmed (so they won't apply directly — applying
by hand is better anyway as some of these are hackish and might be better done
differently).
I'm currently running SFx
under the
Scriptish
extension 0.1.8 in Mozilla SeaMonkey 2.17.1.
Does not detect any comments for most posts below the fold
Pressing the SFx debug button usually reveals "Comments found=0" for any
post that was below the "More Stories" link. Consequently, these posts
don't reappear as they should when they have new comments.
I surmise that this is because Facebook is loading the comments "lazily", and so they
aren't present in the copy of the post that SFx gets to inspect when it arrives.
My rather hackish solution is to wait half a second before processing each post.
It's nasty, but it works.
In fact it looks like this may also work with the timeout set to zero
(the Interwebs inform me that this is equivalent to doing a "thread/process yield").
--- 7.601/socialfixer.user.js 2013-06-24 14:36:05.000000000 +0100
+++ new/socialfixer.user.js 2013-06-25 14:30:39.317128000 +0100
@@ -3264,6 +3264,6 @@
}
return false;
}
-bind(document,"DOMNodeInserted", function (e) {
+function dom_node_inserted(e) {
var f,id,selector,el,els;
var o = target(e);
@@ -3301,7 +3301,8 @@
}
-});
+}
+bind(document,"DOMNodeInserted", function(e) {setTimeout(function(){dom_node_inserted(e);},500)});
// ==================================================================
// Kill the "Theater" photo viewer
However, one side-effect of this is that the event "better_fb_friend_tracker_pagelet
"
seems to trigger itself recursively. I'm monitoring this as follows (warning, very hackish indeed):
@@ -5346,7 +5353,8 @@
else {
insertAtPosition( feed_right_column, section, 2 );
}
- onIdLoad('better_fb_friend_tracker_pagelet', function(){ setTimeout(loadContent,10); });
+ var ftpctr=0;
+ onIdLoad('better_fb_friend_tracker_pagelet', function(){ GM_log("better_fb_friend_tracker_pagelet " + ++ftpctr); if (ftpctr<2)setTimeout(loadContent,10); });
}
}
} catch(e) { add_error("Friend Tracker Error",e.toString()); }
Does not correctly understand "View x more comments"
A few months ago Facebook stopped saying "View all x comments" and started saying
"View x more comments" instead. SFx can't get the total number of comments in the
latter case.
@@ -4422,5 +4423,11 @@
}
return view_all_count + new_comment_count;
}
+if ( /view ([,.\d]+) more comment/i.test(c.innerHTML) ) {
+ var comment_count = +(RegExp.$1.replace(/[,.]/g,""));
+ var comments = QSA(c,comment_selector);
+ if (comments) comment_count += comments.length;
+ return comment_count;
+}
var pager_row = QS(c,'.UFIPagerRow');
if (pager_row) {
Does not correctly understand "x of y" comments
This seems to be mostly because of typos in the code.
@@ -4425,8 +4432,8 @@
var pager_row = QS(c,'.UFIPagerRow');
if (pager_row) {
- var counter = QS(pager_row,'.rfloat,.fcg');
+ var counter = QS(pager_row,'.rfloat .fcg');
if (counter) {
- var count = match(counter.innerHTML,'/\s+\s+of\s+(\d+)/');
+ var count = match(counter.innerHTML,/\d+\s+of\s+(\d+)/);
if (count) {
return count;
}
Live timestamp updates cause browser slowness
Assuming "Fix timestamps to show actual date/time" is not enabled,
Facebook periodically sends live timestamp updates for every timestamp
currently on the screen. Each of these causes an insertion event that
SFx tries to process, and this can eat up processing time, particularly
when a lot of posts and comments have been expanded. Telling SFx not
to process these events significantly reduces processing time and does
not seem to have any adverse effects.
@@ -3254,7 +3254,7 @@
var ignoreMutation = function(o) {
var tn = o.tagName;
if (o.nodeType==3 || internalUpdate) { return true; }
- if (tn=="SCRIPT" || tn=="LINK" || tn=="INPUT" || tn=="BR" || tn=="STYLE" || tn=="META") { return true; }
+ if (tn=="SCRIPT" || tn=="LINK" || tn=="INPUT" || tn=="BR" || tn=="STYLE" || tn=="META" || tn=="ABBR") { return true; }
var cn = o.className, pn=o.parentNode, pcn="";
if (pn&&pn.className) {
pcn = pn.className;
TypeError: o is null
For some reason, the DOMNodeInserted event sometimes seems to trigger
with a null target (maybe a browser bug? Possibly a side-effect of the
first fix on this page?). It does no harm to guard against this.
@@ -3268,6 +3268,6 @@
var f,id,selector,el,els;
var o = target(e);
-if (ignoreMutation(o)) { return; }
+if (!o || ignoreMutation(o)) { return; }
if (options.get("fix_timestamps")) {
fix_timestamps(o);
Finding the child node count
A comment in the SFx source code says...
// So we stored the childNode length and compare it later when marking as read. Yuck
...but it appears to calculate it wrongly by using QS (return the first comment) instead of
QSA (return all comments). It's not clear whether this code is still relevant,
but it may as well be less wrong.
@@ -4129,7 +4130,7 @@
// So we stored the childNode length and compare it later when marking as read. Yuck!
// cnc = childNodeCount
post_data.cnc = 0;
-if (c) { post_data.cnc = (QS(c,comment_selector)||[]).length; }
+if (c) { post_data.cnc = (QSA(c,comment_selector)||[]).length; }
// But not if the user has disabled following of comments
var new_comments_exist = false;