Forked from Qofar/Tweetdeck_MARKING_friends_followers.user.js
Last active
October 18, 2020 14:59
-
-
Save nirvash/7df0282fc3befede8acbcd3d573cda66 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.addFriendMark = function(following, followed_by, userId, name) { | |
var mark = this.getFriendMark(following, followed_by, userId); | |
if (mark !== '' && name.indexOf(mark) !== 0) { | |
name = mark + name; | |
} | |
return name; | |
}; | |
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){ | |
e.user.name = this.addFriendMark(e.user.following, e.user.followed_by, e.user.id, e.user.name); | |
var tweet = this.processTweet_prev(e); | |
if (tweet.retweetedStatus) { | |
var reTweetUser = tweet.retweetedStatus.user; | |
reTweetUser.name = this.addFriendMark(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.addFriendMark(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.addFriendMark(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.addFriendMark(tgt.following, tgt.followed_by, tgt.id, tgt.name); | |
} | |
if (tgt.user) { | |
tgt.user.name = this.addFriendMark(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.addFriendMark(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.addFriendMark(src.following, src.followed_by, src.id, src.name); | |
tgt.name = client.addFriendMark(tgt.following, tgt.followed_by, tgt.id, tgt.name); | |
if (e.target_object) { | |
var tgtobj = e.target_object.user; | |
tgtobj.name = client.addFriendMark(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
会話リストなどでアイコンが多重に付与されていたのでその対策