Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($, jn) {
- if(_Janetter_Window_Type=="main" || _Janetter_Window_Type=="profile" || _Janetter_Window_Type=="notice"){
- // entitiesにextended_entitiesを統合
- var _init = jn.tweetController.prototype.init;
- jn.tweetController.prototype.init = function (juid, item, options, autoread){
- if(item){
- if(item.entities && item.extended_entities){
- item.entities.extended_media = item.extended_entities.media || [];
- }
- if(item.retweeted_status && item.retweeted_status.entities && item.retweeted_status.extended_entities){
- item.retweeted_status.entities.extended_media = item.retweeted_status.extended_entities.media || [];
- }
- }
- return _init.apply(this, arguments);
- };
- // entitiesLinkの修正
- var linkExtendedEntities = function(entities){
- var text = '';
- if(entities.extended_media){
- entities.extended_media.slice(1).forEach(function(e, i){
- var link = '<a hidden href="%1" class="link" title="%2"%3%4%5>%6</a>'.format(
- e.url,
- (e.expanded_url || e.url).decodeURI().htmlEncode(true),
- /* そのままだとexpandedが同値になってサムネイル表示してくれないため、#付けて無理やり変える */
- e.expanded_url ? ' expanded="' + e.expanded_url.htmlEncode(true) + '#' + (i+2) + '"' : '',
- e.media_url ? ' media="' + e.media_url.htmlEncode(true) + '"' : '',
- e.type ? ' type="' + e.type.htmlEncode(true) + '"' : '',
- e.display_url ? e.display_url.htmlEncode(true) : e.url.htmlEncode(true)
- );
- text += link;
- });
- }
- return text;
- };
- var _fn_entitiesLink = $.fn.entitiesLink;
- $.fn.entitiesLink = function(entities){
- _fn_entitiesLink.call(this, entities);
- this.html(this.html() + linkExtendedEntities(entities));
- return this;
- };
- var _str_entitiesLink = String.prototype.entitiesLink;
- String.prototype.entitiesLink = function(entities){
- return _str_entitiesLink.call(this, entities) + linkExtendedEntities(entities);
- };
- }
- })(jQuery, janet);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement