Forked from Qofar/Tweetdeck_MARKING_friends_followers.user.js
Created
August 24, 2017 06:48
-
-
Save nirvash/821a828a3b52b8f174dae40bdeac7794 to your computer and use it in GitHub Desktop.
Tweetdeckで片思い"⇦"、片思われ"⇨'"、相互フォロー"☺"を名前の先頭に表示するUserScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Tweetdeck MARKING Friends and Followers | |
// @include https://tweetdeck.twitter.com/* | |
// @version 1.1 | |
// @license MIT License | |
// ==/UserScript== | |
(function(w) { | |
var TD = w.TD; | |
TD.services.TwitterClient.prototype.followers = null; | |
TD.services.TwitterClient.prototype.getFollowersIDs = function(cursor) { | |
if (!cursor) this.followers = {}; | |
this.makeTwitterCall( | |
'https://api.twitter.com/1.1/followers/ids.json', | |
{ | |
user_id : this.oauth.account.getUserID(), | |
cursor : cursor ? cursor : -1, | |
stringify_ids : true | |
}, | |
'GET', | |
function(response) { | |
for (var i = 0; i < response.ids.length; i++) { | |
this.followers[response.ids[i]] = true; | |
} | |
if (response.next_cursor_str !== '0') { | |
this.getFollowersIDs(response.next_cursor_str); | |
} | |
}, | |
function(){}, | |
function(){} | |
); | |
}; | |
TD.services.TwitterClient.prototype.getFriendMark = function(following, followed_by, userId){ | |
var isFriend = following || this.friends[userId]; | |
var isFollower = followed_by || this.followers[userId]; | |
if (isFollower) { | |
if (isFriend) { | |
return '☺'; | |
} else { | |
return '⇨'; | |
} | |
} else { | |
if (isFriend) { | |
return '⇦'; | |
} else { | |
return ''; | |
} | |
} | |
}; | |
TD.services.TwitterClient.prototype.loadCaches_prev = TD.services.TwitterClient.prototype.loadCaches; | |
TD.services.TwitterClient.prototype.loadCaches = function() { | |
this.getFollowersIDs(); | |
this.loadCaches_prev(); | |
}; | |
TD.services.TwitterClient.prototype.processTweet_prev = TD.services.TwitterClient.prototype.processTweet; | |
TD.services.TwitterClient.prototype.processTweet = function(e){ | |
var tweet = this.processTweet_prev(e); | |
var tweetUser = tweet.user; | |
tweetUser.name = this.getFriendMark(tweetUser.following, tweetUser.followed_by, tweetUser.id) + tweetUser.name; | |
if (tweet.retweetedStatus) { | |
var reTweetUser = tweet.retweetedStatus.user; | |
reTweetUser.name = this.getFriendMark(reTweetUser.following, reTweetUser.followed_by, reTweetUser.id) + reTweetUser.name; | |
} | |
return tweet; | |
}; | |
TD.services.TwitterClient.prototype.processMessages_prev = TD.services.TwitterClient.prototype.processMessages; | |
TD.services.TwitterClient.prototype.processMessages = function(e, t) { | |
for (var i = 0; i < e.length; i++) { | |
var sender = e[i].sender; | |
sender.name = this.getFriendMark(sender.following, sender.followed_by, sender.id) + sender.name; | |
} | |
return this.processMessages_prev(e, t); | |
}; | |
TD.services.TwitterClient.prototype.processActions_prev = TD.services.TwitterClient.prototype.processActions; | |
TD.services.TwitterClient.prototype.processActions = function(e) { | |
for (var i = 0; i < e.length; i++) { | |
var n = e[i]; | |
if (n.sources_size > 0 ) { | |
var src = n.sources[0]; | |
src.name = this.getFriendMark(src.following, src.followed_by, src.id) + src.name; | |
} | |
if (n.targets_size > 0 ) { | |
var tgt = n.targets[0]; | |
if (tgt.name) { | |
tgt.name = this.getFriendMark(tgt.following, tgt.followed_by, tgt.id) + tgt.name; | |
} | |
if (tgt.user) { | |
tgt.user.name = this.getFriendMark(tgt.user.following, tgt.user.followed_by, tgt.user.id) + tgt.user.name; | |
} | |
} | |
} | |
return this.processActions_prev(e); | |
}; | |
TD.services.TwitterClient.prototype.processUser_prev = TD.services.TwitterClient.prototype.processUser; | |
TD.services.TwitterClient.prototype.processUser = function(e) { | |
e.name = this.getFriendMark(e.following, e.followed_by, e.id) + e.name; | |
return this.processUser_prev(e); | |
}; | |
TD.services.TwitterAction.processStreamAction_prev = TD.services.TwitterAction.processStreamAction; | |
TD.services.TwitterAction.processStreamAction = function(e, t) { | |
var client = TD.controller.clients.getClient(t.getKey()); | |
var src = e.source; | |
var tgt = e.target; | |
src.name = client.getFriendMark(src.following, src.followed_by, src.id) + src.name; | |
tgt.name = client.getFriendMark(tgt.following, tgt.followed_by, tgt.id) + tgt.name; | |
if (e.target_object) { | |
var tgtobj = e.target_object.user; | |
tgtobj.name = client.getFriendMark(tgtobj.following, tgtobj.followed_by, tgtobj.id) + tgtobj.name; | |
} | |
return TD.services.TwitterAction.processStreamAction_prev(e, t); | |
}; | |
})(unsafeWindow); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment