Guest User

Untitled

a guest
Jul 13th, 2017
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.32 KB | None | 0 0
  1. (function(source) {
  2. if ('function' == typeof source) {
  3. source = '(' + source + ')();'
  4. }
  5. var script = document.createElement('script');
  6. script.setAttribute("type", "application/javascript");
  7. script.textContent = source;
  8. document.body.appendChild(script);
  9. document.body.removeChild(script);
  10. })
  11.  
  12. (function(){
  13. var w = window;
  14. var d = w.document;
  15.  
  16. var settings = {
  17. Onload: true,
  18.  
  19. Sticky: true,
  20.  
  21. Online: true,
  22.  
  23. Idle: true,
  24.  
  25. Mobile: true,
  26.  
  27. Margin: '0px 10px',
  28. MinHeight: '140px',
  29. Width: '200px'
  30. };
  31.  
  32. function ajax(url){
  33. this.Url = url;
  34. this.XMLHttpRequest = new w.XMLHttpRequest();
  35. }
  36.  
  37. ajax.prototype = {
  38. 'send':function(type,data,callback){
  39. try{
  40. this.Callback = callback;
  41. this.XMLHttpRequest.open(type,this.Url,true);
  42. this.XMLHttpRequest.onreadystatechange = this.stdcallback.bind(this);
  43. this.XMLHttpRequest.send(data);
  44. return true;
  45. }catch(e){
  46. return false;
  47. }
  48. },
  49.  
  50. 'stdcallback':function(){
  51. if(this.XMLHttpRequest.readyState === 4 && this.XMLHttpRequest.status === 200){
  52. if(typeof this.Callback === 'function') this.Callback(this.XMLHttpRequest);
  53. }
  54. }
  55. };
  56.  
  57. var util = {
  58. 'insertRule':function(rule){
  59. if(!this.css){
  60. this.css = d.createElement('style');
  61. d.querySelector('head').appendChild(this.css);
  62. }
  63.  
  64. return this.css.appendChild(d.createTextNode(rule));
  65. },
  66.  
  67. 'getItem':function(key){
  68. return unescape(d.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + escape(key).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
  69. },
  70.  
  71. 'setItem':function(key,value){
  72. d.cookie = escape(key) + '=' + escape(value) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/';
  73. },
  74.  
  75. 'removeItem':function(key){
  76. d.cookie = escape(key) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
  77. }
  78. };
  79.  
  80. var rocki = {
  81. 'DOMContentLoaded':function(){
  82. w.toggle_list = function(r){
  83. if(util.getItem('toggle' + r) === 'true'){
  84. util.setItem('toggle' + r,'false');
  85. }else{
  86. util.setItem('toggle' + r,'true');
  87. }
  88. w.render_chat();
  89. };
  90.  
  91. w.change_order = function(r){
  92. var f = d.querySelectorAll('ul.fbChatOrderedList li.separator[id]');
  93. for(var i = 1, j = f.length; i < j; i++){
  94. if(f.item(i).id === r){
  95. util.setItem('order' + f.item(i).id,i-1);
  96. util.setItem('order' + f.item(i-1).id,i);
  97. }else{
  98. util.setItem('order' + f.item(i).id,i);
  99. }
  100. }
  101. w.render_chat();
  102. };
  103.  
  104. w.Arbiter.subscribe('sidebar/initialized',function(a,d){
  105. d.isViewportCapable = function(){ return false; };
  106. d.disable();
  107. });
  108.  
  109. w.Env = w.require('Env');
  110. w.Env.user = w.require("CurrentUserInitialData").id;
  111.  
  112. w.Arbiter.subscribe('buddylist-nub/initialized',function(a,c){
  113. var av = w.require('AvailableList'),
  114. sp = w.require('ShortProfiles'),
  115. tl = w.require('Toggler'),
  116. oa = w.require('debounceAcrossTransitions'),
  117. ps = w.require('PresenceStatus'),
  118. at = w.require('LastMobileActiveTimes');
  119.  
  120. w.ChatOpenTab = w.require('ChatOpenTab');
  121.  
  122. var getAvailableList = function(){
  123. return av.getAvailableIDs().filter(function(r){
  124. switch(av.get(r)){
  125. case av.ACTIVE: return settings.Online;
  126. case av.IDLE: return settings.Idle;
  127. default: return false;
  128. }
  129. });
  130. };
  131.  
  132. var sortAlpha = function(x,y){
  133. var r = sp.getNow(x), s = sp.getNow(y);
  134. if(!r || !s) return 0;
  135. var t = r.name.toLowerCase(),
  136. u = s.name.toLowerCase();
  137. return t < u ? -1 : 1;
  138. };
  139.  
  140. var sortLists = function(x,y){
  141. if(!x.member || !y.member) return 0;
  142. var r = Number(util.getItem('order' + x.uid)),
  143. s = Number(util.getItem('order' + y.uid));
  144. if(r === s) return 0;
  145. return r < s ? -1 : 1;
  146. };
  147.  
  148. c.orderedList._getListItem = function(id){
  149. this.itemCache = this.itemCache || {};
  150. if(!this.itemCache.hasOwnProperty(id)){
  151. var usr = sp.getNow(id);
  152. this.itemCache[id] = d.createElement('li');
  153. this.itemCache[id].setAttribute('onclick', 'ChatOpenTab.openUserTab(' + usr.id + ');');
  154. this.itemCache[id].className = '__42fz';
  155. this.itemCache[id].innerHTML =
  156. '<a class="_55ln" rel="ignore" tabindex="0">\
  157. <div class="__55lp">\
  158. <div class="__56p9">\
  159. <div size="28" style="width:28px;height:28px;">\
  160. <img width="28" height="28" src="' + usr.thumbSrc +'">\
  161. </div>\
  162. </div>\
  163. <div class="__5bon">\
  164. <div class="__568z">\
  165. <div class="__5t35"></div>\
  166. <i class="_sp_9ot619 _sx_1b221c"></i>\
  167. </div>\
  168. </div>\
  169. <div class="__55lr">' + usr.name + '</div>\
  170. </div></a>';
  171. var status = this.itemCache[id].querySelector('.__568z');
  172. this.itemCache[id]._text = status.querySelector(':first-child');
  173. this.itemCache[id]._img = status.querySelector(':last-child');
  174. }
  175. if(av.get(id) === av.MOBILE){
  176. this.itemCache[id]._text.innerHTML = at.getShortDisplay(id);
  177. this.itemCache[id]._img.className = ' _sp_axfrm8';
  178. this.itemCache[id]._text.style.color = '#898F9C';
  179. }else{
  180. this.itemCache[id]._text.innerHTML = ps.getDetailedActivePresence(id);
  181. this.itemCache[id]._img.className = ' _sp_9ot619 _sx_1b221c';
  182. this.itemCache[id]._text.style.color = '#63A924';
  183. }
  184. return this.itemCache[id];
  185. };
  186.  
  187. w.render_chat = /*c.orderedList.render =*/ c.orderedList._renderOrderedList = function(){
  188. this.render = oa(function(){
  189. if(!rocki.lists) return setTimeout(this.render.bind(this),300);
  190. var a = getAvailableList(), b = [], c, d, e = {};
  191.  
  192. //var rc = w.require('React'), ol = w.require('ChatSidebarOrderedList.react'), tp = this.getSortedList({}, this._numTopFriends);
  193. //rc.renderComponent(ol({availableUsers:av,isSidebar:this._isSidebar,scrollContainer:this._scrollContainer,topUsers:tp}),this._orderedList);
  194.  
  195. rocki.lists.sort(sortLists);
  196. if(a.length > 0){
  197. a.sort(sortAlpha);
  198. for(var f = 0, g = rocki.lists.length; f < g; f++){
  199. if(!rocki.lists[f].member) return setTimeout(this.render.bind(this),300);
  200. c = a.filter(function(r){ return rocki.lists[f].member.hasOwnProperty(r); });
  201. if(c.length > 0){
  202. b.push('<li class="separator" id="' + rocki.lists[f].uid + '" onclick="toggle_list(\'' + rocki.lists[f].uid + '\');"><div class="outer"><div class="inner"><span class="text">' +
  203. rocki.lists[f].text + ' (' + c.length + ') <a href="#" onclick="change_order(\'' + rocki.lists[f].uid + '\');return false;">+</a> <a href="#" onclick="requireLazy([\'Dialog\'],function(a){new a().setAsyncURL(\'/ajax/choose/?type=friendlist&flid=' + rocki.lists[f].uid + '\').setAutohide(true).show();});return false;">~</a></span><div class="dive"><span class="bar"></span></div></div></div></li>');
  204.  
  205. if(util.getItem('toggle' + rocki.lists[f].uid) !== 'true'){
  206. for(var k = 0, l = c.length; k < l; k++){
  207. b.push(this._getListItem(c[k]));
  208. e[c[k]] = 1;
  209. }
  210. }
  211. }
  212. }
  213. c = a.filter(function(r){ return !e.hasOwnProperty(r); });
  214. if(c.length > 0){
  215. b.push('<li class="separator" onclick="toggle_list(\'other\');"><div class="outer"><div class="inner"><span class="text">' +
  216. 'Other (' + c.length + ')</span><div class="dive"><span class="bar"></span></div></div></div></li>');
  217.  
  218. if(util.getItem('toggleother') !== 'true'){
  219. for(var k = 0, l = c.length; k < l; k++){
  220. b.push(this._getListItem(c[k]));
  221. }
  222. }
  223. }
  224. if(settings.Mobile){
  225. c = av.getAvailableIDs().filter(function(r){ return av.get(r) === av.MOBILE && w.PresencePrivacy.getFriendVisibility(r) !== w.PresencePrivacy.BLACKLISTED; });
  226. if(c.length > 0){
  227. b.push('<li class="separator" onclick="toggle_list(\'mobile\');"><div class="outer"><div class="inner"><span class="text">' +
  228. 'Mobile (' + c.length + ')</span><div class="dive"><span class="bar"></span></div></div></div></li>');
  229.  
  230. if(util.getItem('togglemobile') !== 'true'){
  231. c.sort(sortAlpha);
  232. for(var k = 0, l = c.length; k < l; k++){
  233. b.push(this._getListItem(c[k]));
  234. }
  235. }
  236. }
  237. }
  238. }else{
  239. b.push('<div style="padding:10px;">No friends online.</div>');
  240. }
  241. if(b.length > 0){
  242. var ul = this._root.firstChild;
  243. ul.innerHTML = '';
  244. for(var s = 0, t = b.length; s < t; s++){
  245. if(typeof b[s] === 'string'){
  246. ul.innerHTML += b[s];
  247. }else{
  248. ul.appendChild(b[s]);
  249. }
  250. }
  251. this.inform('render',{},this.BEHAVIOR_PERSISTENT);
  252. console.log('Facebook Old Chat by Star Nhật');
  253. }
  254. }.bind(this),300,false);
  255. this.render();
  256. }.bind(c.orderedList);
  257.  
  258. w.Arbiter.subscribe('sidebar/show',function(a,d){
  259. d.hide();
  260. c.show();
  261. });
  262.  
  263. tl.createInstance(c.root).setSticky(settings.Sticky);
  264.  
  265. c.orderedList.scrollTo = function(){ return false; };
  266.  
  267. c.orderedList._arbiter.subscribe('render',function(){
  268. c.label.innerHTML =
  269. c.root.querySelector('div.titlebarTextWrapper').innerHTML =
  270. 'Chat (' + getAvailableList().length + ')';
  271. });
  272.  
  273. sp.fetchAll();
  274.  
  275. //var menu = d.querySelector('div.fbNubFlyout div.fbNubFlyoutTitlebar ul.uiMenuInner');
  276. //menu.innerHTML = '<li data-label="Manage Lists" class="uiMenuItem"><a aria-checked="false" href="/bookmarks/lists" tabindex="-1" class="itemAnchor"><span class="itemLabel fsm">Manage Lists</span></a></li>' + menu.innerHTML;
  277.  
  278. util.setItem('togglemobile',true);
  279.  
  280. if(w.ChatVisibility.isOnline() && settings.Onload) c.show();
  281. });
  282. },
  283.  
  284. 'getflid':function(){
  285. var a = new ajax('/ajax/typeahead/first_degree.php?__a=1&filter[0]=friendlist&lazy=0&viewer=' + w.Env.user + '&__user=' + w.Env.user);
  286. a.send('GET',null,function(b){
  287. var typeahead = eval('(' + b.responseText.substr(9) + ')');
  288. if(!!typeahead.payload){
  289. this.lists = typeahead.payload.entries;
  290. this.getmember();
  291. }
  292. }.bind(this));
  293. },
  294.  
  295. 'getmember':function(){
  296. var regex = /\\?"(\d+)\\?":1/g, a;
  297. for(var i = 0, j = this.lists.length; i < j; i++){
  298. a = new ajax('/ajax/choose/?type=friendlist&flid=' + this.lists[i].uid + '&view=all&__a=1&__d=1&__user=' + w.Env.user);
  299. a.send('GET',null,function(b,c){
  300. var d; this.lists[c].member = {};
  301. while(d = regex.exec(b.responseText)){
  302. this.lists[c].member[d[1]] = 1;
  303. }
  304. }.bind(this,a.XMLHttpRequest,i));
  305. }
  306. }
  307. };
  308.  
  309. if(w && w.Arbiter){
  310. util.insertRule('\
  311. .fbDock {\
  312. margin:' + settings.Margin + '!important;\
  313. }\
  314. #fbDockChatBuddylistNub {\
  315. width:' + settings.Width + '!important;\
  316. }\
  317. .fbNubFlyout {\
  318. min-height:' + settings.MinHeight + '!important;\
  319. }\
  320. .fbChatOrderedList .separator {\
  321. float: left;\
  322. width: 100%;\
  323. }\
  324. .fbChatOrderedList .separator {\
  325. -moz-user-select: none;\
  326. display: table;\
  327. height: 32px;\
  328. }\
  329. .fbChatOrderedList .separator .outer {\
  330. display: table-cell;\
  331. vertical-align: middle;\
  332. }\
  333. .fbChatOrderedList .separator .outer .inner {\
  334. cursor: pointer;\
  335. position: relative;\
  336. text-align: center;\
  337. top: -50%;\
  338. z-index: 1;\
  339. }\
  340. .fbChatOrderedList .separator .text {\
  341. background-color: #FFFFFF;\
  342. color: #989DB3;\
  343. display: inline-block;\
  344. font-size: 10px;\
  345. font-weight: bold;\
  346. padding: 0 5px;\
  347. text-transform: uppercase;\
  348. }\
  349. .fbChatOrderedList .separator .dive {\
  350. left: 0;\
  351. position: absolute;\
  352. top: 50%;\
  353. width: 100%;\
  354. z-index: -1;\
  355. }\
  356. .fbChatOrderedList .separator .dive .bar {\
  357. border-bottom: 2px solid #CCD0DA;\
  358. display: block;\
  359. margin: 0 5px;\
  360. }\
  361. .__42fz {\
  362. float: left;\
  363. width: 100%;\
  364. }\
  365. .__55ln {\
  366. color: #333333;\
  367. display: block;\
  368. height: 28px;\
  369. line-height: 28px;\
  370. padding: 2px 8px 2px 5px;\
  371. position: relative;\
  372. }\
  373. .__55lp {\
  374. position: relative;\
  375. }\
  376. .__56p9 {\
  377. float: left;\
  378. height: 28px;\
  379. position: relative;\
  380. width: 28px;\
  381. }\
  382. .__5bon {\
  383. float: right;\
  384. line-height: 24px;\
  385. margin: 0 4px;\
  386. text-align: right;\
  387. }\
  388. .__568z {\
  389. display: inline-block;\
  390. }\
  391. .__5t35 {\
  392. color: #A8A8A8;\
  393. display: inline-block;\
  394. font-size: 9px;\
  395. font-weight: bold;\
  396. line-height: 12px;\
  397. text-shadow: none;\
  398. vertical-align: middle;\
  399. }\
  400. .__5t35 {\
  401. color: #63A924;\
  402. font-weight: 500;\
  403. }\
  404. ._sp_9ot619 {\
  405. background-image: url("/rsrc.php/v2/ye/r/hKjn1vT0PpA.png");\
  406. background-repeat: no-repeat;\
  407. background-size: auto auto;\
  408. display: inline-block;\
  409. height: 16px;\
  410. width: 16px;\
  411. }\
  412. ._sx_1b221c {\
  413. background-position: -210px -367px;\
  414. height: 7px;\
  415. width: 7px;\
  416. }\
  417. .__55lr {\
  418. overflow: hidden;\
  419. padding-left: 8px;\
  420. text-overflow: ellipsis;\
  421. white-space: nowrap;\
  422. }\
  423. ._sp_axfrm8 {\
  424. background-position: -213px -384px;\
  425. background-image: url("/rsrc.php/v2/yQ/r/5Hl1VnbYk4m.png");\
  426. background-repeat: no-repeat;\
  427. background-size: auto auto;\
  428. display: inline-block;\
  429. height: 11px;\
  430. width: 7px;\
  431. }\
  432. ');
  433.  
  434. rocki.DOMContentLoaded();
  435. rocki.getflid();
  436. }
  437. });
Add Comment
Please, Sign In to add comment