Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

always sort friends in the sidebar; remember sidebar state between se…

…ssions

This is necessary since Twitter folks decided it should be hidden by default
and to get them an ajax request has to be issued. This uses jQuery global
Ajax events to detect this load and act after it.
  • Loading branch information...
commit 4c0f7f919626caac0d544ceae5d7608660695592 1 parent cf51ea4
@mislav authored
Showing with 34 additions and 17 deletions.
  1. +15 −2 endless_tweets/endless_tweets.js
  2. +19 −15 endless_tweets/friends.js
View
17 endless_tweets/endless_tweets.js
@@ -11,6 +11,7 @@
//= toolkit/gm_functions.js
var timeline = $('timeline'),
+ sidebar = $('side'),
jQuery = realWindow.jQuery,
twttr = realWindow.twttr,
pageTracker = realWindow._gat && realWindow._gat._getTracker("UA-87067-6"),
@@ -279,9 +280,22 @@ function onAvatarLoad(data, callback) {
//= friends.js
+var jQueryOldCookie = jQuery.cookie
+jQuery.cookie = function(name, value, options) {
+ if (value && name == "menus" && !(options && options.expires)) {
+ if (!options) options = {}
+ options.expires = 365
+ }
+ jQueryOldCookie(name, value, options)
+}
+
+jQuery(sidebar).bind("ajaxSuccess", function(e, xhr, ajax){
+ if (ajax.url == "/timeline/render_following_avatars") sortFriends()
+})
+
// *** iPhone location map *** //
-var address = find(null, '#side .vcard .adr')
+var address = find(sidebar, '.vcard .adr')
if (address && /[+-]?\d+\.\d+,[+-]?\d+\.\d+/.test(address.textContent)) {
var API_KEY = 'ABQIAAAAfOaovFhDnVE3QsBZj_YthxSnhvsz13Tv4UkZBHR3eJwOymtuUxT045UEYNAo1HL_pePrMexH4SYngg',
@@ -295,7 +309,6 @@ if (address && /[+-]?\d+\.\d+,[+-]?\d+\.\d+/.test(address.textContent)) {
//= toolkit/update_notifier.js
var scriptURL = 'http://userscripts.org/scripts/show/24398',
- sidebar = $('side'),
wrapper = find(null, '#content > .wrapper')
if (sidebar) {
View
34 endless_tweets/friends.js
@@ -1,5 +1,4 @@
-var friends = xpath2array(select('#side #following_list .vcard', null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE)),
- friendNames = []
+var friendNames = []
function memoizeFriendName(name) {
name = name.toLowerCase()
@@ -72,19 +71,24 @@ function compare(a, b, filter) {
return a < b ? -1 : 1;
}
-if (friends.length) {
- friends.sort(function(a, b) {
- return compare(a, b, function(vcard) {
- if (!vcard._name) {
- vcard._name = selectString('./a/@href', vcard).match(/(\w+)\s*$/)[1]
- vcard._nameDowncase = vcard._name.toLowerCase()
- }
- return vcard._nameDowncase
+function sortFriends() {
+ var friends = xpath2array(select('#following_list .vcard', sidebar, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE))
+
+ if (friends.length) {
+ friends.sort(function(a, b) {
+ return compare(a, b, function(vcard) {
+ if (!vcard._name) {
+ vcard._name = selectString('./a/@href', vcard).match(/(\w+)\s*$/)[1]
+ vcard._nameDowncase = vcard._name.toLowerCase()
+ }
+ return vcard._nameDowncase
+ })
})
- })
- friends.forEach(function(vcard) {
- vcard.parentNode.appendChild(vcard)
- friendNames.push(vcard._nameDowncase)
- })
+ friends.forEach(function(vcard) {
+ vcard.parentNode.appendChild(vcard)
+ friendNames.push(vcard._nameDowncase)
+ })
+ }
}
+sortFriends()
Please sign in to comment.
Something went wrong with that request. Please try again.