Tieba Chat

Tieba Chat | 这是一个实现在网页端使用贴吧客户端聊天功能的脚本。通过该脚本,您可以与使用贴吧客户端的好友聊天

当前为 2014-07-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Tieba Chat
  3. // @version 1.9
  4. // @description Tieba Chat | 这是一个实现在网页端使用贴吧客户端聊天功能的脚本。通过该脚本,您可以与使用贴吧客户端的好友聊天
  5. // @match http://tieba.baidu.com/*
  6. // @include http://tieba.baidu.com/*
  7. // @author 864907600cc
  8. // @icon http://1.gravatar.com/avatar/147834caf9ccb0a66b2505c753747867
  9. // @run-at document-end
  10. // @grant none
  11. // @noframes
  12. // @namespace http://ext.ccloli.com
  13. // ==/UserScript==
  14. // 本脚本基于 GPLv3 协议开源 http://www.gnu.org/licenses/gpl.html‎
  15. // (c) 86497600cc. Some Rights Reserved.
  16. var hex_md5 = (function(g, k) {
  17. function l(a) {
  18. return n(m(o(a)))
  19. };
  20. function m(a) {
  21. return h(j(p(a), a.length * 8))
  22. };
  23. function n(e) {
  24. try {} catch(a) {
  25. g = 0
  26. };
  27. var b = g ? '0123456789ABCDEF': '0123456789abcdef';
  28. var c = '';
  29. var d;
  30. for (var a = 0; a < e.length; a++) d = e.charCodeAt(a),
  31. c += b.charAt(d >>> 4 & 15) + b.charAt(d & 15);
  32. return c
  33. };
  34. function o(d) {
  35. var b = '';
  36. var c = -1;
  37. var a, e;
  38. while (++c < d.length) a = d.charCodeAt(c),
  39. e = c + 1 < d.length ? d.charCodeAt(c + 1) : 0,
  40. 55296 <= a && a <= 56319 && 56320 <= e && e <= 57343 && (a = 65536 + ((a & 1023) << 10) + (e & 1023), c++),
  41. a <= 127 ? b += String.fromCharCode(a) : a <= 2047 ? b += String.fromCharCode(192 | a >>> 6 & 31, 128 | a & 63) : a <= 65535 ? b += String.fromCharCode(224 | a >>> 12 & 15, 128 | a >>> 6 & 63, 128 | a & 63) : a <= 2097151 && (b += String.fromCharCode(240 | a >>> 18 & 7, 128 | a >>> 12 & 63, 128 | a >>> 6 & 63, 128 | a & 63));
  42. return b
  43. };
  44. function p(c) {
  45. var b = Array(c.length >> 2);
  46. for (var a = 0; a < b.length; a++) b[a] = 0;
  47. for (var a = 0; a < c.length * 8; a += 8) b[a >> 5] |= (c.charCodeAt(a / 8) & 255) << a % 32;
  48. return b
  49. };
  50. function h(c) {
  51. var b = '';
  52. for (var a = 0; a < c.length * 32; a += 8) b += String.fromCharCode(c[a >> 5] >>> a % 32 & 255);
  53. return b
  54. };
  55. function j(j, l) {
  56. j[l >> 5] |= 128 << l % 32,
  57. j[(l + 64 >>> 9 << 4) + 14] = l;
  58. var g = 1732584193;
  59. var h = -271733879;
  60. var i = -1732584194;
  61. var f = 271733878;
  62. for (var k = 0; k < j.length; k += 16) {
  63. var n = g;
  64. var o = h;
  65. var p = i;
  66. var m = f;
  67. g = a(g, h, i, f, j[k + 0], 7, -680876936),
  68. f = a(f, g, h, i, j[k + 1], 12, -389564586),
  69. i = a(i, f, g, h, j[k + 2], 17, 606105819),
  70. h = a(h, i, f, g, j[k + 3], 22, -1044525330),
  71. g = a(g, h, i, f, j[k + 4], 7, -176418897),
  72. f = a(f, g, h, i, j[k + 5], 12, 1200080426),
  73. i = a(i, f, g, h, j[k + 6], 17, -1473231341),
  74. h = a(h, i, f, g, j[k + 7], 22, -45705983),
  75. g = a(g, h, i, f, j[k + 8], 7, 1770035416),
  76. f = a(f, g, h, i, j[k + 9], 12, -1958414417),
  77. i = a(i, f, g, h, j[k + 10], 17, -42063),
  78. h = a(h, i, f, g, j[k + 11], 22, -1990404162),
  79. g = a(g, h, i, f, j[k + 12], 7, 1804603682),
  80. f = a(f, g, h, i, j[k + 13], 12, -40341101),
  81. i = a(i, f, g, h, j[k + 14], 17, -1502002290),
  82. h = a(h, i, f, g, j[k + 15], 22, 1236535329),
  83. g = b(g, h, i, f, j[k + 1], 5, -165796510),
  84. f = b(f, g, h, i, j[k + 6], 9, -1069501632),
  85. i = b(i, f, g, h, j[k + 11], 14, 643717713),
  86. h = b(h, i, f, g, j[k + 0], 20, -373897302),
  87. g = b(g, h, i, f, j[k + 5], 5, -701558691),
  88. f = b(f, g, h, i, j[k + 10], 9, 38016083),
  89. i = b(i, f, g, h, j[k + 15], 14, -660478335),
  90. h = b(h, i, f, g, j[k + 4], 20, -405537848),
  91. g = b(g, h, i, f, j[k + 9], 5, 568446438),
  92. f = b(f, g, h, i, j[k + 14], 9, -1019803690),
  93. i = b(i, f, g, h, j[k + 3], 14, -187363961),
  94. h = b(h, i, f, g, j[k + 8], 20, 1163531501),
  95. g = b(g, h, i, f, j[k + 13], 5, -1444681467),
  96. f = b(f, g, h, i, j[k + 2], 9, -51403784),
  97. i = b(i, f, g, h, j[k + 7], 14, 1735328473),
  98. h = b(h, i, f, g, j[k + 12], 20, -1926607734),
  99. g = c(g, h, i, f, j[k + 5], 4, -378558),
  100. f = c(f, g, h, i, j[k + 8], 11, -2022574463),
  101. i = c(i, f, g, h, j[k + 11], 16, 1839030562),
  102. h = c(h, i, f, g, j[k + 14], 23, -35309556),
  103. g = c(g, h, i, f, j[k + 1], 4, -1530992060),
  104. f = c(f, g, h, i, j[k + 4], 11, 1272893353),
  105. i = c(i, f, g, h, j[k + 7], 16, -155497632),
  106. h = c(h, i, f, g, j[k + 10], 23, -1094730640),
  107. g = c(g, h, i, f, j[k + 13], 4, 681279174),
  108. f = c(f, g, h, i, j[k + 0], 11, -358537222),
  109. i = c(i, f, g, h, j[k + 3], 16, -722521979),
  110. h = c(h, i, f, g, j[k + 6], 23, 76029189),
  111. g = c(g, h, i, f, j[k + 9], 4, -640364487),
  112. f = c(f, g, h, i, j[k + 12], 11, -421815835),
  113. i = c(i, f, g, h, j[k + 15], 16, 530742520),
  114. h = c(h, i, f, g, j[k + 2], 23, -995338651),
  115. g = d(g, h, i, f, j[k + 0], 6, -198630844),
  116. f = d(f, g, h, i, j[k + 7], 10, 1126891415),
  117. i = d(i, f, g, h, j[k + 14], 15, -1416354905),
  118. h = d(h, i, f, g, j[k + 5], 21, -57434055),
  119. g = d(g, h, i, f, j[k + 12], 6, 1700485571),
  120. f = d(f, g, h, i, j[k + 3], 10, -1894986606),
  121. i = d(i, f, g, h, j[k + 10], 15, -1051523),
  122. h = d(h, i, f, g, j[k + 1], 21, -2054922799),
  123. g = d(g, h, i, f, j[k + 8], 6, 1873313359),
  124. f = d(f, g, h, i, j[k + 15], 10, -30611744),
  125. i = d(i, f, g, h, j[k + 6], 15, -1560198380),
  126. h = d(h, i, f, g, j[k + 13], 21, 1309151649),
  127. g = d(g, h, i, f, j[k + 4], 6, -145523070),
  128. f = d(f, g, h, i, j[k + 11], 10, -1120210379),
  129. i = d(i, f, g, h, j[k + 2], 15, 718787259),
  130. h = d(h, i, f, g, j[k + 9], 21, -343485551),
  131. g = e(g, n),
  132. h = e(h, o),
  133. i = e(i, p),
  134. f = e(f, m)
  135. };
  136. return Array(g, h, i, f)
  137. };
  138. function f(a, b, c, d, f, g) {
  139. return e(i(e(e(b, a), e(d, g)), f), c)
  140. };
  141. function a(b, a, c, d, e, g, h) {
  142. return f(a & c | ~a & d, b, a, e, g, h)
  143. };
  144. function b(c, a, d, b, e, g, h) {
  145. return f(a & b | d & ~b, c, a, e, g, h)
  146. };
  147. function c(b, a, c, d, e, g, h) {
  148. return f(a ^ c ^ d, b, a, e, g, h)
  149. };
  150. function d(b, a, c, d, e, g, h) {
  151. return f(c ^ (a | ~d), b, a, e, g, h)
  152. };
  153. function e(b, c) {
  154. var a = (b & 65535) + (c & 65535);
  155. var d = (b >> 16) + (c >> 16) + (a >> 16);
  156. return d << 16 | a & 65535
  157. };
  158. function i(a, b) {
  159. return a << b | a >>> 32 - b
  160. };
  161. return g = 0,
  162. k = '',
  163. l
  164. } ());
  165.  
  166. var user_id = window.PageData.user.id || window.PageData.user.user_id;
  167.  
  168. var _client_id = 'wappc_1398857293796_956',
  169. _client_type = '2',
  170. _client_version = '4.2.7',
  171. _phone_imei = '092887406663530',
  172. net_type = '3',
  173. sign_key = 'tiebaclient!!!';
  174.  
  175. /*if(document.cookie.match(/BDUSS=(.{192,}?);?/))var BDUSS=document.cookie.match(/BDUSS=(.{192,}?);?/)[1];
  176. else if(GM_getValue('BDUSS',0)!=0)var BDUSS=GM_getValue('BDUSS');
  177. else{
  178. var BDUSS=prompt('无法获取 BDUSS,请尝试在移动版贴吧注销并登录(不可用)。\n\n1. 将浏览器 UA 设置为移动设备的 UA(例如 Chrome 可在开发者工具中点击右上角的“Show drawer.”,并在下方的 Emulation 里设置 UserAgent;Firefox 可安装 User Agent Overrider 等扩展);\n2. 访问 http://tieba.baidu.com/mo 进行登录(不可用)操作;\n3. 登录(不可用)后禁用 UA 设置,回到贴吧页检查是否可用。\n\n如果希望手动配置 BDUSS,请将 BDUSS 贴在下方并按确定键。');
  179. if(BDUSS!=null&&BDUSS!=''&&BDUSS.match(/.{192,}?/)){
  180. //document.cookie='BDUSS='+BDUSS.match(/.{192,}?/)+'; expires='+(new Date(new Date().getTime()+60*60*24*365*10*1000)).toGMTString()+'; path=/';
  181. GM_setValue('BDUSS',BDUSS);
  182. var BDUSS=BDUSS;
  183. window.location.href=window.location.href;
  184. }
  185. throw 'Tieba Chat can\'t get BDUSS!!!';
  186. }*/
  187.  
  188. var tb_chat_data = JSON.parse(window.localStorage.getItem('tb_chat_data')) || {};
  189. var message_update_timestamp = window.localStorage.getItem('tb_chat_message_update_timestamp') || new Date().getTime();
  190. var message_update_count = window.localStorage.getItem('tb_chat_message_update_count') || 0;
  191. var user_portrait = '';
  192. var com_portrait = '';
  193. var chatting_list_page = 1;
  194. var this_last_msg = 0;
  195. var this_early_msg = 0;
  196. var this_username = null;
  197. var this_userid = 0;
  198. var this_msg_update = null;
  199. var model = 0;
  200.  
  201. if (tb_chat_data.first_install == null) {
  202. window.$.dialog.alert('<div style="font-size:14px"><p>欢迎使用 Tieba Chat ~~~ ヽ(//∇//)ノ♡</p><p>这是一个实现在网页端使用贴吧客户端的聊天功能的脚本。通过该脚本,您可以方便地与使用贴吧客户端的好友聊天。</p><p>使用说明:<br>1. 将鼠标划至网页右下角的“贴吧聊天”即可打开聊天界面;<br>2. 点击聊天列表中的用户或贴子楼层右下角“聊天”可以发起聊天,点击“点击加载下/上一页”可以进行翻页操作;<br>3. 在聊天界面下方文本框中输入聊天文字,点击右侧“发送”即可发送消息;<br>4. 在聊天界面点击信息列表最上方的“点击查看更多”即可查看之前的消息(如果存在的话);<br>5. 鼠标移出聊天界面后 0.5 秒可收起聊天界面。</p><p style="color:red">警告:<br>* 该脚本目前仍处于测试阶段,可能存在一些未知错误,请谨慎使用<br><del>* 该脚本需要获取 BDUSS,但并不会将其共享,如果您不信任,请卸载此脚本</del> 已确认不需要 BDUSS<br>* 该脚本目前只能发送和接收文字信息,对于图片、表情、语音等多媒体信息暂不支持(主要是 mini 客户端 api 没有提供)<br>* 本脚本目前只是为实现该功能而编写,暂未考虑效率问题,这可能导致浏览器运行缓慢<br>* 本脚本无缓存功能,所有操作均需要重新访问 api,这可能带来较多的带宽消耗<br>* 此脚本的设计可能比较简陋,暂时还没有设置界面……毕竟只是为了测试而已 OTL</p><p>如有疑问请在 firefox 吧相关贴子讨论……</p></div>', {
  203. title: "Tieba Chat 欢迎界面",
  204. width: 800
  205. }) tb_chat_data.first_install = 1;
  206. window.localStorage.setItem('tb_chat_data', JSON.stringify(tb_chat_data));
  207. }
  208.  
  209. function get_string(c) {
  210. var str = '';
  211. var str2 = '';
  212. for (var i in c) {
  213. str += i + '=' + c[i];
  214. str2 += i + '=' + encodeURIComponent(c[i]) + '&';
  215. }
  216. var sign = hex_md5(str + sign_key);
  217. str2 += 'sign=' + sign;
  218. return str2;
  219. }
  220.  
  221. function get_message_update() {
  222. var xhr = new XMLHttpRequest();
  223. xhr.onreadystatechange = function() {
  224. if (xhr.readyState == 4 && xhr.status == 200) {
  225. var t = JSON.parse(xhr.responseText);
  226. if (t.error_code == '0') {
  227. if (t.error && t.error.errno != '0') {
  228. var s = show_error(t.error.errno, t.error.errmsg);
  229. var t = setTimeout(function() {
  230. s.parentElement.removeChild(s);
  231. },
  232. 5000);
  233. s.onclick = function() {
  234. get_message_update();
  235. s.parentElement.removeChild(s);
  236. clearTimeout(t);
  237. };
  238. throw 'Tieba Chat Error ' + t.error.errno + ': ' + t.error.errmsg;
  239. }
  240. message_update_timestamp = new Date().getTime();
  241. message_update_count = t.message.pletter;
  242. if (message_update_count != '0') {
  243. document.title = '【' + message_update_count + ' 条新聊天】' + original_title;
  244. panel_top.style.color = 'orange';
  245. } else {
  246. document.title = original_title;
  247. panel_top.style.color = '#000';
  248. }
  249. window.localStorage.setItem('tb_chat_message_update_timestamp', message_update_timestamp);
  250. window.localStorage.setItem('tb_chat_message_update_count', t.message.pletter);
  251. } else {
  252. var s = show_error(t.error_code, t.error_msg);
  253. var t = setTimeout(function() {
  254. s.parentElement.removeChild(s);
  255. },
  256. 5000);
  257. s.onclick = function() {
  258. get_message_update();
  259. s.parentElement.removeChild(s);
  260. clearTimeout(t);
  261. };
  262. throw 'Tieba Chat Error ' + t.error_code + ': ' + t.error_msg;
  263. }
  264. }
  265. };
  266. xhr.open('POST', '//tieba.baidu.com/c/s/msg?' + get_string());
  267. xhr.send();
  268. }
  269.  
  270. function get_chatting_list(pn) {
  271. var xhr = new XMLHttpRequest();
  272. xhr.onreadystatechange = function() {
  273. if (xhr.readyState == 4 && xhr.status == 200) {
  274. var t = JSON.parse(xhr.responseText);
  275. if (t.error_code == '0') {
  276. if (t.error && t.error.errno != '0') {
  277. var s = show_error(t.error.errno, t.error.errmsg);
  278. var t = setTimeout(function() {
  279. s.parentElement.removeChild(s);
  280. },
  281. 5000);
  282. s.onclick = function() {
  283. get_chatting_list(pn);
  284. s.parentElement.removeChild(s);
  285. clearTimeout(t);
  286. };
  287. throw 'Tieba Chat Error ' + t.error.errno + ': ' + t.error.errmsg;
  288. }
  289. switch (model) {
  290. case 0:
  291. panel_head.textContent = '贴吧聊天';
  292. break;
  293. case 1:
  294. panel_head.textContent = '贴吧聊天(标记阅读模式)';
  295. break;
  296. case 2:
  297. panel_head.textContent = '贴吧聊天(删除用户模式)';
  298. break;
  299. }
  300. panel.setAttribute('model', model);
  301. panel_main.innerHTML = '';
  302. var panel_list = document.createElement('div');
  303. panel_list.className = 'tb_chat_panel_list';
  304. panel_main.appendChild(panel_list);
  305. chatting_list_page = pn;
  306. if (pn > 1) {
  307. var msg_more = document.createElement('div');
  308. msg_more.textContent = '点击加载上一页';
  309. msg_more.style.cssText = 'width:200px;margin:20px auto;text-align:center;font-size:13px;background:#0CF;padding:5px;-webkit-user-select:none;-moz-user-select:none;cursor:pointer;color:#FFF';
  310. panel_list.appendChild(msg_more);
  311. msg_more.onclick = function() {
  312. get_chatting_list(pn - 1);
  313. msg_more.textContent = '正在载入......';
  314. };
  315. }
  316. for (var c in t.record) {
  317. var p = document.createElement('div');
  318. p.className = 'tb_chat_row';
  319. p.setAttribute('user_id', t.record[c].user_id);
  320. p.setAttribute('user_name', t.record[c].user_name) p.innerHTML = '<div class="tb_chat_pleft"><img class="tb_chat_avatar" src="http://tb.himg.baidu.com/sys/portrait/item/' + t.record[c].portrait + '" alt></div><div class="tb_chat_pright"><div class="tb_chat_username">' + t.record[c].user_name + (t.record[c].unread_count == '0' ? '': ' <small>(' + t.record[c].unread_count + ')</small>') + '</div><div class="tb_chat_lasttext">' + (t.record[c].abstract.length > 0 ? t.record[c].abstract[t.record[c].abstract.length - 1].text: '') + '</div></div><div style="clear:both"></div>';
  321. if (t.record[c].unread_count != '0') {
  322. p.style.color = 'orange';
  323. p.onclick = function() {
  324. panel_top.style.color = '#000';
  325. switch (model) {
  326. case 0:
  327. this_userid = this.getAttribute('user_id');
  328. this_username = this.getAttribute('user_name');
  329. get_latest_msg(this.getAttribute('user_id'));
  330. break;
  331. case 1:
  332. get_latest_msg(this.getAttribute('user_id'), true);
  333. this.style.color = '#000';
  334. break;
  335. case 2:
  336. delete_user(this.getAttribute('user_id'), true);
  337. break;
  338. }
  339. }
  340. } else p.onclick = function() {
  341. switch (model) {
  342. case 0:
  343. this_userid = this.getAttribute('user_id');
  344. this_username = this.getAttribute('user_name');
  345. get_latest_msg(this.getAttribute('user_id'));
  346. break;
  347. case 1:
  348. get_latest_msg(this.getAttribute('user_id'), true);
  349. break;
  350. case 2:
  351. delete_user(this.getAttribute('user_id'), true);
  352. break;
  353. }
  354. }
  355. panel_list.appendChild(p);
  356. }
  357. if (t.has_more == 1) {
  358. var msg_more = document.createElement('div');
  359. msg_more.textContent = '点击加载下一页';
  360. msg_more.style.cssText = 'width:200px;margin:20px auto;text-align:center;font-size:13px;background:#0CF;padding:5px;-webkit-user-select:none;-moz-user-select:none;cursor:pointer;color:#FFF';
  361. panel_list.appendChild(msg_more);
  362. msg_more.onclick = function() {
  363. get_chatting_list(pn + 1);
  364. msg_more.textContent = '正在载入......';
  365. };
  366. }
  367. panel_top_left.textContent = '+';
  368. panel_top_right.textContent = '≡';
  369. panel_top_left.onclick = function() {
  370. var username = prompt('请输入用户名以发起聊天');
  371. if (username != null && username != '') get_userid(username);
  372. }
  373. panel_top_right.onclick = function() {
  374. switch (prompt('请键入以下数字并点击“确定”以完成对应操作:\n1. 进入标记已读模式\n2. 进入删除用户模式\n3. 回到聊天模式\n\n(比较简陋真是抱歉了 _(:з」∠)_ )')) {
  375. case '1':
  376. alert('现在你可以通过点击聊天面板上的用户来标记已读,标记已读的用户将不会再提醒以前的消息\n警告:该操作仅是方便标记已查阅的消息记录,请注意辨别未查阅的消息,标记过程将不会出现提醒,且操作不可逆\n如果需要回到聊天模式,请点击右上角的三道杠');
  377. model = 1;
  378. get_chatting_list(pn);
  379. break;
  380. case '2':
  381. alert('现在你可以通过点击聊天面板上的用户来删除该用户,删除的用户将不会再出现在聊天面板上\n警告:该操作仅是方便删除垃圾信息,请注意辨别消息发送用户,标记过程将不会出现提醒,且操作不可逆\n如果需要回到聊天模式,请点击右上角的三道杠');
  382. model = 2;
  383. get_chatting_list(pn);
  384. break;
  385. case '3':
  386. alert('已回到聊天模式');
  387. model = 0;
  388. get_chatting_list(pn);
  389. }
  390. }
  391. this_last_msg = 0;
  392. this_early_msg = 0;
  393. this_username = null;
  394. this_userid = 0;
  395. } else {
  396. var s = show_error(t.error_code, t.error_msg);
  397. var t = setTimeout(function() {
  398. s.parentElement.removeChild(s);
  399. },
  400. 5000);
  401. s.onclick = function() {
  402. get_chatting_list(pn);
  403. s.parentElement.removeChild(s);
  404. clearTimeout(t);
  405. };
  406. throw 'Tieba Chat Error ' + t.error_code + ': ' + t.error_msg;
  407. }
  408. }
  409. };
  410. xhr.open('POST', '//tieba.baidu.com/c/s/comlist?' + get_string({
  411. //BDUSS:BDUSS,
  412. _client_id: _client_id,
  413. _client_type: _client_type,
  414. _client_version: _client_version,
  415. _phone_imei: _phone_imei,
  416. net_type: net_type,
  417. pn: pn
  418. }));
  419. xhr.send();
  420. }
  421.  
  422. function get_latest_msg(id, silent) {
  423. var silent = silent || false;
  424. var xhr = new XMLHttpRequest();
  425. xhr.onreadystatechange = function() {
  426. if (xhr.readyState == 4 && xhr.status == 200) {
  427. var t = JSON.parse(xhr.responseText);
  428. if (t.error_code == '0') {
  429. if (t.error && t.error.errno != '0') {
  430. var s = show_error(t.error.errno, t.error.errmsg);
  431. var t = setTimeout(function() {
  432. s.parentElement.removeChild(s);
  433. },
  434. 5000);
  435. s.onclick = function() {
  436. get_latest_msg(id);
  437. s.parentElement.removeChild(s);
  438. clearTimeout(t);
  439. };
  440. throw 'Tieba Chat Error ' + t.error.errno + ': ' + t.error.errmsg;
  441. }
  442. if (silent == false) {
  443. //console.log(this_early_msg+'|'+this_last_msg);
  444. if (id != this_userid || document.getElementsByClassName('tb_chat_panel_list')[0]) panel_main.innerHTML = '';
  445. panel_head.textContent = this_username;
  446. if (document.getElementsByClassName('tb_chat_panel_msg')[0]) var panel_msg = document.getElementsByClassName('tb_chat_panel_msg')[0];
  447. else {
  448. var panel_msg = document.createElement('div');
  449. panel_msg.className = 'tb_chat_panel_msg';
  450. panel_main.appendChild(panel_msg);
  451. }
  452. com_portrait = t.com_portrait;
  453. user_portrait = t.user_portrait;
  454. if (t.has_more == 1) {
  455. var msg_more = document.createElement('div');
  456. msg_more.textContent = '点击加载更多';
  457. msg_more.style.cssText = 'width:200px;margin:20px auto;text-align:center;font-size:13px;background:#0CF;padding:5px;-webkit-user-select:none;-moz-user-select:none;cursor:pointer;color:#FFF';
  458. panel_msg.appendChild(msg_more);
  459. msg_more.onclick = function() {
  460. get_early_msg(id, panel_msg, msg_more);
  461. };
  462. }
  463. for (var c in t.message) {
  464. var p = document.createElement('div');
  465. p.className = 'tb_chat_message';
  466. if (t.message[c].from == '0') {
  467. p.className += ' com';
  468. p.innerHTML = '<div class="tb_chat_pleft"><img class="tb_chat_avatar" src="http://tb.himg.baidu.com/sys/portrait/item/' + com_portrait + '" alt></div><div class="tb_chat_pright"><div class="tb_chat_message_inner">' + (t.message[c].content[0].text || '未知数据') + '</div></div><div style="clear:both"></div>';
  469. } else {
  470. p.className += ' user';
  471. p.innerHTML = '<div class="tb_chat_pleft"><img class="tb_chat_avatar" src="http://tb.himg.baidu.com/sys/portrait/item/' + user_portrait + '" alt></div><div class="tb_chat_pright"><div class="tb_chat_message_inner">' + (t.message[c].content[0].text || '未知数据') + '</div></div><div style="clear:both"></div>';
  472. }
  473. p.setAttribute('msg_id', t.message[c].msg_id);
  474. p.title = 'Post @ ' + new Date(t.message[c].time * 1000);
  475. panel_msg.appendChild(p);
  476. if (parseInt(t.message[c].msg_id, 10) < parseInt(this_early_msg, 10) || this_early_msg == 0) this_early_msg = t.message[c].msg_id;
  477. if (parseInt(t.message[c].msg_id, 10) > parseInt(this_last_msg, 10) || this_last_msg == 0) this_last_msg = t.message[c].msg_id;
  478. //console.log(this_early_msg+'|'+this_last_msg);
  479. }
  480. panel_msg.scrollTop = panel_msg.scrollHeight;
  481. this_userid = id;
  482. if (!document.getElementsByClassName('tb_chat_msg_panel')[0]) {
  483. var msg_panel = document.createElement('div');
  484. var msg_textarea = document.createElement('textarea');
  485. var msg_send = document.createElement('div');
  486. msg_panel.style.cssText = 'width:100%;height:50px;position:absolute;bottom:0;left:0';
  487. msg_panel.className = 'tb_chat_msg_panel';
  488. panel_main.appendChild(msg_panel);
  489. msg_textarea.style.cssText = 'width:320px;height:36px;font-size:12px;margin:7px;position:absolute;left:0;top:0;resize:none';
  490. msg_textarea.className = 'tb_chat_msg_textarea';
  491. msg_panel.appendChild(msg_textarea);
  492. msg_send.style.cssText = 'width:50px;height:25px;font-size:14px;line-height:25px;text-align:center;position:absolute;margin:15px 7px;right:0;top:0;background:#0CF;cursor:pointer;color:#FFF';
  493. msg_send.textContent = '发送';
  494. msg_panel.appendChild(msg_send);
  495. msg_send.onclick = function() {
  496. if (msg_textarea.value != '') add_message(id, this_last_msg, msg_textarea.value);
  497. };
  498. msg_textarea.onfocus = function(event) {
  499. msg_textarea.onkeydown = function(event) {
  500. if (event.ctrlKey == 1 && event.keyCode == 13 && msg_textarea.value != '') add_message(id, this_last_msg, msg_textarea.value);
  501. };
  502. };
  503. msg_textarea.onblur = function() {
  504. msg_textarea.onkeydown = null;
  505. };
  506. window.onfocus = function() {
  507. if (this_msg_update == null) this_msg_update = setInterval(function() {
  508. if (document.getElementsByClassName('tb_chat_msg_panel')[0] && panel.hasAttribute('show')) get_latest_msg(id)
  509. },
  510. 10000);
  511. };
  512. window.onblur = function() {
  513. if (this_msg_update != null) {
  514. clearInterval(this_msg_update);
  515. this_msg_update = null;
  516. }
  517. };
  518. panel_top_left.textContent = '←';
  519. panel_top_right.textContent = '≡';
  520. msg_textarea.focus();
  521. panel_top_right.onclick = function() {
  522. switch (prompt('请键入以下数字并点击“确定”以完成对应操作:\n1. 清空当前用户全部聊天记录\n2. 从聊天列表内删除当前用户\n\n(比较简陋真是抱歉了 _(:з」∠)_ )')) {
  523. case '1':
  524. delete_msg(id);
  525. break;
  526. case '2':
  527. delete_user(id);
  528. break;
  529. }
  530. };
  531. panel_top_left.onclick = function() {
  532. get_chatting_list(chatting_list_page);
  533. if (this_msg_update != null) {
  534. clearInterval(this_msg_update);
  535. this_msg_update = null;
  536. }
  537. window.onfocus = null;
  538. window.onblur = null;
  539. };
  540. }
  541. }
  542. get_message_update();
  543. } else {
  544. var s = show_error(t.error_code, t.error_msg);
  545. var t = setTimeout(function() {
  546. s.parentElement.removeChild(s);
  547. },
  548. 5000);
  549. s.onclick = function() {
  550. get_latest_msg(id);
  551. s.parentElement.removeChild(s);
  552. clearTimeout(t);
  553. };
  554. throw 'Tieba Chat Error ' + t.error_code + ': ' + t.error_msg;
  555. }
  556. }
  557. };
  558. xhr.open('POST', '//tieba.baidu.com/c/s/recentmsg?' + get_string({
  559. //BDUSS:BDUSS,
  560. _client_id: _client_id,
  561. _client_type: _client_type,
  562. _client_version: _client_version,
  563. _phone_imei: _phone_imei,
  564. com_id: id,
  565. msg_id: this_last_msg,
  566. net_type: net_type,
  567. user_id: user_id
  568. }));
  569. xhr.send();
  570. }
  571.  
  572. function get_early_msg(id, panel_msg, msg_more) {
  573. msg_more.textContent = '正在载入......';
  574. var scroll_top = panel_msg.scrollHeight - panel_msg.scrollTop;
  575. var xhr = new XMLHttpRequest();
  576. xhr.onreadystatechange = function() {
  577. if (xhr.readyState == 4 && xhr.status == 200) {
  578. var t = JSON.parse(xhr.responseText);
  579. if (t.error_code == '0') {
  580. if (t.error && t.error.errno != '0') {
  581. var s = show_error(t.error.errno, t.error.errmsg);
  582. var t = setTimeout(function() {
  583. s.parentElement.removeChild(s);
  584. },
  585. 5000);
  586. s.onclick = function() {
  587. get_early_msg(id, panel_msg, msg_more);
  588. s.parentElement.removeChild(s);
  589. clearTimeout(t);
  590. };
  591. throw 'Tieba Chat Error ' + t.error.errno + ': ' + t.error.errmsg;
  592. }
  593. var xxx = document.createElement('div');
  594. //console.log(this_early_msg+'|'+this_last_msg);
  595. panel_msg.insertBefore(xxx, msg_more.nextElementSibling);
  596. for (var c in t.message) {
  597. var p = document.createElement('div');
  598. p.className = 'tb_chat_message';
  599. if (t.message[c].from == '0') {
  600. p.className += ' com';
  601. p.innerHTML = '<div class="tb_chat_pleft"><img class="tb_chat_avatar" src="http://tb.himg.baidu.com/sys/portrait/item/' + com_portrait + '" alt></div><div class="tb_chat_pright"><div class="tb_chat_message_inner">' + (t.message[c].content[0].text || '未知数据') + '</div></div><div style="clear:both"></div>';
  602. } else {
  603. p.className += ' user';
  604. p.innerHTML = '<div class="tb_chat_pleft"><img class="tb_chat_avatar" src="http://tb.himg.baidu.com/sys/portrait/item/' + user_portrait + '" alt></div><div class="tb_chat_pright"><div class="tb_chat_message_inner">' + (t.message[c].content[0].text || '未知数据') + '</div></div><div style="clear:both"></div>';
  605. }
  606. p.setAttribute('msg_id', t.message[c].msg_id);
  607. p.title = 'Post @ ' + new Date(t.message[c].time * 1000);
  608. if (parseInt(t.message[c].msg_id, 10) < parseInt(this_early_msg, 10) || this_early_msg == 0) this_early_msg = t.message[c].msg_id;
  609. if (parseInt(t.message[c].msg_id, 10) > parseInt(this_last_msg, 10) || this_last_msg == 0) this_last_msg = t.message[c].msg_id;
  610. xxx.appendChild(p);
  611. //console.log(this_early_msg+'|'+this_last_msg+'|'+t.message[c].msg_id);
  612. }
  613. if (t.has_more == 1) msg_more.textContent = '点击加载更多';
  614. else msg_more.parentElement.removeChild(msg_more);
  615. panel_msg.scrollTop = panel_msg.scrollHeight - scroll_top;
  616. } else {
  617. var s = show_error(t.error_code, t.error_msg);
  618. var t = setTimeout(function() {
  619. s.parentElement.removeChild(s);
  620. },
  621. 5000);
  622. s.onclick = function() {
  623. get_early_msg(id, panel_msg, msg_more);
  624. s.parentElement.removeChild(s);
  625. clearTimeout(t);
  626. };
  627. throw 'Tieba Chat Error ' + t.error_code + ': ' + t.error_msg;
  628. }
  629. }
  630. };
  631. xhr.open('POST', '//tieba.baidu.com/c/s/historymsg?' + get_string({
  632. //BDUSS:BDUSS,
  633. _client_id: _client_id,
  634. _client_type: _client_type,
  635. _client_version: _client_version,
  636. _phone_imei: _phone_imei,
  637. com_id: id,
  638. msg_id: this_early_msg,
  639. net_type: net_type,
  640. user_id: user_id
  641. }));
  642. xhr.send();
  643. }
  644.  
  645. function add_message(id, last_msg_id, content) {
  646. var xhr = new XMLHttpRequest();
  647. xhr.onreadystatechange = function() {
  648. if (xhr.readyState == 4 && xhr.status == 200) {
  649. var t = JSON.parse(xhr.responseText);
  650. if (t.error_code == '0') {
  651. if (t.error && t.error.errno != '0') {
  652. var s = show_error(t.error.errno, t.error.errmsg);
  653. var t = setTimeout(function() {
  654. s.parentElement.removeChild(s);
  655. },
  656. 5000);
  657. s.onclick = function() {
  658. add_message(id, last_msg_id, content);
  659. s.parentElement.removeChild(s);
  660. clearTimeout(t);
  661. };
  662. throw 'Tieba Chat Error ' + t.error.errno + ': ' + t.error.errmsg;
  663. }
  664. var panel_msg = document.getElementsByClassName('tb_chat_panel_msg')[0];
  665. for (var c in t.recent.message) {
  666. var p = document.createElement('div');
  667. p.className = 'tb_chat_message';
  668. if (t.recent.message[c].from == '0') {
  669. p.className += ' com';
  670. p.innerHTML = '<div class="tb_chat_pleft"><img class="tb_chat_avatar" src="http://tb.himg.baidu.com/sys/portrait/item/' + com_portrait + '" alt></div><div class="tb_chat_pright"><div class="tb_chat_message_inner">' + (t.recent.message[c].content[0].text || '未知数据') + '</div></div><div style="clear:both"></div>';
  671. } else {
  672. p.className += ' user';
  673. p.innerHTML = '<div class="tb_chat_pleft"><img class="tb_chat_avatar" src="http://tb.himg.baidu.com/sys/portrait/item/' + user_portrait + '" alt></div><div class="tb_chat_pright"><div class="tb_chat_message_inner">' + (t.recent.message[c].content[0].text || '未知数据') + '</div></div><div style="clear:both"></div>';
  674. }
  675. p.setAttribute('msg_id', t.recent.message[c].msg_id);
  676. p.title = 'Post @ ' + new Date(t.recent.message[c].time * 1000);
  677. panel_msg.appendChild(p);
  678. if (parseInt(t.recent.message[c].msg_id, 10) < parseInt(this_early_msg, 10) || this_early_msg == 0) this_early_msg = t.recent.message[c].msg_id;
  679. if (parseInt(t.recent.message[c].msg_id, 10) > parseInt(this_last_msg, 10) || this_last_msg == 0) this_last_msg = t.recent.message[c].msg_id;
  680. }
  681. var p = document.createElement('div');
  682. p.className = 'tb_chat_message';
  683. p.className += ' user';
  684. p.innerHTML = '<div class="tb_chat_pleft"><img class="tb_chat_avatar" src="http://tb.himg.baidu.com/sys/portrait/item/' + user_portrait + '" alt></div><div class="tb_chat_pright"><div class="tb_chat_message_inner">' + (t.message.content[0].text || '未知数据') + '</div></div><div style="clear:both"></div>';
  685. p.setAttribute('msg_id', t.message.msg_id);
  686. panel_msg.appendChild(p);
  687. if (parseInt(t.message.msg_id, 10) < parseInt(this_early_msg, 10) || this_early_msg == 0) this_early_msg = t.message.msg_id;
  688. if (parseInt(t.message.msg_id, 10) > parseInt(this_last_msg, 10) || this_last_msg == 0) this_last_msg = t.message.msg_id;
  689. panel_msg.scrollTop = panel_msg.scrollHeight;
  690. document.getElementsByClassName('tb_chat_msg_textarea')[0].value = '';
  691. document.getElementsByClassName('tb_chat_msg_textarea')[0].focus();
  692. } else {
  693. var s = show_error(t.error_code, t.error_msg);
  694. var t = setTimeout(function() {
  695. s.parentElement.removeChild(s);
  696. },
  697. 5000);
  698. s.onclick = function() {
  699. add_message(id, last_msg_id, content);
  700. s.parentElement.removeChild(s);
  701. clearTimeout(t);
  702. };
  703. throw 'Tieba Chat Error ' + t.error_code + ': ' + t.error_msg;
  704. }
  705. }
  706. };
  707. xhr.open('POST', '//tieba.baidu.com/c/s/addmsg?' + get_string({
  708. //BDUSS:BDUSS,
  709. _client_id: _client_id,
  710. _client_type: _client_type,
  711. _client_version: _client_version,
  712. _phone_imei: _phone_imei,
  713. com_id: id,
  714. content: content,
  715. last_msg_id: last_msg_id,
  716. net_type: net_type,
  717. user_id: user_id
  718. }));
  719. xhr.send();
  720. }
  721.  
  722. function show_error(c, t) {
  723. var panel_error = document.createElement('div');
  724. panel_error.className = 'tb_chat_error';
  725. panel.appendChild(panel_error);
  726. panel_error.innerHTML = 'Tieba Chat Error!!!<br>Error Code: ' + c + '<br>Error Message:' + t + '<br>Click this panel to retry....';
  727. return panel_error;
  728. }
  729.  
  730. function get_userid(username) {
  731. var xhr = new XMLHttpRequest();
  732. xhr.onreadystatechange = function() {
  733. if (xhr.readyState == 4 && xhr.status == 200) {
  734. var t = JSON.parse(xhr.responseText);
  735. if (t.no == 0) {
  736. this_username = username;
  737. this_userid = t.data.id;
  738. get_latest_msg(t.data.id);
  739. } else {
  740. var s = show_error(t.no, t.error);
  741. var t = setTimeout(function() {
  742. s.parentElement.removeChild(s);
  743. },
  744. 5000);
  745. s.onclick = function() {
  746. get_userid(username);
  747. s.parentElement.removeChild(s);
  748. clearTimeout(t);
  749. };
  750. throw 'Tieba Chat Error ' + t.no + ': ' + t.error;
  751. }
  752. }
  753. };
  754. xhr.open('POST', '//tieba.baidu.com/home/get/panel?ie=utf-8&un=' + encodeURIComponent(username));
  755. xhr.send();
  756. }
  757.  
  758. function delete_msg(id) {
  759. var xhr = new XMLHttpRequest();
  760. xhr.onreadystatechange = function() {
  761. if (xhr.readyState == 4 && xhr.status == 200) {
  762. var t = JSON.parse(xhr.responseText);
  763. if (t.error.errno == "0" && t.error_code == "0") {
  764. alert('清除成功!');
  765. document.getElementsByClassName('tb_chat_panel_msg')[0].innerHTML = '';
  766. } else {
  767. var s = show_error(t.error_code, t.error_msg);
  768. var t = setTimeout(function() {
  769. s.parentElement.removeChild(s);
  770. },
  771. 5000);
  772. s.onclick = function() {
  773. delete_msg(id);
  774. s.parentElement.removeChild(s);
  775. clearTimeout(t);
  776. };
  777. throw 'Tieba Chat Error ' + t.error_code + ': ' + t.error_msg;
  778. }
  779. }
  780. };
  781. xhr.open('POST', '//tieba.baidu.com/c/s/clearmsg?' + get_string({
  782. _client_id: _client_id,
  783. _client_type: _client_type,
  784. _client_version: _client_version,
  785. _phone_imei: _phone_imei,
  786. com_id: id,
  787. net_type: net_type,
  788. user_id: user_id
  789. }));
  790. xhr.send();
  791. }
  792.  
  793. function delete_user(id, silent) {
  794. var silent = silent || false;
  795. var xhr = new XMLHttpRequest();
  796. xhr.onreadystatechange = function() {
  797. if (xhr.readyState == 4 && xhr.status == 200) {
  798. var t = JSON.parse(xhr.responseText);
  799. if (t.error.errno == "0" && t.error_code == "0") {
  800. if (silent == false) {
  801. alert('删除成功!');
  802. if (this_msg_update != null) {
  803. clearInterval(this_msg_update);
  804. this_msg_update = null;
  805. }
  806. window.onfocus = null;
  807. window.onblur = null;
  808. }
  809. get_chatting_list(chatting_list_page);
  810. } else {
  811. var s = show_error(t.error_code, t.error_msg);
  812. var t = setTimeout(function() {
  813. s.parentElement.removeChild(s);
  814. },
  815. 5000);
  816. s.onclick = function() {
  817. delete_msg(id);
  818. s.parentElement.removeChild(s);
  819. clearTimeout(t);
  820. };
  821. throw 'Tieba Chat Error ' + t.error_code + ': ' + t.error_msg;
  822. }
  823. }
  824. };
  825. xhr.open('POST', '//tieba.baidu.com/c/s/delcom?' + get_string({
  826. _client_id: _client_id,
  827. _client_type: _client_type,
  828. _client_version: _client_version,
  829. _phone_imei: _phone_imei,
  830. com_id: id,
  831. net_type: net_type,
  832. tbs: PageData.tbs ? PageData.tbs: get_tbs(),
  833. user_id: user_id
  834. }));
  835. xhr.send();
  836. }
  837.  
  838. function get_tbs() {
  839. var xhr = new XMLHttpRequest();
  840. xhr.onreadystatechange = function() {
  841. if (xhr.readyState == 4 && xhr.status == 200) return JSON.parse(xhr.responseText).tbs;
  842. };
  843. xhr.open('GET', 'http://tieba.baidu.com/dc/common/tbs');
  844. xhr.send();
  845. }
  846.  
  847. function insert_chat_button(event) {
  848. if (event.animationName == 'nodeInserted') {
  849. var button = document.createElement('a');
  850. var node = event.target;
  851. button.className = 'btn_chat';
  852. node.parentElement.insertBefore(button, node);
  853. button.onclick = function() {
  854. get_userid(JSON.parse(node.parentElement.parentElement.parentElement.parentElement.getAttribute('data-field')).un);
  855. panel.setAttribute('show', '1');
  856. };
  857. }
  858. }
  859.  
  860. var message_update_timer = setInterval(function() {
  861. if ((new Date().getTime() - (window.localStorage.getItem('tb_chat_message_update_timestamp') || message_update_timestamp)) > 10000) {
  862. get_message_update();
  863. } else if (window.localStorage.getItem('tb_chat_message_update_count') != '0') {
  864. document.title = '【' + window.localStorage.getItem('tb_chat_message_update_count') + ' 条新聊天】' + original_title;
  865. panel_top.style.color = 'orange';
  866. } else {
  867. document.title = original_title;
  868. panel_top.style.color = '#000';
  869. }
  870. },
  871. 1000);
  872.  
  873. // ------------------------------------------------------------------------
  874.  
  875. var panel = document.createElement('div');
  876. var panel_top = document.createElement('div');
  877. var panel_head = document.createElement('div');
  878. var panel_main = document.createElement('div');
  879. var panel_top_left = document.createElement('div');
  880. var panel_top_right = document.createElement('div');
  881. var panel_ifshow = null;
  882. var original_title = document.title;
  883. var ss = document.createElement('style');
  884. var stylesheet = '.tb_chat_panel{width:400px;height:100%;position:fixed;top:calc(100% - 30px);right:0px;background:rgba(255,255,255,.75);z-index:200000;transition:all 0.5s ease-in;-webkit-user-select:none;-moz-user-select:none;border:1px solid #CCC;font-size:14px}.tb_chat_panel[show]{top:0px;transition:all 0.5s ease-out}.tb_chat_panel_top{font-size:14px;line-height:30px;text-align:center;width:100%;height:30px;-webkit-user-select:none;-moz-user-select:none;border-bottom:1px solid #CCC}.tb_chat_panel_top_left{position:absolute;left:10px;top:3px;width:24px;height:24px;line-height:24px;background:#0CF;opacity:0;color:#FFF;cursor:pointer;text-align:center;border-radius:50%;transition:all 0.5s ease-out}.tb_chat_panel[show] .tb_chat_panel_top_left{opacity:1;transition:all 0.5s ease-in}.tb_chat_panel_top_right{position:absolute;right:10px;top:3px;width:24px;height:24px;line-height:24px;background:#0CF;opacity:0;color:#FFF;cursor:pointer;text-align:center;border-radius:50%;transition:all 0.5s ease-out}.tb_chat_panel[show] .tb_chat_panel_top_right{opacity:1;transition:all 0.5s ease-in}.tb_chat_panel_main{height:calc(100% - 30px);overflow:auto}.tb_chat_row{/*width:400px;*/height:60px;padding:10px;cursor:pointer}.tb_chat_row:hover{background:rgba(0,0,0,.1)}.tb_chat_pleft{float:left}.tb_chat_row .tb_chat_avatar{width:60px;height:60px}.tb_chat_pright{float:left;max-width:300px}.tb_chat_row .tb_chat_username{font-size:14px;padding:6px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.tb_chat_row .tb_chat_lasttext{padding:6px;font-size:12px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.tb_chat_next{font-size:14px;text-align:center;width:100%;height:30px;line-height:30px}.tb_chat_message{font-size:12px;line-height:14px;min-height:28px;padding:5px}.tb_chat_message .tb_chat_avatar{width:28px;height:28px}.tb_chat_message.user .tb_chat_pleft,.tb_chat_message.user .tb_chat_pright{float:right;text-align:right}.tb_chat_message .tb_chat_message_inner{margin:0 10px;padding:6px;background:#FFF;border:1px solid #CCC;border-radius:3px;-moz-user-select:text;-webkit-user-select:text;text-align:left}.tb_chat_panel_msg{margin-bottom:50px;height:calc(100% - 50px);overflow:auto}.tb_chat_error{background:rgba(255,0,0,.25);font-size:12px;line-height:16px;position:fixed;width:350px;margin:0 25px;top:50px;right:0px;box-shadow:rgba(255,0,0,0.25) 0 0 5px;color:#F00}.tb_chat_message_inner::selection,.tb_chat_message_inner::-moz-selection{background:rgba(255,255,255,0.5)}.tb_chat_panel[model="1"] .tb_chat_panel_top,.tb_chat_panel[model="2"] .tb_chat_panel_top,.tb_chat_panel[model="2"] .tb_chat_row{color:red!important}.btn_sendmsg{animation:nodeInserted 0.01s;-webkit-animation:nodeInserted 0.01s;-o-animation:nodeInserted 0.01s;-ms-animation:nodeInserted 0.01s}@keyframes nodeInserted{from{background-color:#FFF}to{background-color:#EEE}}@-webkit-keyframes nodeInserted{from{background-color:#FFF}to{background-color:#EEE}}@-o-keyframes nodeInserted{from{background-color:#FFF}to{background-color:#EEE}}@-ms-keyframes nodeInserted{from{background-color:#FFF}to{background-color:#EEE}}.btn_chat{cursor:pointer;margin-left:8px;background-image:url(http://imgsrc.baidu.com/forum/pic/item/c28b2d6d55fbb2fb8303a7d94d4a20a44723dcb3.jpg)!important;background-position:0 0!important}.btn_chat:hover{background-position:-86px 0!important}.btn_chat:active{background-position:-172px 0!important}.interaction_wrap_theme1 .btn_chat{background-position:0 -22px!important;width:70px!important}.interaction_wrap_theme1 .btn_chat:hover{background-position:-86px -22px!important}.interaction_wrap_theme1 .btn_chat:active{background-position:-172px -22px!important}';
  885. panel.className = 'tb_chat_panel';
  886. document.body.appendChild(panel);
  887. ss.textContent = stylesheet;
  888. panel.appendChild(ss);
  889. panel_top.className = 'tb_chat_panel_top';
  890. panel.appendChild(panel_top);
  891. panel_head.textContent = '贴吧聊天';
  892. panel_top.appendChild(panel_head);
  893. panel_top_left.className = 'tb_chat_panel_top_left';
  894. panel_top_left.textContent = '+';
  895. panel_top.appendChild(panel_top_left);
  896. panel_top_right.className = 'tb_chat_panel_top_right';
  897. panel_top_right.textContent = '≡';
  898. panel_top.appendChild(panel_top_right);
  899. panel_main.className = 'tb_chat_panel_main';
  900. panel.appendChild(panel_main);
  901.  
  902. panel_top.onmouseover = function() {
  903. if (!panel.hasAttribute('show')) {
  904. if (this_userid == 0) get_chatting_list(chatting_list_page);
  905. else get_latest_msg(this_userid);
  906. }
  907. panel.setAttribute('show', '1');
  908. };
  909. panel.onmouseover = function() {
  910. if (panel_ifshow != null) clearTimeout(panel_ifshow);
  911. };
  912. panel.onmouseout = function() {
  913. panel_ifshow = setTimeout(function() {
  914. if (panel.hasAttribute('show')) panel.removeAttribute('show');
  915. panel_ifshow = null;
  916. },
  917. 500);
  918. };
  919. panel_top_left.onclick = function() {
  920. var username = prompt('请输入用户名以发起聊天');
  921. if (username != null && username != '') get_userid(username);
  922. };
  923. get_chatting_list(chatting_list_page);
  924. document.addEventListener('animationstart', insert_chat_button, false);
  925. document.addEventListener('MSAnimationStart', insert_chat_button, false);
  926. document.addEventListener('webkitAnimationStart', insert_chat_button, false);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址