Tieba Advanced

贴吧增强 - Gerald倾情打造

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

  1. // ==UserScript==
  2. // @name Tieba Advanced
  3. // @namespace http://gera2ld.blog.163.com/
  4. // @author Gerald <gera2ld@163.com>
  5. // @icon http://s.gravatar.com/avatar/a0ad718d86d21262ccd6ff271ece08a3?s=80
  6. // @version 2.7.5.3
  7. // @description 贴吧增强 - Gerald倾情打造
  8. // @homepageURL http://geraldl.ml/userjs/TiebaAdvanced
  9. // @include http://tieba.baidu.com/*
  10. // @exclude http://tieba.baidu.com/tb/*
  11. // @require https://greasyfork.org/scripts/144/code.user.js
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. var mask=$('<div class=ge_mask style="padding:100px 100px 20px;">').appendTo('body'); // Mask layer
  16. // Arrays for Lzl initiation
  17. var lzl_init=[],lzl_buttons=[],lzl_styles=[],lzl_efilters=[];
  18. addPButton=function(o,c,m,a) { // 新增楼中楼按钮
  19. lzl_styles=lzl_styles.concat(c);o.addClass(c[0]);
  20. if(!a) a={};if(!a.after) a.after='.lzl_panel_submit';
  21. lzl_buttons.push([o,m,a]);
  22. return o;
  23. };
  24. DELAY=2000;
  25.  
  26. // 初始化贴子管理面板
  27. function initPostManager() {
  28. if(utils.postManager) return;
  29. utils.addStyle('\
  30. #ge_tm{display:none;border-collapse:separate;width:100%;height:100%;background:white;color:#333;padding:20px;border-radius:20px;shadow:0 1px 5px #333;border-spacing:5px;table-layout:fixed;}\
  31. #ge_tm tr{height:1px;}\
  32. #ge_tm tr.ge_td{height:auto;}\
  33. .ge_td>td{width:50%;height:100%;vertical-align:top;position:relative;}\
  34. .ge_td>td>*{width:100%;height:100%;border:1px solid;overflow:auto;background:transparent;'+(window.opera?'position:absolute;':'')+'}\
  35. ');
  36. var tm=$('<table id=ge_tm>').appendTo(mask);
  37. tm.listItems=function(t,e,x,s){
  38. var d=[];
  39. if(x) d.push('<option>'+x+'</option>');
  40. t.list.forEach(function(i){d.push('<option>'+i.name+'</option>');});
  41. e.html(d.join(''));
  42. if(s) {x=x?1:0;t.load(s-x);e.prop('selectedIndex',t.last+x);}
  43. };
  44. tm.newItem=function(e,d) {
  45. tm.list.load(tm.list.length-1);
  46. if(!tm.list.cur||tm.list.cur.data) {
  47. tm.list.load(tm.list.push(d));
  48. $('<option>').appendTo(ti).text(tm.list.cur.name);
  49. } else {
  50. tm.list.cur.type=d.type;
  51. tm.list.cur.data=d.data;
  52. }
  53. $(ti).prop('selectedIndex',tm.list.last);
  54. editItem();
  55. };
  56. var th=document.createElement('p'),tk='innerText' in th?'innerText':'textContent';
  57. function h2t(h){ // html to text
  58. th.innerHTML=h.replace(/<br>/g,'\n');
  59. return th[tk];
  60. }
  61. function t2h(t){ // text to html
  62. th[tk]=t;
  63. return th.innerHTML.replace(/ /g,'&nbsp; ').replace(/(^| ) /g,'&nbsp;$1').replace(/\r?\n/g,'<br>');
  64. }
  65. function editItem(e) {
  66. if(e) tm.list.load(ti.prop('selectedIndex'),1);
  67. var t=tm.list.cur;
  68. tc.prop('disabled',!t);
  69. if(!t) t={type:'s',data:''};
  70. tt.val(t.type);
  71. if(['j','h','H'].indexOf(t.type)>=0) tc.val(t.data);
  72. else tc.val(h2t(t.data));
  73. liveShow();
  74. }
  75. function saveItem(e) {
  76. var t=tm.list.cur;if(!t) return;
  77. switch(t.type=tt.val()) {
  78. case 'j':try{eval(t.data=tc.val());}catch(e){}break;
  79. case 's':t.data=t2h(tc.val());break;
  80. case 'H':t.data=tc.val();break;
  81. default:tv.find('img').each(function(i,e){
  82. e.setAttribute('pic_type',1);
  83. unsafeWindow.EditorUI.resizeImage(e,560);
  84. });
  85. tc.val(t.data=tv.html());
  86. }
  87. }
  88. function liveShow(e) {
  89. function show() {
  90. if(--count) return;
  91. var t=tt.val(),s;
  92. if(t=='j') try{s=eval(tc.val());}catch(e){s='<font color=red>JS代码有误!</font>';}
  93. else s=tc.val();
  94. if(t=='s') s=t2h(s);
  95. else if(t=='H') s=s.split('\n').shift();
  96. tv.html(s);
  97. }
  98. count++;
  99. setTimeout(show,500);
  100. }
  101. var count=0;
  102. tm.loadPanel=function(t,n,c) {
  103. tm.list=t;tn.text(n);tm.callback=c;
  104. tm.listItems(t,ti);editItem(1);
  105. mask.fadeIn('fast',function() {
  106. tm.css({display:'table'}).animate({top:'0px',left:'0px'},300);
  107. });
  108. };
  109. var c=$('<td colspan=2>').appendTo($('<tr>').appendTo(tm)),
  110. tn=$('<strong class=ge_rsep>').appendTo(c),
  111. ti=$('<select>').appendTo(c).change(editItem);
  112. $('<span class="ge_sbtn ge_rsep">改名</span>').appendTo(c).click(function(e) {
  113. if(!tm.list.cur) return;
  114. var t=prompt('修改名称:',tm.list.cur.name);
  115. if(t) {tm.list.cur.name=t;ti.children('option:eq('+tm.list.last+')').text(t);}
  116. });
  117. var tt=$('<select>').appendTo($('<label class=ge_rsep>类型:'+utils.getLink('advanced',{title:'帮助',html:'(?)'})+'</label>').appendTo(c)).html('<option value="s" checked>普通字串</option><option value="h">HTML代码</option><option value="H">HTML随机</option><option value="j">JS代码</option>').change(liveShow).blur(saveItem);
  118. $('<span class=ge_sbtn>添加</span>').appendTo(c).click(tm.newItem);
  119. $('<span class=ge_sbtn>删除</span>').appendTo(c).click(function() {
  120. var l=tm.list.last;tm.list.pop(l);ti.children().eq(l).remove();editItem(1);
  121. });
  122. c=$('<div style="float:right;"></div>').appendTo(c);
  123. $('<span class=ge_sbtn>关闭</span>').appendTo(c).click(function() {
  124. tm.list.save();if(tm.callback) tm.callback();
  125. tm.animate({top:innerHeight+'px'},300,function() {$(this).hide();mask.fadeOut('fast');});
  126. });
  127. $('<tr><td>编辑框</td><td align=right>预览框</td></tr>').appendTo(tm);
  128. c=$('<tr class=ge_td>').appendTo(tm);
  129. var tc=$('<textarea>').appendTo($('<td>').appendTo(c)).blur(saveItem).keyup(liveShow).mouseup(liveShow);
  130. var tv=$('<div>').appendTo($('<td>').appendTo(c));
  131. utils.postManager=tm;
  132. }
  133. // 灌水
  134. function initAddWater(editor) {
  135. initPostManager();
  136. var tails=utils.list('tails',null,function(){return {type:'s',data:'',name:'新尾巴'};},[
  137. {type:'j',name:'UA',data:'"——我喂自己袋盐<br>&gt;&gt;"+navigator.userAgent'},
  138. {type:'h',name:'求妹纸',data:'<img pic_type="1" class="BDE_Image" src="http://imgsrc.baidu.com/forum/w%3D580/sign=6ca77dcee5dde711e7d243fe97edcef4/b03533fa828ba61e111605e44134970a314e5905.jpg" width="560" height="11"><br><img pic_type="1" src="http://static.tieba.baidu.com/tb/editor/images/tsj/t_0010.gif" class="BDE_Smiley" height="40" width="40">求妹纸~'},
  139. ]).load(),water=utils.list('water',null,function(){return {type:'s',data:'',name:'新水贴'};},[
  140. {type:'s',name:'打酱油',data:'我是打酱油的~'},
  141. ]).load();
  142. function initTails(){utils.postManager.listItems(tails,ti,'随机',utils.getObj('tailindex',1));}
  143. function initWater(){utils.postManager.listItems(water,wi,'随机',utils.getObj('waterindex',0));}
  144. function getItem(t,s){
  145. var l=s.prop('selectedIndex'),L=t.length;if(!L) return;
  146. if(!l) l=Math.floor(Math.random()*L); else l--;
  147. t=t.list[l];var d=t.data;
  148. if(t.type=='j') d=eval(d);
  149. else if(t.type=='H') {d=d.split('\n');d=d[Math.floor(Math.random()*d.length)];}
  150. return d;
  151. }
  152. var op=utils.addRPopup(utils.addSButton('灌 水')).panel;
  153. $('<div class=ge_sbtn style="cursor:default">智能灌水</div>').appendTo(op);
  154. var ti=$('<select class=ge_rsep>').appendTo($('<label>尾巴:</label>').appendTo(op)).change(function(e){utils.setObj('tailindex',this.selectedIndex);});
  155. $('<br>').appendTo(op);
  156. var tail=utils.bindProp($('<input type=checkbox>').prependTo($('<label class=ge_rsep>自动附加尾巴</label>').appendTo(op)),'checked','usetail',true);
  157. $('<br>').appendTo(op);
  158. $('<span class=ge_sbtn>存为新尾巴</span>').appendTo(op).click(function(e){
  159. utils.postManager.loadPanel(tails,'尾巴管理',initTails);
  160. utils.postManager.newItem(e,{type:'h',name:'新尾巴',data:editor.$body.html()});
  161. });
  162. $('<span class=ge_sbtn>管理</span>').appendTo(op).click(function(e){utils.postManager.loadPanel(tails,'尾巴管理',initTails);});
  163. $('<hr>').appendTo(op);
  164. var wi=$('<select class=ge_rsep>').appendTo($('<label>水贴:</label>').appendTo(op)).change(function(e){utils.setObj('waterindex',this.selectedIndex);});
  165. $('<br>').appendTo(op);
  166. $('<span class=ge_sbtn>存为新水贴</span>').appendTo(op).click(function(e){
  167. utils.postManager.loadPanel(water,'水贴管理',initWater);
  168. utils.postManager.newItem(e,{type:'h',name:'新水贴',data:editor.$body.html()});
  169. });
  170. $('<span class=ge_sbtn>管理</span>').appendTo(op).click(function(e){utils.postManager.loadPanel(water,'水贴管理',initWater);});
  171. $('<br>').appendTo(op);
  172. $('<span class=ge_sbtn>载入</span>').appendTo(op).click(function(e){
  173. editor.execCommand('inserthtml',getItem(water,wi));
  174. });
  175. $('<span class=ge_sbtn>发表</span>').appendTo(op).click(function(e){
  176. editor.$body.html(getItem(water,wi));
  177. unsafeWindow.test_poster.post();
  178. });
  179. /*$('<span class=ge_sbtn>人工置顶</span>').appendTo(op).click(function(e){
  180. function post(){PostHandler.post(rich_postor._option.url,b,delay,function(){});}
  181. function delay(m){
  182. if(m) {
  183. if(m.no) d+=1000; else {d=DELAY;e.text('停止('+(++c)+')');}
  184. }
  185. if(!m||!m.no) b.content=getItem(water,wi);
  186. setTimeout(post,d);
  187. }
  188. (e=$(this)).unbind('click').text('停止').click(function(){location.reload();});
  189. var c=0,d=0;b=rich_postor._getData();delay();
  190. });*/
  191. var tailed=false;
  192. utils.hook(unsafeWindow.test_poster,'post',{before:function(){
  193. var t=getItem(tails,ti);
  194. if(!tail.prop('checked')||!t||tailed) return;
  195. editor.$body.append('&nbsp;<br><br>'+t);tailed=true; // 加个空格以免破坏@
  196. }});
  197. initTails();initWater();
  198. }
  199.  
  200. // 尾页直达功能
  201. function initLastPage() {
  202. utils.addStyle('.threadlist_rep_num{cursor:pointer;}');
  203. $('.threadlist_rep_num').prop('title','直达尾页').click(function(e){
  204. e=$(e.target);e.unbind('click');
  205. var s='',d=JSON.parse(e.parents('.j_thread_list').attr('data-field'));
  206. setInterval(function(){
  207. if(s.length>2) s=''; else s+='.';
  208. e.html(s);
  209. },300);
  210. d='/p/'+d.id;
  211. $.get(d,function(data){
  212. var m=data.match(/共<span class="red">(\d+)/)[1];
  213. if(m=='1') m=''; else m='?pn='+m;
  214. location.href=d+m;
  215. });
  216. });
  217. }
  218.  
  219. // 召唤术增强
  220. var calllist=utils.list('calllist','calllast',function(){return {name:'新列表',data:[]};},true).load(),
  221. purl='http://imgsrc.baidu.com/forum/pic/item/fcb4c3fdfc039245664e092a8594a4c27c1e2592.jpg';
  222. function initCard() {
  223. function fix(){
  224. var t=this._j_card,c=calllist.cur.data;
  225. setTimeout(function(){
  226. function updateCSS(e) {e.css('background-position',j<0?'0 0':'-62px 0');}
  227. var u=t.getData().un,j=c.indexOf(u),w=t.find('.interaction_wrap'),a;
  228. if(w.length) updateCSS(a=$('<a href=# style="background:url('+purl+') no-repeat scroll 0 0">').appendTo(w).click(function(e){
  229. e.preventDefault();
  230. if(j<0) {j=c.length;c.push(u);}
  231. else {for(;j<c.length-1;j++) c[j]=c[j+1];c.pop();j=-1;}
  232. calllist.save();
  233. updateCSS(a);
  234. }));
  235. },0);
  236. }
  237. unsafeWindow._.Module.use("ihome/widget/UserVisitCard",{},function(b){
  238. utils.hook(b.__proto__,'buildVisitCard',{before:function(){
  239. utils.hook(this._visit_card,'setContent',{after:fix});
  240. }});
  241. });
  242. }
  243. function initCall(editor) {
  244. var pl,sl,be,bs,c=calllist;
  245. utils.addStyle('\
  246. #callList{border:1px solid;height:125px;overflow:auto;background:white;width:380px;margin:0 auto;}\
  247. #callList a{padding:2px;border-radius:2px;margin:2px;display:inline-block;}\
  248. #callList a.selected{background:limegreen;color:white}\
  249. .edui-btn-toolbar .edui-btn .call_list,.lzl_panel_call{background:url("'+purl+'") no-repeat scroll transparent -124px 0;width:21px;}\
  250. .lzl_panel_call{height:20px;width:22px;float:right;}\
  251. ');
  252. function newList(e) {
  253. c.load(c.push());$('<option>').appendTo(sl).text(c.cur.name);
  254. sl.prop('selectedIndex',c.last);
  255. editList(e);
  256. }
  257. function editList(e) {
  258. if(e) c.load(sl.prop('selectedIndex')); else sl.prop('selectedIndex',c.last);
  259. pl.empty();
  260. c.cur.data.forEach(function(i){$('<a href=#>').html(i).appendTo(pl);});
  261. pl.prop('contenteditable',false);
  262. }
  263. function loadLists(p) {
  264. var op=p.panel;
  265. c.load();op.empty();
  266. $('<div class=ge_sbtn style="cursor:default">超级召唤</div>').appendTo(op);
  267. sl=$('<select>').appendTo($('<label>选择名单:</label>').appendTo(op)).change(editList);
  268. $('<span class="ge_sbtn ge_rsep">改名</span>').appendTo(op).click(function(e) {
  269. e.preventDefault();
  270. var t=prompt('列表名称:',c.cur.name);
  271. if(t) {sl.children(':eq('+c.last+')').text(t);c.cur.name=t;c.save();}
  272. });
  273. $('<span class=ge_sbtn>新建列表</span>').appendTo(op).click(newList);
  274. $('<span class="ge_sbtn ge_rsep">删除列表</span>').appendTo(op).click(function(e){
  275. e.preventDefault();
  276. var l=c.last;c.pop(l);editList();sl.children().eq(l).remove();
  277. });
  278. pl=$('<div id=callList>').appendTo(op).click(function(e){
  279. e.preventDefault();
  280. e=e.target;if(e.tagName=='A') $(e).toggleClass('selected');
  281. }).dblclick(function(e){
  282. e.stopPropagation();
  283. var s=window.getSelection();
  284. if(!s.rangeCount) return;
  285. var r=s.getRangeAt(0),c=r.startContainer,k=r.startOffset;
  286. var i=c.data.substr(0,k).search(/\s\S*$/),j=c.data.substr(k).search(/\s/);
  287. r.setStart(c,i+1);r.setEnd(c,j<0?c.data.length:k+j);
  288. s.removeAllRanges();s.addRange(r); // Compatible with Chrome
  289. });
  290. $('<label>名单管理:</label>').appendTo(op);
  291. be=$('<span>').appendTo(op);
  292. $('<span class=ge_sbtn>编辑</span>').appendTo(be).click(function(e){
  293. bs.show();be.hide();
  294. pl.prop('contenteditable',true);
  295. pl.text(c.cur.data.join(' '));
  296. });
  297. $('<span class=ge_sbtn>全选/不选</span>').appendTo(be).click(function(e){
  298. e.preventDefault();
  299. var a=pl.children('a:not(.selected)');
  300. if(a.length) a.addClass('selected'); else pl.children('a').removeClass('selected');
  301. });
  302. bs=$('<span>').appendTo(op).hide();
  303. $('<span class=ge_sbtn>去重</span>').appendTo(bs).click(function(e){
  304. var d=pl.text().replace(/^\s+|\s+$/,'').split(/\s+/),h={};
  305. d.forEach(function(i){h[i]=0;});
  306. pl.text(Object.getOwnPropertyNames(h).join(' '));
  307. });
  308. $('<span class="ge_sbtn ge_rsep">完成</span>').appendTo(bs).click(function(e){
  309. c.cur.data=pl.text().replace(/^\s+|\s+$/,'').split(/\s+/);
  310. c.save();editList(e);be.show();bs.hide();
  311. });
  312. $('<span>空格隔开,双击选中一个名字</span>').appendTo(bs);
  313. var b=$('<div style="float:right">').appendTo(op);be=be.add(b);
  314. $('<span class=ge_sbtn title="普通召唤,超过十个ID将会失败">召唤</span>').appendTo(b).click(function(e){
  315. var se=p==pM?editor:unsafeWindow.LzlEditor._s_p._se;
  316. pl.children('a.selected').each(function(i,e){se.execCommand('inserthtml','@'+e.innerHTML+'&nbsp;');});
  317. p.onclose();
  318. });
  319. /*$('<span class=ge_sbtn title="插入一个占位符,将自动替换成召唤名单">自动召唤</span>').appendTo(b).click(function(e){
  320. e=[];pl.children('a.selected').each(function(){e.push(this.innerHTML);});
  321. p.onclose();
  322. if(e.length) {
  323. p.holder.names=e;
  324. e=p.holder==E?editor:unsafeWindow.LzlEditor._s_p._se;
  325. e.execCommand('inserthtml','<img class=BDE_Smiley title="将在此自动插入召唤名单" alt="召唤列表" height=18>');
  326. }
  327. });*/
  328. c.list.forEach(function(i){$('<option>').text(i.name).appendTo(sl);});
  329. editList();
  330. }
  331. var l=/<img [^>]*?alt="召唤列表"[^>]*>/;
  332. function addNames(e,n){
  333. if(n.splice) n='@'+n.splice(0,10).join(' @')+' ';
  334. return e.replace(l,n);
  335. }
  336. // 主编辑框
  337. var o=utils.addTButton($('<div unselectable="on" class="edui-icon call_list" title="召唤">')),
  338. pM=utils.addRPopup(o,loadLists);
  339. /*utils.hook(unsafeWindow.PostHandler,'post',{before:function(f,a){
  340. function post(){f.hook_func(a[0],a[1],E.names?delay:a[2],a[3]);}
  341. function delay(m){
  342. if(m){if(m.no) d+=1000; else d=DELAY;}
  343. if((!m||!m.no)&&E.names) {
  344. a[1].content=addNames(e,E.names);
  345. if(!E.names.length) delete E.names;
  346. }
  347. setTimeout(post,d);
  348. }
  349. var e=a[1].content,d=0;f.hookStop();
  350. if(E.names&&e.search(l)<0) delete E.names;
  351. delay();
  352. }});*/
  353. // 楼中楼
  354. /*lzl_init.push(function(){
  355. utils.hook(unsafeWindow.SimplePostor.prototype,'_submitData',{before:function(f){
  356. function post(){
  357. $.tb.post(FORUM_POST_URL.postAdd,b,delay);
  358. }
  359. function delay(m){
  360. if(o.names) {
  361. if(m){if(m.no) d+=1000; else d=DELAY;}
  362. if(!m||!m.no) {
  363. b.content=addNames(a,o.names);
  364. if(!o.names.length) delete o.names;
  365. }
  366. setTimeout(post,d);
  367. } else location.reload();
  368. }
  369. if(o.names&&this._se.editArea.innerHTML.search(l)>=0) {
  370. f.hookStop();var d=0,b=this._getData(),a=b.content;delay();
  371. }
  372. }});
  373. });*/
  374. o=$('<span title="召唤">');
  375. addPButton(o,['lzl_panel_call'],utils.addRPopup(o,loadLists).ontoggle,{keys:['click']});
  376. }
  377.  
  378. // 自动获取礼包
  379. // 来源:http://userscripts.org/scripts/show/268885
  380. // 感谢 Star Brilliant <m13253@hotmail.com>
  381. function initFetchGift() {
  382. setInterval(function(){
  383. $('.rand_gift').click();
  384. $('.time_gift.unopen_gift').click();
  385. },10000);
  386. }
  387.  
  388. // 字体颜色初始化
  389. function initFont() {
  390. utils.colors={red:'#e10602'};
  391. utils.switchColor=function(cr,cs) {
  392. document.execCommand('forecolor',false,document.queryCommandValue('forecolor').replace(/\s/g,'')==cr?'#333333':cs);
  393. }
  394. function fix() {
  395. $(this.editArea).find('font[color]').each(function(i,e){
  396. e=$(e);i=e.html();
  397. switch(e.prop('color')){
  398. case utils.colors.red:
  399. e.replaceWith('<span class="edit_font_color">'+i+'</span>');
  400. break;
  401. }
  402. }).end().find('b').each(function(i,e){
  403. e=$(e);i=e.html();e.replaceWith('<strong>'+i+'</strong>');
  404. }).end().find('span.at').each(function(i,e){ // allow at
  405. e.outerHTML=e.innerHTML;
  406. });
  407. }
  408. var p=unsafeWindow.TED.EditorCore.prototype;
  409. p.submitValidHTML=p.submitValidHTML.concat(['span','strong']); // allow font in Lzl
  410. utils.hook(unsafeWindow.rich_postor._editor,'filteSubmitHTML',{before:fix});
  411. lzl_efilters.push(fix);
  412. }
  413.  
  414. // 修复楼中楼定位翻页
  415. function initLzlFix() {
  416. $('li.lzl_li_pager').each(function(i,e){
  417. if((e=$(e)).children('.lzl_more:hidden').length) e.children('.j_pager:hidden').show();
  418. });
  419. }
  420. // 楼中楼初始化
  421. function initLzL() {
  422. // 倒序添加按钮
  423. var t=$('#edit_parent .tb-editor-toolbar');
  424. if(t.children('.font_color').length)
  425. addPButton($('<span title="红字" unselectable="on"></span>'),['font_color'],
  426. function(e){utils.switchColor('rgb(225,6,2)',utils.colors.red);},{before:'.lzl_panel_smile'});
  427. if(t.children('.font_strong').length)
  428. addPButton($('<span title="加粗" unselectable="on"></span>'),['font_strong'],
  429. function(e){document.execCommand('bold',false,'');},{before:'.lzl_panel_smile'});
  430. // 楼中楼初始化
  431. function fixLzl() {
  432. var p=$('div.lzl_panel_btn');p.parent().css('width','50%').prev().css('width','50%');
  433. lzl_buttons.forEach(function(i){utils.addButton(p,i[0],i[1],i[2]);});
  434. }
  435. t='.font_strong,.font_color{background:url("http://tb2.bdstatic.com/tb/editor/v2/font_style.png") no-repeat transparent;height:20px;width:22px;}.font_color{background-position:0 -20px;}';
  436. if(lzl_styles.length) t+='.'+lzl_styles.join(',.')+'{margin:2px 1px;float:right;}';
  437. utils.addStyle(t);
  438. if(unsafeWindow.LzlEditor._s_p) fixLzl();
  439. lzl_init.forEach(function(i){i();});
  440. utils.hook(unsafeWindow.SimplePostor.prototype,'_buildNormalEditor',{after:fixLzl});
  441. utils.hook(unsafeWindow.TED.SimpleEditor.prototype,'filteSubmitHTML',{before:lzl_efilters});
  442. utils.hook(unsafeWindow.SimplePostor.prototype,'_getHtml',{before:function(f){
  443. f.hookStop();return this._se.getHtml();
  444. }});
  445. }
  446.  
  447. function initEditor(editor){
  448. initAddWater(editor); // 灌水+尾巴
  449. initCall(editor); // 召唤增强,召唤列表
  450. //initFont(editor); //初始化:高级字体
  451. }
  452.  
  453. // 以下为模块调用,可将不需要的模块注释,不要改变顺序
  454. if($&&PageData&&PageData.user) { // 出错反馈按钮
  455. initCard(); // 用户卡片上添加召唤按钮
  456. // 以下模块无需登录
  457. if(PageData.thread) { // 以下模块仅在帖子浏览页面加载
  458. //initLzlFix(); // 修复楼中楼定位翻页
  459. } else {
  460. initLastPage(); // 尾页直达功能
  461. }
  462. //以下模块仅在登录时加载
  463. if(PageData.user.is_login) {
  464. if(unsafeWindow.PosterContext&&unsafeWindow.PosterContext.isPostAllowed()) utils.wait(unsafeWindow,'test_editor',initEditor);
  465. initFetchGift();
  466. if(unsafeWindow.LzlEditor&&unsafeWindow.SimplePostor) initLzL(); //初始化楼中楼:支持已加载的功能
  467. }
  468. }