Created
September 2, 2014 03:32
-
-
Save Qofar/ce75ad344e65982162cb 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 Thumbnail | |
// @include https://tweetdeck.twitter.com/* | |
// @version 1.0 | |
// @license MIT License | |
// ==/UserScript== | |
(function(){ | |
function source() { | |
TD.services.TwitterMedia.SERVICES["nicovideo"] = /^(?:http:\/\/www\.nicovideo\.jp\/watch\/(?:sm|nm)(\d+))|(?:http:\/\/nico\.ms\/(?:sm|nm)(\d+))/; | |
TD.services.TwitterMedia.SERVICES["nicocommu"] = /^http:\/\/com\.nicovideo\.jp\/community\/co(\d+)/; | |
TD.services.TwitterMedia.SERVICES["nicoseiga"] = /^(?:http:\/\/lohas\.nicoseiga\.jp\/+(?:thumb\/(\d+)|\w+\/\w+\/\w+\/(\d+)))|(?:http:\/\/nico\.(?:ms|sc)\/im(\d+))/; | |
// twitpic http://dev.twitpic.com/docs/thumbnails/ | |
TD.services.TwitterMedia.SERVICES["twitpic"] = /^http:\/\/twitpic\.com\/(\w+)/; | |
// imgur https://api.imgur.com/models/gallery_image | |
TD.services.TwitterMedia.SERVICES["imgur"] = /^https?:\/\/(?:\w+\.)?imgur\.com\/(?:download\/|gallery\/(?=\w{7}))?(\w{5}(?:\w{2})?)[bhlmst]?(?:(\.\w+)(?:\?\d)?|(?:&\w+)*(?:#0)?)$/; | |
// imgly http://img.ly/api | |
TD.services.TwitterMedia.SERVICES["imgly"] = /^http:\/\/img\.ly\/(\w+)/; | |
// twitgoo http://twitgoo.com/images/Twitgoo_API.pdf | |
TD.services.TwitterMedia.SERVICES["twitgoo"] = /^http:\/\/twitgoo\.com\/(\w+)/; | |
// movapic | |
TD.services.TwitterMedia.SERVICES["movapic"] = /^http:\/\/movapic\.com\/pic\/(\w+)/; | |
// moby http://developers.mobypicture.com/documentation/ | |
TD.services.TwitterMedia.SERVICES["moby"] = /^http:\/\/moby\.to\/(\w+)/; | |
// yfrog http://twitter.yfrog.com/page/api | |
TD.services.TwitterMedia.SERVICES["yfrog"] = /^http:\/\/yfrog\.com\/\w+/; | |
// twipple http://p.twipple.jp/wiki/Main_Page | |
TD.services.TwitterMedia.SERVICES["twipple"] = /^http:\/\/p\.twipple\.jp\/(\w+)/; | |
// photozou http://photozou.jp/basic/api | |
TD.services.TwitterMedia.SERVICES["photozou"] = /^http:\/\/photozou\.jp\/photo\/show\/\d+\/(\d+)/; | |
// metacafe | |
TD.services.TwitterMedia.SERVICES["metacafe"] = /^http:\/\/www\.metacafe\.com\/(?:w|watch)\/([\w\-]+)/; | |
// dailymotion | |
TD.services.TwitterMedia.SERVICES["dailymotion"] = /^http:\/\/(?:www|touch)\.dailymotion\.com\/(?:#\/)?video\/([\w\-]+)/; | |
// TD.services.TwitterMedia.prototype.thumb_prev = TD.services.TwitterMedia.prototype.thumb; | |
// TD.services.TwitterMedia.prototype.thumb = function() { | |
// console.log("thumb"); | |
// switch (this.service) { | |
// case "nicovideo": | |
// case "nicocommu": | |
// case "nicoseiga": | |
// case "twitpic": | |
// case "imgur": | |
// case "imgly": | |
// return this.small(); | |
// } | |
// return this.thumb_prev(); | |
// }; | |
TD.services.TwitterMedia.prototype.small_prev = TD.services.TwitterMedia.prototype.small; | |
TD.services.TwitterMedia.prototype.small = function() { | |
switch (this.service) { | |
case "nicovideo": | |
var id = this.urlMatches[2] || this.urlMatches[1]; | |
var host = (id %4) + 1; | |
return "http://tn-skr" + host + ".smilevideo.jp/smile?i=" + id; | |
case "nicocommu": | |
return "http://icon.nimg.jp/community/co" + this.urlMatches[1] + ".jpg"; | |
case "nicoseiga": | |
var id = this.urlMatches[3] || this.urlMatches[1] || this.urlMatches[2]; | |
return "http://lohas.nicoseiga.jp/thumb/" + id + "q"; | |
// return this.medium(); | |
case "twitpic": | |
// return "http://twitpic.com/show/mini/" + this.urlMatches[1]; | |
return this.medium(); | |
case "imgur": | |
var ext = this.urlMatches[2] ? this.urlMatches[2] : ".jpg"; | |
return "http://i.imgur.com/" + this.urlMatches[1] + "t" + ext; | |
case "imgly": | |
return "http://img.ly/show/thumb/" + this.urlMatches[1]; | |
case "twitgoo": | |
return "http://twitgoo.com/show/thumb/" + this.urlMatches[1]; | |
case "movapic": | |
// return "http://image.movapic.com/pic/t_" + this.urlMatches[1] + ".jpeg"; | |
return this.medium(); | |
case "moby": | |
return this.urlMatches[0] + ":square"; | |
case "yfrog": | |
return this.urlMatches[0] + ":small"; | |
case "twipple": | |
return "http://p.twpl.jp/show/thumb/" + this.urlMatches[1]; | |
case "photozou": | |
return "http://photozou.jp/p/thumb/" + this.urlMatches[1]; | |
case "metacafe": | |
return "http://www.metacafe.com/thumb/" + this.urlMatches[1] + ".jpg"; | |
case "dailymotion": | |
return "http://www.dailymotion.com/thumbnail/video/" + this.urlMatches[1]; | |
} | |
return this.small_prev(); | |
}; | |
TD.services.TwitterMedia.prototype.medium_prev = TD.services.TwitterMedia.prototype.medium; | |
TD.services.TwitterMedia.prototype.medium = function() { | |
switch (this.service) { | |
case "nicovideo": | |
return this.large(); | |
case "nicocommu": | |
return this.small(); | |
case "nicoseiga": | |
var id = this.urlMatches[3] || this.urlMatches[1] || this.urlMatches[2]; | |
return "http://lohas.nicoseiga.jp/thumb/" + id + "m"; | |
case "twitpic": | |
return "http://twitpic.com/show/thumb/" + this.urlMatches[1]; | |
case "imgur": | |
var ext = this.urlMatches[2] ? this.urlMatches[2] : ".jpg"; | |
return "http://i.imgur.com/" + this.urlMatches[1] + "m" + ext; | |
case "imgly": | |
return "http://img.ly/show/medium/" + this.urlMatches[1]; | |
case "twitgoo": | |
return "http://twitgoo.com/show/thumb/" + this.urlMatches[1]; | |
case "owly": | |
return "http://static.ow.ly/photos/normal/" + this.urlMatches[1]; | |
case "movapic": | |
return "http://image.movapic.com/pic/s_" + this.urlMatches[1] + ".jpeg"; | |
case "moby": | |
return this.urlMatches[0] + ":medium"; | |
case "yfrog": | |
return this.urlMatches[0] + ":medium"; | |
case "twipple": | |
return "http://p.twpl.jp/show/large/" + this.urlMatches[1]; | |
case "photozou": | |
return this.large(); | |
case "metacafe": | |
return this.small(); | |
case "dailymotion": | |
return this.small(); | |
} | |
return this.medium_prev(); | |
}; | |
TD.services.TwitterMedia.prototype.large_prev = TD.services.TwitterMedia.prototype.large; | |
TD.services.TwitterMedia.prototype.large = function() { | |
switch (this.service) { | |
case "nicovideo": | |
var id = this.urlMatches[2] || this.urlMatches[1]; | |
var large = id > 16500000 ? ".L" : ""; | |
var host = (id %4) + 1; | |
return "http://tn-skr" + host + ".smilevideo.jp/smile?i=" + id + large; | |
case "nicocommu": | |
return this.small(); | |
case "nicoseiga": | |
var id = this.urlMatches[3] || this.urlMatches[1] || this.urlMatches[2]; | |
return "http://lohas.nicoseiga.jp/thumb/" + id + "l"; | |
case "twitpic": | |
return "http://twitpic.com/show/full/" + this.urlMatches[1]; | |
// return this.medium(); | |
case "imgur": | |
var ext = this.urlMatches[2] ? this.urlMatches[2] : ".jpg"; | |
return "http://i.imgur.com/" + this.urlMatches[1] + ext; | |
case "imgly": | |
return "http://img.ly/show/full/" + this.urlMatches[1]; | |
case "twitgoo": | |
return "http://twitgoo.com/show/img/" + this.urlMatches[1]; | |
case "owly": | |
return "http://static.ow.ly/photos/original/" + this.urlMatches[1]; | |
case "movapic": | |
return "http://image.movapic.com/pic/m_" + this.urlMatches[1] + ".jpeg"; | |
case "moby": | |
return this.urlMatches[0] + ":medium"; | |
case "yfrog": | |
return this.medium(); | |
case "twipple": | |
return "http://p.twpl.jp/show/orig/" + this.urlMatches[1]; | |
case "photozou": | |
return "http://photozou.jp/p/img/" + this.urlMatches[1]; | |
case "metacafe": | |
return this.small(); | |
case "dailymotion": | |
return this.small(); | |
} | |
return this.large_prev(); | |
}; | |
TD.services.TwitterStatus.prototype.render_prev = TD.services.TwitterStatus.prototype.render; | |
TD.services.TwitterStatus.prototype.render = function(e) { | |
var medias = this._media; | |
if (medias && medias.length > 0) { | |
for (var i = 0; i < medias.length; i++) { | |
var media = medias[i]; | |
switch (media.service) { | |
case "nicovideo": | |
case "nicocommu": | |
case "nicoseiga": | |
case "twitpic": | |
case "imgur": | |
case "imgly": | |
case "twitgoo": | |
case "owly": | |
case "movapic": | |
case "moby": | |
case "yfrog": | |
case "twipple": | |
case "photozou": | |
e.mediaPreviewSize = TD.vo.Column.MEDIA_PREVIEW_SIZE_SMALL; | |
break; | |
} | |
} | |
} | |
return this.render_prev(e); | |
}; | |
} | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.innerHTML = '(' + source.toString() + ')();'; | |
document.body.appendChild(script); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment