Revert Mayhem's unread scrolling changes

Too buggy. Threads often don't scroll at all.
This commit is contained in:
Jordan Bates 2013-05-15 02:43:35 -07:00
parent 514450be9b
commit 68678e671a
5 changed files with 31 additions and 57 deletions

View File

@ -1,5 +1,5 @@
/* /*
* 4chan X - Version 1.2.4 - 2013-05-14 * 4chan X - Version 1.2.4 - 2013-05-15
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE

View File

@ -19,7 +19,7 @@
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.2.4 - 2013-05-14 * 4chan X - Version 1.2.4 - 2013-05-15
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -7574,13 +7574,12 @@
} }
} }
Unread.addPosts(posts); Unread.addPosts(posts);
if (!Conf['Scroll to Last Read Post']) { if (Conf['Scroll to Last Read Post']) {
return; return Unread.scroll();
} }
return Unread.scroll();
}, },
scroll: function() { scroll: function() {
var hash, onload, post, posts, prevID, root; var hash, post, posts, prevID, root;
if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) { if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) {
return; return;
@ -7597,17 +7596,11 @@
break; break;
} }
} }
onload = function() { root.scrollIntoView(false);
return root.scrollIntoView(false); return;
};
} else {
posts = Object.keys(Unread.thread.posts);
post = Unread.thread.posts[posts[posts.length - 1]];
onload = function() {
return Header.scrollToPost(post.nodes.root);
};
} }
return $.on(window, 'load', onload); posts = Object.keys(Unread.thread.posts);
return Header.scrollToPost(Unread.thread.posts[posts[posts.length - 1]].nodes.root);
}, },
sync: function() { sync: function() {
var lastReadPost; var lastReadPost;

View File

@ -19,7 +19,7 @@
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.2.4 - 2013-05-14 * 4chan X - Version 1.2.4 - 2013-05-15
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -7583,13 +7583,12 @@
} }
} }
Unread.addPosts(posts); Unread.addPosts(posts);
if (!Conf['Scroll to Last Read Post']) { if (Conf['Scroll to Last Read Post']) {
return; return Unread.scroll();
} }
return Unread.scroll();
}, },
scroll: function() { scroll: function() {
var hash, onload, post, posts, prevID, root; var hash, post, posts, prevID, root;
if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) { if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) {
return; return;
@ -7606,17 +7605,11 @@
break; break;
} }
} }
onload = function() { root.scrollIntoView(false);
return root.scrollIntoView(false); return;
};
} else {
posts = Object.keys(Unread.thread.posts);
post = Unread.thread.posts[posts[posts.length - 1]];
onload = function() {
return Header.scrollToPost(post.nodes.root);
};
} }
return $.on(window, 'load', onload); posts = Object.keys(Unread.thread.posts);
return Header.scrollToPost(Unread.thread.posts[posts[posts.length - 1]].nodes.root);
}, },
sync: function() { sync: function() {
var lastReadPost; var lastReadPost;

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript // Generated by CoffeeScript
/* /*
* 4chan X - Version 1.2.4 - 2013-05-14 * 4chan X - Version 1.2.4 - 2013-05-15
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -7561,13 +7561,12 @@
} }
} }
Unread.addPosts(posts); Unread.addPosts(posts);
if (!Conf['Scroll to Last Read Post']) { if (Conf['Scroll to Last Read Post']) {
return; return Unread.scroll();
} }
return Unread.scroll();
}, },
scroll: function() { scroll: function() {
var hash, onload, post, posts, prevID, root; var hash, post, posts, prevID, root;
if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) { if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) {
return; return;
@ -7584,17 +7583,11 @@
break; break;
} }
} }
onload = function() { root.scrollIntoView(false);
return root.scrollIntoView(false); return;
};
} else {
posts = Object.keys(Unread.thread.posts);
post = Unread.thread.posts[posts[posts.length - 1]];
onload = function() {
return Header.scrollToPost(post.nodes.root);
};
} }
return $.on(window, 'load', onload); posts = Object.keys(Unread.thread.posts);
return Header.scrollToPost(Unread.thread.posts[posts[posts.length - 1]].nodes.root);
}, },
sync: function() { sync: function() {
var lastReadPost; var lastReadPost;

View File

@ -30,8 +30,7 @@ Unread =
for ID, post of Unread.thread.posts for ID, post of Unread.thread.posts
posts.push post if post.isReply posts.push post if post.isReply
Unread.addPosts posts Unread.addPosts posts
return unless Conf['Scroll to Last Read Post'] Unread.scroll() if Conf['Scroll to Last Read Post']
Unread.scroll()
scroll: -> scroll: ->
# Let the header's onload callback handle it. # Let the header's onload callback handle it.
@ -44,15 +43,11 @@ Unread =
break if prevID is post.ID break if prevID is post.ID
prevID = post.ID prevID = post.ID
break unless post.isHidden break unless post.isHidden
onload = -> root.scrollIntoView false root.scrollIntoView false
else return
# Scroll to the last read post. # Scroll to the last read post.
posts = Object.keys Unread.thread.posts posts = Object.keys Unread.thread.posts
post = Unread.thread.posts[posts[posts.length - 1]] Header.scrollToPost Unread.thread.posts[posts[posts.length - 1]].nodes.root
onload = -> Header.scrollToPost post.nodes.root
# Prevent the browser to scroll back to
# the previous scroll location on page load.
$.on window, 'load', onload
sync: -> sync: ->
lastReadPost = Unread.db.get lastReadPost = Unread.db.get