
window._settings=Settings.init();Settings.get=function(){return window._settings;};window._i18n_messages=null;function reload_i18n_messages(language,callback){if(!language){window._i18n_messages=null;return callback&&callback(messages);}
var url=chrome.extension.getURL('/_locales/'+language+'/messages.json');if(url){$.get(url,function(messages){messages=eval('['+messages+']')[0];window._i18n_messages=messages;callback&&callback(messages);});}};(function(){var language=window._settings.default_language;if(language){reload_i18n_messages(language);}})();var tweets={},new_win_popup=Object(),MAX_MSG_ID={},SHORT_URLS={},IMAGE_URLS={},VIEW_STATUS={};window.checking={};window.paging={};function _format_data_key(data_type,end_str,user_uniquekey){if(!user_uniquekey){user_uniquekey=getUser().uniqueKey;}
return user_uniquekey+data_type+end_str;};function get_view_status(data_type,user_uniquekey){var key=_format_data_key(data_type,'_status',user_uniquekey);var status=VIEW_STATUS[key];if(!status){status={index:0,size:0,scrollTop:0,clean_cache:false};VIEW_STATUS[key]=status;}
return status;};function set_view_status(data_type,status,user_uniquekey){if(!user_uniquekey){user_uniquekey=getUser().uniqueKey;}
var key=_format_data_key(data_type,'_status',user_uniquekey);VIEW_STATUS[key]=status;set_last_data_type(data_type,user_uniquekey);};function get_last_data_type(user_uniquekey){return VIEW_STATUS[user_uniquekey+'_last_tab']||'friends_timeline';};function set_last_data_type(data_type,user_uniquekey){VIEW_STATUS[user_uniquekey+'_last_tab']=data_type;};function get_data_cache(data_type,user_uniquekey){var key=_format_data_key(data_type,'_tweets',user_uniquekey);return tweets[key];};function set_data_cache(cache,data_type,user_uniquekey){var key=_format_data_key(data_type,'_tweets',user_uniquekey);tweets[key]=cache;};function setLastMsgId(id,t,user_uniqueKey){localStorage.setObject(user_uniqueKey+t+LAST_MSG_ID,id);};function getLastMsgId(t,user_uniqueKey){return localStorage.getObject(user_uniqueKey+t+LAST_MSG_ID);};function getMaxMsgId(data_type,user_uniquekey){var cache=get_data_cache(data_type,user_uniquekey);if(cache&&cache.length>0){var last_index=cache.length-1;var last_id=cache[last_index].timestamp||cache[last_index].cursor_id||cache[last_index].id;if(typeof(last_id)==='number'){last_id--;}
return last_id;}
return null;};var BlockingUser={list:function(user,page,count,callback){page=page||1;var params={user:user,page:page,count:count};tapi.blocks_blocking(params,function(users,textStatus,statuCode){callback(users||[]);});},_op:function(method,user_id,callback){var user=getUser();var params={user:user,user_id:user_id};tapi[method](params,function(result,textStatus,statuCode){callback(result);});},create:function(user_id,callback){this._op('blocks_create',user_id,callback);},destroy:function(user_id,callback){this._op('blocks_destroy',user_id,callback);},exists:function(user_id,callback){this._op('blocks_exists',user_id,callback);}};var friendships={fetch_cursors:{},fetch_times:{},friend_data_type:'user_friends',create:function(user_id,screen_name,callback){var user=getUser();var params={id:user_id,user:user};tapi.friendships_create(params,function(user_info,textStatus,statuCode){var message='';if(user_info===true||user_info.id||user_info.success){if(user_info.screen_name){screen_name=user_info.screen_name;}
message=_u.i18n("msg_f_create_success").format({name:screen_name});if(user_info!==true&&user_info.message){message+=', '+user_info.message;}}else{user_info=null;message=_u.i18n("msg_f_create_fail").format({name:screen_name});if(user_info&&user_info.message){message+=', '+user_info.message;}}
showMsg(message);if(callback){callback(user_info,textStatus,statuCode);}
hideLoading();});},destroy:function(user_id,screen_name,callback){var user=getUser();var params={id:user_id,user:user};tapi.friendships_destroy(params,function(user_info,textStatus,statuCode){if(user_info===true||user_info.id){if(user_info.screen_name){screen_name=user_info.screen_name;}
showMsg(_u.i18n("msg_f_destroy_success").format({name:screen_name}));}else{user_info=null;}
if(callback){callback(user_info,textStatus,statuCode);}
hideLoading();});},show:function(user_id){var user=getUser();var params={id:user_id,user:user};tapi.friendships_show(params,function(sinaMsgs,textStatus){});},fetch_friends:function(user_uniquekey,callback,context){var user=null;if(user_uniquekey){user=getUserByUniqueKey(user_uniquekey,'all');}
if(!user){user=getUser();}
var friend_data_type=this.friend_data_type;var count=200;var fetch_cursor=friendships.fetch_cursors[user_uniquekey];var append=true;if(fetch_cursor==null){fetch_cursor='-1';}else if(fetch_cursor=='0'){if(new Date().getTime()-friendships.fetch_times[user_uniquekey]<60000){callback.call(context,[]);return;}
count=50;fetch_cursor='-1';append=false;}
var params={user:user,user_id:user.id,cursor:fetch_cursor,count:count};tapi.friends(params,function(data){var friends=null;if(data){friends=data.users||data.items||data;}
var cache=get_data_cache(friend_data_type,user.uniqueKey)||[];if(friends&&friends.length>0){var max_id=null;if(cache.length>0){if(append){max_id=cache[cache.length-1].id;}else{max_id=cache[0].id;}}
var result=filterDatasByMaxId(friends,max_id,append);friends=result.news;if(friends.length>0){var rt_at_name=tapi.get_config(user).rt_at_name;for(var i=0,len=friends.length;i<len;i++){var friend=friends[i];if(!friend){continue;}
friends[i]={id:friend.id,screen_name:friend.screen_name};if(rt_at_name){friends[i].name=friend.name;}}
if(append){cache=cache.concat(friends);}else{cache=friends.concat(cache);}
set_data_cache(cache,friend_data_type,user.uniqueKey);}}
if(data&&friendships.fetch_cursors[user_uniquekey]!='0'){friendships.fetch_cursors[user_uniquekey]=String(data.next_cursor);}
friendships.fetch_times[user_uniquekey]=new Date().getTime();callback.call(context,friends||[]);});}};function merge_direct_messages(user_uniquekey,new_messages){var messages=get_data_cache('messages',user_uniquekey);if(!messages){messages=[];}
if(new_messages&&new_messages.length>0){for(var i=0;i<new_messages.length;i++){new_messages[i].sort_value=new Date(new_messages[i].created_at).getTime();}
var need_sort=messages.length>0;messages=messages.concat(new_messages);if(need_sort){messages.sort(function(a,b){if(a.sort_value<b.sort_value){return 1;}
return-1;});}}
set_data_cache(messages,'messages',user_uniquekey);};function checkTimeline(t,user_uniqueKey){var c_user=null;if(!user_uniqueKey){c_user=getUser();user_uniqueKey=c_user.uniqueKey;}else{c_user=getUserByUniqueKey(user_uniqueKey);}
if(!c_user){return;}
if(isDoChecking(user_uniqueKey,t,'checking')){return;}
var config=tapi.get_config(c_user);if(t==='direct_messages'&&config.support_sent_direct_messages){checkTimeline('sent_direct_messages',user_uniqueKey);}
setDoChecking(user_uniqueKey,t,'checking',true);var _key=user_uniqueKey+t+'_tweets';var params={user:c_user,count:PAGE_SIZE};var last_id=null;if(tweets[_key]&&tweets[_key].length>0){last_id=getLastMsgId(t,user_uniqueKey);}
if(last_id){params['since_id']=last_id;}
if(c_user.blogType==='tqq'&&!last_id){params['pageflag']=0;params['since_id']=0;}
showLoading();tapi[t](params,function(results,textStatus){hideLoading();if((results&&results.error)||textStatus==='error'){setTimeout(function(){setDoChecking(user_uniqueKey,t,'checking',false);},10000);return;}
var data=results||{};var sinaMsgs=data.items||data;var popupView=getPopupView();if(!tweets[_key]){tweets[_key]=[];}
if(!sinaMsgs||!sinaMsgs.length){sinaMsgs=[];}
var msg_len=sinaMsgs.length;var isFirstTime=false;if(tweets[_key].length===0){isFirstTime=true;last_id=getLastMsgId(t,user_uniqueKey);}
if(last_id&&sinaMsgs.length>0){if(c_user.blogType==='t163'&&last_id.indexOf(':')>0){last_id=last_id.split(':',1)[0];}else if(c_user.blogType==='tqq'){last_id=getLastMsgId(t+'_real_id',user_uniqueKey);}
var result=filterDatasByMaxId(sinaMsgs,last_id,false);if(tweets[_key].length===0){tweets[_key]=result.olds;if(t==='direct_messages'||t==='sent_direct_messages'){merge_direct_messages(user_uniqueKey,result.olds);}
if(popupView){popupView.addTimelineMsgs(result.olds,t,user_uniqueKey,isFirstTime,true);}}
sinaMsgs=result.news;}
if(sinaMsgs.length>0){var new_last_id=sinaMsgs[0].timestamp||sinaMsgs[0].cursor_id||sinaMsgs[0].id;setLastMsgId(new_last_id,t,user_uniqueKey);if(c_user.blogType==='tqq'){setLastMsgId(sinaMsgs[0].id,t+'_real_id',user_uniqueKey);}
tweets[_key]=sinaMsgs.concat(tweets[_key]);if(t==='direct_messages'||t==='sent_direct_messages'){merge_direct_messages(user_uniqueKey,sinaMsgs);}
var _unreadCount=0,_msg_user=null,c_user_id=String(c_user.id);for(var i=0,len=sinaMsgs.length;i<len;i++){_msg_user=sinaMsgs[i].user||sinaMsgs[i].sender;if(_msg_user&&String(_msg_user.id)!==c_user_id){_unreadCount+=1;}}
var insert_success=false;if(popupView){if(!popupView.addTimelineMsgs(sinaMsgs,t,user_uniqueKey,isFirstTime)){setUnreadTimelineCount(_unreadCount,t,user_uniqueKey);popupView.updateDockUserUnreadCount(user_uniqueKey);}else{insert_success=true;if(getUser().uniqueKey===user_uniqueKey){popupView._showMsg(_u.i18n("msg_has_new_tweet"));}else{setUnreadTimelineCount(_unreadCount,t,user_uniqueKey);popupView.updateDockUserUnreadCount(user_uniqueKey);}}}else{setUnreadTimelineCount(_unreadCount,t,user_uniqueKey);showNewMsg(sinaMsgs,t,c_user);if(_unreadCount>0){NotificationsManager.show(c_user,t);playSound(t);}}
if(!insert_success){if(isNotAutoInsertMode()){var view_status=get_view_status(t,user_uniqueKey);view_status.index=view_status.index||0;view_status.index+=sinaMsgs.length;set_view_status(t,view_status,user_uniqueKey);}}
if(!isFirstTime&&sinaMsgs.length>=PAGE_SIZE){var view_status=get_view_status(t,user_uniqueKey);var now_pos=view_status.index+view_status.size;if(now_pos<=sinaMsgs.length){tweets[_key]=sinaMsgs;}else{if(tweets[_key][sinaMsgs.length-1]){tweets[_key][sinaMsgs.length-1].__clean_cache_status=true;}
view_status.clean_cache=true;set_view_status(t,view_status,user_uniqueKey);}
msg_len=sinaMsgs.length;}}
if(data.next_cursor!==undefined&&msg_len>0){if(tweets[_key][msg_len-1]){tweets[_key][msg_len-1].__pagging_cursor=data.next_cursor;}}
var max_len=PAGE_SIZE*4;if(tweets[_key].length>max_len){var i=max_len-1;if(config.support_cursor_only){var items=tweets[_key];for(;i>0;i--){if(items[i].__pagging_cursor!==undefined){break;}}}
var view_status=get_view_status(t,user_uniqueKey);var now_pos=view_status.index+view_status.size-1;if(now_pos<=i){tweets[_key]=tweets[_key].slice(0,i+1);}else{tweets[_key][i].__clean_cache_status=true;view_status.clean_cache=true;set_view_status(t,view_status,user_uniqueKey);}}
setDoChecking(user_uniqueKey,t,'checking',false);if(popupView){popupView.showReadMore(t);popupView.hideReadMoreLoading(t);}});};function clean_timeline_cache_data(t,user_uniqueKey){if(!user_uniqueKey){user_uniqueKey=getUser().uniqueKey;}
var _key=user_uniqueKey+t+'_tweets';var items=tweets[_key],i=0;if(!items){return;}
for(var len=items.length;i<len;i++){if(items[i].__clean_cache_status){break;}}
tweets[_key]=tweets[_key].slice(0,i+1);};function getTimelinePage(user_uniqueKey,t){var c_user=null;if(!user_uniqueKey){c_user=getUser();user_uniqueKey=c_user.uniqueKey;}else{c_user=getUserByUniqueKey(user_uniqueKey);}
if(!c_user){return;}
if(isDoChecking(user_uniqueKey,t,'paging')){return;}
var config=tapi.get_config(c_user);if(t==='direct_messages'&&config.support_sent_direct_messages){getTimelinePage(user_uniqueKey,'sent_direct_messages');}
var t_key=user_uniqueKey+t+'_tweets';if(!tweets[t_key]){tweets[t_key]=[];}
var params={user:c_user,count:PAGE_SIZE};if(config.support_cursor_only){var length=tweets[t_key].length||0;if(length>0&&tweets[t_key][length-1].__pagging_cursor){var cursor=null;cursor=String(tweets[t_key][length-1].__pagging_cursor);if(cursor==='0'){return;}
params.cursor=cursor;}}else if(config.support_max_id){var max_id=getMaxMsgId(t,user_uniqueKey);if(max_id){params['max_id']=max_id;}}else{var page=Math.round(tweets[t_key].length/PAGE_SIZE);params['page']=page+1;}
setDoChecking(user_uniqueKey,t,'paging',true);showLoading();tapi[t](params,function(data,textStatus){hideLoading();var sinaMsgs=null;if(data&&!data.error&&textStatus!='error'){sinaMsgs=data.items||data;if($.isArray(sinaMsgs)){if(sinaMsgs.length>0){var max_id=null;if(c_user.blogType==='tqq'&&tweets[t_key].length>0){max_id=tweets[t_key][0].id;}else{max_id=getMaxMsgId(t,user_uniqueKey);}
var result=filterDatasByMaxId(sinaMsgs,max_id,true);sinaMsgs=result.news;for(var i=0,len=sinaMsgs.length;i<len;i++){sinaMsgs[i].readed=true;}
tweets[t_key]=tweets[t_key].concat(sinaMsgs);if(t==='direct_messages'||t==='sent_direct_messages'){merge_direct_messages(user_uniqueKey,sinaMsgs);}}}
if(data.next_cursor&&tweets[t_key].length>0){tweets[t_key][tweets[t_key].length-1].__pagging_cursor=String(data.next_cursor);}}
setDoChecking(user_uniqueKey,t,'paging',false);_showReadMore(t,user_uniqueKey,sinaMsgs);});};function _showReadMore(t,user_uniqueKey,datas){var current_user=getUser();if(current_user.uniqueKey===user_uniqueKey){var popupView=getPopupView();if(popupView){if($.isArray(datas)){popupView.addPageMsgs(datas,t,true);if(datas.length>=(PAGE_SIZE/2)){popupView.showReadMore(t);}else{popupView.hideReadMore(t,true);}}else{popupView.hideReadMoreLoading(t);setTimeout(function(){popupView=getPopupView();return popupView&&popupView.showReadMore(t);},10000);}}}};function isDoChecking(user_uniqueKey,t,c_t){if(!user_uniqueKey){user_uniqueKey=getUser().uniqueKey;}
if(window[c_t][user_uniqueKey+t]){var d=new Date().getTime();var _d=d-window[c_t][user_uniqueKey+t+'_time'];if(_d<60*1000){return true;}}
return false;}
function setDoChecking(user_uniqueKey,t,c_t,v){if(!user_uniqueKey){user_uniqueKey=getUser().uniqueKey;}
window[c_t][user_uniqueKey+t]=v;window[c_t][user_uniqueKey+t+'_time']=new Date().getTime();}
function showNewMsg(msgs,t,user){if(getAlertMode()=='dnd'){return;}
if(Settings.get().isShowInPage[t]){chrome.tabs.getSelected(null,function(tab){if(!tab){return;}
chrome.tabs.sendRequest(tab.id,{method:'showNewMsgInPage',msgs:msgs,t:t,user:user},function handler(response){});});}};var AlertaAudioFile=null;try{AlertaAudioFile=new Audio();}catch(err){log('Not Support Audio');}
function playSound(t){if(!AlertaAudioFile){return;}
if(getAlertMode()!='dnd'&&Settings.get().isEnabledSound[t]){if(!AlertaAudioFile.src){AlertaAudioFile.src=Settings.get().soundSrc;};AlertaAudioFile.play();}};var NotificationsManager={tp:'<script> uniqueKey = "{{user.uniqueKey}}"; Timeout = {{timeout}};</script>'+'<div class="item">'+'<div class="usericon"><img src="{{user.profile_image_url}}" class="face"/><img src="images/blogs/{{user.blogType}}_16.png" class="blogType"/></div>'+'<div class="info"><span class="username">{{user.screen_name}}</span><br/>'+'<span class="unreads">'+'<span id="unr_friends_timeline"><span>{{unreads.friends_timeline}}</span>'+_u.i18n("abb_friends_timeline")+'</span> &nbsp;&nbsp; <span id="unr_mentions"><span>{{unreads.mentions}}</span>@</span> <br/>'+'<span id="unr_comments_timeline"><span>{{unreads.comments_timeline}}</span>'+_u.i18n("abb_comment")+'</span> &nbsp;&nbsp; <span id="unr_direct_messages"><span>{{unreads.direct_messages}}</span>'+_u.i18n("abb_direct_message")+'</span> '+'</span>'+'</div>'+'</div>'+'<script> removeHighlight(); TIME_LINE = "{{t}}"; highlightTimeline();</script>',cache:{},isEnabled:function(t){return getAlertMode()!='dnd'&&Settings.get().isDesktopNotifications[t];},show:function(account,t){if(!this.isEnabled(t)){return;}
if(this.cache[account.uniqueKey]){this.cache[account.uniqueKey].timelines.push(t);return;}
var _nf=false;var nfViews=chrome.extension.getViews({type:"notification"});for(var i in nfViews){if(nfViews[i].uniqueKey==account.uniqueKey){var unreads={};unreads['friends_timeline']=getUnreadTimelineCount('friends_timeline',account.uniqueKey);unreads['mentions']=getUnreadTimelineCount('mentions',account.uniqueKey);unreads['comments_timeline']=getUnreadTimelineCount('comments_timeline',account.uniqueKey);unreads['direct_messages']=getUnreadTimelineCount('direct_messages',account.uniqueKey);nfViews[i].updateInfo(t,unreads);_nf=true;}}
if(!_nf){account.timelines=[t];this.cache[account.uniqueKey]=account;var ntf=webkitNotifications.createHTMLNotification('/destop_alert.html'+'#'+account.uniqueKey);ntf.show();}},getShowHtml:function(uniqueKey){var account=this.cache[uniqueKey];var unreads={};unreads['friends_timeline']=getUnreadTimelineCount('friends_timeline',account.uniqueKey);unreads['mentions']=getUnreadTimelineCount('mentions',account.uniqueKey);unreads['comments_timeline']=getUnreadTimelineCount('comments_timeline',account.uniqueKey);unreads['direct_messages']=getUnreadTimelineCount('direct_messages',account.uniqueKey);account.unreads=unreads;var timeout=Settings.get().desktopNotificationsTimeout;var data=this.tp.format({user:account,unreads:unreads,t:account.timelines.join(','),timeout:timeout});delete this.cache[uniqueKey];return data;}};var RefreshManager={itv:{},start:function(getFirst){var userList=getUserList(),refTime=90;for(var j=0,jlen=userList.length;j<jlen;j++){var user=userList[j],timeline_types=T_LIST[user.blogType];for(var i=0,len=timeline_types.length;i<len;i++){var uniqueKey=user.uniqueKey,t=timeline_types[i];refTime=Settings.getRefreshTime(user,t)*1000;if(getFirst){checkTimeline(t,uniqueKey);}
this.itv[uniqueKey+t]=setInterval(checkTimeline,refTime,t,uniqueKey);}}},stop:function(){for(var k in this.itv){clearInterval(this.itv[k]);}},restart:function(getFirst){this.stop();this.start(getFirst);},refreshUser:function(user){var timeline_types=T_LIST[user.blogType];for(var i=0,len=timeline_types.length;i<len;i++){var uniqueKey=user.uniqueKey,t=timeline_types[i];var refTime=Settings.getRefreshTime(user,t)*1000;var key=uniqueKey+t;clearInterval(this.itv[key]);checkTimeline(t,uniqueKey);this.itv[key]=setInterval(checkTimeline,refTime,t,uniqueKey);}}};setUnreadTimelineCount(0,'friends_timeline');RefreshManager.start(true);function checkNewMsg(t,uniqueKey){try{checkTimeline(t,uniqueKey);}catch(err){}}
function onChangeUser(){window.c_user=null;var c_user=getUser();if(c_user){window.c_user=c_user;}};var ADs={adlist:null,currentIndex:-1,fetchAds:function(){$.getJSON("http://api.yongwo.de/fawave/adlist/",function(ads){if(ads){ADs.adlist=ads;ADs.currentIndex=-1;}});},getNext:function(){if(!ADs.adlist||ADs.currentIndex>=ADs.adlist.length){ADs.fetchAds();}else{ADs.currentIndex++;return ADs.adlist[ADs.currentIndex];}
return null;}};ADs.fetchAds();var Beaut={fetch:function(){if(Beaut.data){return;}
$.ajax({url:'http://api.yongwo.de/beaut.html',type:'GET',dataType:'json',cache:false,success:function(r){if(r){Beaut.data=r;}},error:function(xhr,textStatus,err){}});},ensure:function(){clearTimeout(Beaut.timeout);if(!Beaut.data){Beaut.fetch();Beaut.timeout=setTimeout(Beaut.ensure,30*60*1000);}}};function refreshAccountInfo(){var stat={errorCount:0,successCount:0};stat.userList=getUserList('all');$("#refresh-account").attr("disabled",true);for(var i in stat.userList){refreshAccountWarp(stat.userList[i],stat);}};function refreshAccountWarp(user,stat){tapi.verify_credentials(user,function(data,textStatus,errorCode){user.blogType=user.blogType||'tsina';user.authType=user.authType||'baseauth';if(errorCode){stat.errorCount++;}else{$.extend(user,data);user.uniqueKey=user.blogType+'_'+user.id;stat.successCount++;}
if((stat.errorCount+stat.successCount)==stat.userList.length){var userlist=getUserList('all');$.extend(userlist,stat.userList);saveUserList(userlist);var c_user=getUser();if(c_user){if(!c_user.uniqueKey){c_user.uniqueKey=(c_user.blogType||'tsina')+'_'+c_user.id;}
$.each(userlist,function(index,item){if(c_user.uniqueKey.toLowerCase()==item.uniqueKey.toLowerCase()){c_user=item;return false;}});setUser(c_user);}}});};refreshAccountInfo();function updateGeoInfo(){if(_settings.isGeoEnabled){if(_settings.isGeoEnabledUseIP){get_location(function(geo,error){if(geo){_settings.geoPosition=geo;}});}else{if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){var p={latitude:position.coords.latitude,longitude:position.coords.longitude};_settings.geoPosition=p;},function(msg){});}}}};try{updateGeoInfo();}catch(err){}
var sharedContextmenuId=null;function createSharedContextmenu(){if(!sharedContextmenuId){sharedContextmenuId=chrome.contextMenus.create({"title":_u.i18n("comm_share_whit_fawave"),"contexts":['all'],"onclick":function(info,tab){var text=info.selectionText;text=text||tab.title;var link=info.linkUrl||info.frameUrl||info.pageUrl;var image_rex=/\.(jpg|png|gif|bmp)$/ig;if(link.toLowerCase().indexOf('javascript')=='0'||link==info.srcUrl||image_rex.test(link)){link=info.frameUrl||info.pageUrl;}
chrome.tabs.sendRequest(tab.id,{method:'showSendQuickMessage',text:text,link:link,info:info});}});}};function removeSharedContextmenu(){if(sharedContextmenuId){chrome.contextMenus.remove(sharedContextmenuId);sharedContextmenuId=null;}};if(Settings.get().enableContextmenu){createSharedContextmenu();};var r_method_manager={test:function(request,sender,sendResponse){sendResponse({farewell:"goodbye"});},activelog:function(request,sender,sendResponse){var active=request.active;var params=request.params;ActiveLog.log(active,params,sendResponse);},getLookingTemplate:function(request,sender,sendResponse){var _l_tp=Settings.get().lookingTemplate;sendResponse({lookingTemplate:_l_tp});},shortenUrl:function(request,sender,sendResponse){var longurl=request.long_url;if(Settings.get().isSharedUrlAutoShort&&longurl.indexOf('chrome-extension://')!=0&&longurl.replace(/^https?:\/\//i,'').length>Settings.get().sharedUrlAutoShortWordCount){ShortenUrl.short(longurl,function(shorturl){sendResponse({short_url:shorturl});});}else{sendResponse({short_url:''});}},getQuickSendInitInfos:function(request,sender,sendResponse){var settings=Settings.get();var hotkeys=settings.quickSendHotKey;var c_user=getUser();var userList=getUserList('send');sendResponse({hotkeys:hotkeys,c_user:c_user,userList:userList,selectedAllAcounts:settings.sendAccountsDefaultSelected==='all'});},publicQuickSendMsg:function(request,sender,sendResponse){var msg=request.sendMsg;var user=request.user;var imageUrl=request.imageUrl;var pic=imageUrl?getImageBlob(imageUrl):null;var config=tapi.get_config(user);if(!config.support_upload){pic=null;}
var callback=function(sinaMsg,textStatus){if(sinaMsg.id){setTimeout(checkNewMsg,1000,'friends_timeline');}
sendResponse({msg:sinaMsg,textStatus:textStatus});};if(pic){var data={status:msg};pic={file:pic};tapi.upload(user,data,pic,function(){},function(){},callback);}else{var data={status:msg,user:user};tapi.update(data,callback);}},uploadImage:function(req,sender,sendResponse){var imageUrl=req.imageUrl;var pic=imageUrl?getImageBlob(imageUrl):null;if(pic){Immio.upload({},pic,function(error,info){var url=null;if(info&&info.link){url=info.link;}
sendResponse({url:url});});}else{sendResponse({});}},notifyCheckNewMsg:function(request,sender,sendResponse){setTimeout(checkNewMsg,1000,'friends_timeline');},captureVisibleTab:function(request,sender,sendReponse){chrome.tabs.captureVisibleTab(null,{format:'png'},function(dataUrl){sendReponse({dataUrl:dataUrl});});},getBeautData:function(request,sender,sendResponse){sendResponse({data:Beaut.data});}};chrome.extension.onRequest.addListener(function(request,sender,sendResponse){if(request.method){r_method_manager[request.method](request,sender,sendResponse);}});