Tieba Preload

贴吧预加载,自动加载下一页内容,同时附带消灭贴吧自带 Lazy Load 功能

当前为 2014-05-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Tieba Preload
  3. // @version 1.3.2
  4. // @description 贴吧预加载,自动加载下一页内容,同时附带消灭贴吧自带 Lazy Load 功能
  5. // @match http://tieba.baidu.com/*
  6. // @include http://tieba.baidu.com/*
  7. // @exclude http://tieba.baidu.com/*tp=1*
  8. // @exclude http://tieba.baidu.com/*tab=*
  9. // @author 864907600cc
  10. // @icon http://1.gravatar.com/avatar/147834caf9ccb0a66b2505c753747867
  11. // @run-at document-end
  12. // @grant GM_registerMenuCommand
  13. // @namespace https://greasyfork.org/users/141
  14. // ==/UserScript==
  15.  
  16. // 贴子判断方式由 kookxiang 提供
  17. // 本脚本基于 GPLv3 协议开源 http://www.gnu.org/licenses/gpl.html‎
  18. // (c) 86497600cc. Some Rights Reserved.
  19.  
  20. // 修复使用 GM 函数后脚本失效的问题,thanks to shyangs
  21. var window=unsafeWindow,
  22. _=unsafeWindow._,
  23. PageData=unsafeWindow.PageData,
  24. Page=unsafeWindow.Page,
  25. $=unsafeWindow.$,
  26. no_refresh_url_prefix=(typeof unsafeWindow.no_refresh_url_prefix!='undefined')?unsafeWindow.no_refresh_url_prefix:null;
  27.  
  28. var notification=document.createElement('div'),
  29. setting=(window.localStorage.getItem('tb_preload_setting')&&window.localStorage.getItem('tb_preload_setting').indexOf('{')>=0)?JSON.parse(window.localStorage.getItem('tb_preload_setting')):{},
  30. stylesheet='@keyframes setting_panel_show{0%{top:100px;opacity:0}80%{top:-20px;opacity:1}100%{top:0px;opacity:1}}@-webkit-keyframes setting_panel_show{0%{top:100px;opacity:0}80%{top:-20px;opacity:1}100%{top:0px;opacity:1}}@keyframes setting_panel_hide{0%{top:0px;opacity:1}20%{top:-20px;opacity:1}100%{top:100px;opacity:0}}@-webkit-keyframes setting_panel_hide{0%{top:0px;opacity:1}20%{top:-20px;opacity:1}100%{top:100px;opacity:0}}.tb_preload_notification{position:fixed;right:10px;padding:5px;bottom:-50px;box-shadow:0 0 1px 5px rgba(0,0,0,0.5);background:rgba(0,0,0,0.5);font-size:12px;color:#fff;opacity:0;-webkit-transition:0.25s all linear;-o-transition:0.25s all linear;transition:0.25s all linear;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;cursor:pointer;z-index:999999;pointer-events:none}.tb_preload_notification[show]{bottom:10px;opacity:1}.tb_preload_page{width:100%;font-size:14px;text-align:center}.tb_preload_page a{text-decoration:none;color:#333;margin:20px 0;display:block;font-size:14px}.tb_preload_setting{color:#2d64b3;cursor:pointer}.list_loading,.right_section [data-type="tb-datalazyload"]{display:none}.vpic_wrap img{max-height:90px}.tb_preload_setting_panel{width:600px;height:200px;margin:auto;position:fixed;top:0;bottom:0;left:0;right:0;z-index:999998;box-shadow:rgba(0,0,0,.5) 0 0 0 2500px,rgba(255,255,255,.75) 0 0 200px;background:rgba(255,255,255,.75);font-size:14px;-webkit-user-select:none;-moz-user-select:none;-webkit-animation:setting_panel_show 0.75s ease-in;animation:setting_panel_show 0.75s ease-in;font-family:"Hiragino Sans GB","Microsoft Yahei","WenQuanYi Micro Hei",Arial,Tahoma,sans-serif}.tb_preload_setting_panel[close]{-webkit-animation:setting_panel_hide 0.75s ease-out;animation:setting_panel_hide 0.75s ease-out}.tb_preload_setting_panel_bg{width:100%;height:100%;position:fixed;left:0;top:0;z-index:999997}.tb_preload_setting_panel span,.tb_preload_setting_panel a{display:block;cursor:pointer;height:20px;line-height:20px;margin:10px;-webkit-transition:all 0.25s linear;-moz-transition:all 0.25s linear;transition:all 0.25s linear}.tb_preload_setting_panel span{color:#F00;padding-left:50px}.tb_preload_setting_panel span:hover{text-shadow:#F00 0 0 1px}.tb_preload_setting_panel span[active]:hover,.tb_preload_setting_panel a:hover{text-shadow:#7fb900 0 0 1px}.tb_preload_setting_panel span::before{content:"×";display:inline-block;width:20px}.tb_preload_setting_panel span[active]{color:#7FB900}.tb_preload_setting_panel span[active]::before{content:"√"}.tb_preload_setting_panel p{margin:20px;font-size:20px;height:24px;line-height:24px;cursor:default;font-family:"Segoe Script";text-shadow: #000 0 0 2px}.tb_preload_setting_panel a{color:#7FB900;font-family:"Segoe Script";text-align:center}.tbui_follow_fixed{display:block!important}img[origin-src]{display:none!important}',
  31. setting_panel=false,
  32. ss=document.createElement('style'),
  33. notification_timer=null;
  34. ss.textContent=stylesheet;
  35. document.head.appendChild(ss);
  36. notification.className='tb_preload_notification';
  37. document.body.appendChild(notification);
  38. if(setting.thread_preload==null)setting.thread_preload=1;
  39. if(setting.thread_list_lazyload==null)setting.thread_list_lazyload=1;
  40. if(setting.thread_list_preload==null){
  41. setting.thread_list_preload=1;
  42. setting.thread_list_lazyload=1;
  43. var f=document.createElement('script');
  44. f.textContent='$.dialog.alert("<center style=\'font-size:16px\'>请在此呼出设置界面进行设置</center><br><center><img src=\'http://imgsrc.baidu.com/forum/pic/item/8484ecdde71190ef3fa59157cc1b9d16fcfa6008.jpg\' alt></center>",{title:"Tieba Preload Setting Notification",width:1000})';
  45. document.body.appendChild(f);
  46. document.body.removeChild(f);
  47. window.localStorage.setItem('tb_preload_setting',JSON.stringify(setting));
  48. }
  49.  
  50. function set_function(v){
  51. switch(v){
  52. case 1:
  53. if(setting.thread_preload==1){
  54. setting.thread_preload=0;
  55. if(setting_node){
  56. setting_node.textContent='开启自动加载';
  57. setting_node_2.textContent='开启自动加载';
  58. }
  59. if(PageData.product=='pb'&&typeof loader!='undefined'&&loader!=null){
  60. clearInterval(loader);
  61. loader=null;
  62. }
  63. show_notification(1,'已关闭自动加载......');
  64. notification.setAttribute('show','true');
  65. notification_timer=setTimeout(function(){notification.removeAttribute('show')},5000);
  66. }
  67. else{
  68. setting.thread_preload=1;
  69. if(setting_node){
  70. setting_node.textContent='关闭自动加载';
  71. setting_node_2.textContent='关闭自动加载';
  72. }
  73. if(PageData.product=='pb'&&typeof loader!='undefined'&&loader==null)preload_listener();
  74. show_notification(1,'已开启自动加载......');
  75. }
  76. break;
  77. case 2:
  78. if(setting.thread_list_preload==1){
  79. alert('当开启首页贴子列表预加载时,该项不能关闭。');
  80. }
  81. else if(setting.thread_list_lazyload==1){
  82. setting.thread_list_lazyload=0;
  83. if(PageData.product=='frs'&&typeof loader!='undefined'&&loader!=null){
  84. clearInterval(loader);
  85. loader=null;
  86. if(document.getElementById('frs_list_pager'))document.getElementById('frs_list_pager').onclick=null;
  87. }
  88. show_notification(1,'已禁用自动去除首页 lazyload......');
  89. }
  90. else{
  91. setting.thread_list_lazyload=1;
  92. //setting_node.textContent='禁用自动去除首页 lazyload';
  93. if(PageData.product=='frs'&&typeof loader!='undefined'&&loader==null){
  94. kill_tieba_lazyload_listener();
  95. }
  96. show_notification(1,'已开启自动去除首页 lazyload......');
  97. }
  98. break;
  99. case 3:
  100. if(setting.thread_list_preload==1){
  101. setting.thread_list_preload=0;
  102. if(PageData.product=='frs'&&typeof loader!='undefined'&&loader!=null){
  103. clearInterval(loader);
  104. loader=null;
  105. if(document.getElementById('frs_list_pager'))document.getElementById('frs_list_pager').onclick=null;
  106. }
  107. show_notification(1,'已关闭自动加载......');
  108. }
  109. else{
  110. setting.thread_list_preload=1;
  111. setting.thread_list_lazyload=1;
  112. if(PageData.product=='frs'&&typeof loader!='undefined'&&loader==null){
  113. preload_listener();
  114. }
  115. show_notification(1,'已开启自动加载......');
  116. }
  117. break;
  118. }
  119. window.localStorage.setItem('tb_preload_setting',JSON.stringify(setting));
  120. update_setting_panel();
  121. }
  122.  
  123. function call_setting(){
  124. if(setting_panel==false){
  125. setting_panel=true;
  126. var panel=document.createElement('div'),
  127. panel_bg=document.createElement('div');
  128. panel_bg.className='tb_preload_setting_panel_bg';
  129. panel.className='tb_preload_setting_panel';
  130. panel_bg.onclick=function(){
  131. panel.setAttribute('close',true);
  132. setTimeout(function(){panel.parentElement.removeChild(panel);},700);
  133. panel_bg.parentElement.removeChild(panel_bg);
  134. setting_panel=false;
  135. }
  136. panel_bg.setAttribute('title','点击以关闭设置界面');
  137. panel.innerHTML='<p align="center">Tieba Preload Setting</p><span class="tbpreload_setting_panel_thread_preload">自动加载贴子下一页</span><span class="tbpreload_setting_panel_thread_list_lazyload">去除贴吧首页 lazyload</span><span class="tbpreload_setting_panel_thread_list_preload">自动加载贴子列表下一页</span><a href="http://tieba.baidu.com/p/2939166340">Feedback</a>';
  138. document.body.appendChild(panel);
  139. document.body.appendChild(panel_bg);
  140. var panel_thread_preload=document.getElementsByClassName('tbpreload_setting_panel_thread_preload')[0],
  141. panel_thread_list_lazyload=document.getElementsByClassName('tbpreload_setting_panel_thread_list_lazyload')[0],
  142. panel_thread_list_preload=document.getElementsByClassName('tbpreload_setting_panel_thread_list_preload')[0];
  143. panel_thread_preload.onclick=function(){
  144. set_function(1);
  145. }
  146. panel_thread_list_lazyload.onclick=function(){
  147. set_function(2);
  148. }
  149. panel_thread_list_preload.onclick=function(){
  150. set_function(3);
  151. }
  152. update_setting_panel();
  153. }
  154. }
  155.  
  156. function update_setting_panel(){
  157. var panel_thread_preload=document.getElementsByClassName('tbpreload_setting_panel_thread_preload')[0],
  158. panel_thread_list_lazyload=document.getElementsByClassName('tbpreload_setting_panel_thread_list_lazyload')[0],
  159. panel_thread_list_preload=document.getElementsByClassName('tbpreload_setting_panel_thread_list_preload')[0];
  160. if(setting.thread_preload==1)panel_thread_preload.setAttribute('active','true');
  161. else if(panel_thread_preload.hasAttribute('active'))panel_thread_preload.removeAttribute('active');
  162. if(setting.thread_list_lazyload==1)panel_thread_list_lazyload.setAttribute('active','true');
  163. else if(panel_thread_list_lazyload.hasAttribute('active'))panel_thread_list_lazyload.removeAttribute('active');
  164. if(setting.thread_list_preload==1)panel_thread_list_preload.setAttribute('active','true');
  165. else if(panel_thread_list_preload.hasAttribute('active'))panel_thread_list_preload.removeAttribute('active');
  166. }
  167.  
  168. function show_notification(n,c){
  169. notification.textContent=c;
  170. notification.setAttribute('show','true');
  171. if(notification_timer!=null){
  172. clearTimeout(notification_timer);
  173. notification_timer=null;
  174. }
  175. if(n==1){
  176. notification_timer=setTimeout(function(){
  177. notification.removeAttribute('show');
  178. notification_timer=null;
  179. },5000);
  180. }
  181. }
  182.  
  183. GM_registerMenuCommand('Tieba Preload Setting',call_setting);
  184.  
  185. if(typeof PageData!='undefined'&&PageData&&(PageData.product=='pb'||PageData.product=='frs')){ // 判断是否载入
  186. var loading=false,
  187. loader=null;
  188.  
  189. // 以下语句中代码来自 Kill Tieba Lazy Load (by 864907600cc, Licence: WTFPL)
  190.  
  191. function kill_tieba_lazyload(){
  192. var codearea=document.getElementById('pblistCodeArea')||document.getElementById('frslistCodeArea')||null;
  193. if(codearea!=null){
  194. //document.getElementById('list_loading').outerHTML=document.getElementById('pblistCodeArea').value;
  195. //document.getElementById('pblistCodeArea').parentElement.removeChild(document.getElementById('pblistCodeArea'));
  196. var lazyload_t_nodes=codearea.childNodes;
  197. for(var i=0;i<lazyload_t_nodes.length;i++){
  198. if(lazyload_t_nodes[i].nodeType==8){
  199. codearea.outerHTML=lazyload_t_nodes[i].data;
  200. //lazyload_nodes[i].parentElement.removeChild(lazyload_nodes[i])
  201. break;
  202. }
  203. }
  204. }
  205. if(document.querySelectorAll('img[data-tb-lazyload]')){
  206. var lazyload_i_nodes=document.querySelectorAll('img[data-tb-lazyload]');
  207. for(var i=0;i<lazyload_i_nodes.length;i++){
  208. lazyload_i_nodes[i].setAttribute('src',lazyload_i_nodes[i].getAttribute('data-tb-lazyload'));
  209. lazyload_i_nodes[i].removeAttribute('data-tb-lazyload');
  210. }
  211. }
  212. if(document.querySelectorAll('img[onloadfun="listimg"][original]')){
  213. var lazyload_i_nodes=document.querySelectorAll('img[onloadfun="listimg"][original]');
  214. for(var i=0;i<lazyload_i_nodes.length;i++){
  215. lazyload_i_nodes[i].setAttribute('src',lazyload_i_nodes[i].getAttribute('original'));
  216. }
  217. }
  218. if(PageData.product=='pb'){
  219. //_.Module.use("pb/widget/ForumListV3", {});
  220. _.Module.use('pb/component/NoAutoVideo',[{text_videofrom:'视频来自: '}]);
  221. //rebind_image();
  222. //Page.bindOpenImg();
  223. }
  224. if(PageData.product=='frs'&&document.cookie.match(/batch_delete_mode=(\w{4,5})/)&&document.cookie.match(/batch_delete_mode=(\w{4,5})/)[1]=='true'){
  225. var tls=document.getElementsByClassName('j_thread_list');
  226. for(var i=0;i<tls.length;i++){
  227. if(!tls[i].getElementsByClassName('batch_delete')[0]){
  228. var s='<div class="batch_delete j_batch_delete"><div class="batch_delete_text">勾选</div><input type="checkbox" class="batch_delete_select j_batch_delete_select"></div>';
  229. var t=document.createElement('div');
  230. tls[i].appendChild(t);
  231. t.outerHTML=s;
  232. }
  233. }
  234. }
  235. }
  236.  
  237. function show_lzl(c){
  238. var t=document.createElement('iframe');
  239. t.style.cssText='width:0;height:0;position:absolute'
  240. t.setAttribute('onload',c);
  241. document.body.appendChild(t);
  242. //document.body.removeChild(t); // 取消自动移除 iframe,因为该操作可能导致在 Firefox 下无法运行
  243. }
  244.  
  245. // 以下语句中代码基于 Tieba Preload 修改 (by 864907600cc, Licence: GPLv3 | http://ccloli.com/201212/tieba-preload-source/)
  246.  
  247. function whether_fetching(){
  248. //console.log('whether_fetching');
  249. var getscroll=document.documentElement.scrollTop||document.body.scrollTop,
  250. scroll_psi=document.body.scrollHeight-getscroll,
  251. psi=PageData.product=='pb'?5000:PageData.forum.version==2?2500:1500;
  252. if(scroll_psi<=psi&&loading==false){
  253. if(cur_page<total_page){
  254. loading=true;
  255. fetch_next_page();
  256. }
  257. //else window.onscroll=null;
  258. else clearInterval(loader);
  259. }
  260. }
  261.  
  262. function fetch_next_page(){
  263. //console.log('fetch_next_page');
  264. switch(PageData.product){
  265. case 'pb':
  266. var url=page_url+'?see_lz='+see_lz+'&pn='+next_page;
  267. xhr.onreadystatechange=function(){
  268. if(xhr.readyState==4&&xhr.status==200){
  269. var str=xhr.responseText;
  270. if(PageData.page=='v1')var data=str.split('"p_postlist"')[1].split('<div class="p_thread')[0].match(/>([\s\S]+)/)[1]; // 旧版贴吧
  271. else var data=str.split('"p_postlist"')[1].split('"right_section')[0].match(/>([\s\S]+)<\/div>[\s\S]*<\/div>[\s\S]*<div/)[1]; // 先 split 再 match 减少资源消耗(>20s → <1s)
  272. var node=document.getElementsByClassName('p_postlist')[0],
  273. t_node=document.createElement('div'),
  274. p_node=document.createElement('div');
  275. p_node.className='tb_preload_page';
  276. p_node.innerHTML='<a href="'+url+'">第 '+next_page+' 页,共 '+total_page+' 页</a>';
  277. node.appendChild(p_node);
  278. node.appendChild(t_node);
  279. t_node.outerHTML=data;
  280. if(str.match(/<script>.*(_\.Module\.use\("pb\/widget\/ForumListV3"[\s\S]+?)<\/script>/)){
  281. var lzl=str.match(/<script>.*(_\.Module\.use\("pb\/widget\/ForumListV3"[\s\S]+?)<\/script>/)[1];
  282. console.log(lzl);
  283. show_lzl(lzl);
  284. }
  285. kill_tieba_lazyload();
  286. ++cur_page;
  287. ++next_page;
  288. loading=false;
  289. if(cur_page==total_page)clearInterval(loader);
  290. notification.removeAttribute('show');
  291. }
  292. }
  293. xhr.open('GET',url);
  294. xhr.send();
  295. notification.setAttribute('show','true');
  296. show_notification(0,'正在加载第 '+next_page+' 页......');
  297. break;
  298. case 'frs':
  299. var url=page_url+'&pn='+next_page;
  300. if(PageData.forum.version==2){
  301. var xurl=page_url+'&apage=1&pn='+next_page;
  302. }
  303. else{
  304. if(location.hash.indexOf('#!')>=0){
  305. var hash_data=location.hash.match(/#\!\/(.)/)[1];
  306. if(hash_data!=last_hash_data){
  307. switch(hash_data){
  308. case 'm':
  309. page_url=page_url.replace(/f.+kw=/,'f?kw=');
  310. last_hash_data='m';
  311. cur_page=0;
  312. next_page=cur_page+50;
  313. total_page=document.querySelector('a.last').href.match(/pn=(\d+)/)[1];
  314. break;
  315. case 'n':
  316. page_url=page_url.replace(/f.+kw=/,'f/good?kw=');
  317. last_hash_data='n';
  318. cur_page=0;
  319. next_page=cur_page+50;
  320. total_page=document.querySelector('a.last').href.match(/pn=(\d+)/)[1];
  321. break;
  322. case 'v':
  323. page_url=page_url.replace(/f.+kw=/,'f/vote?kw=');
  324. last_hash_data='v';
  325. cur_page=0;
  326. next_page=cur_page+50;
  327. total_page=document.querySelector('a.last').href.match(/pn=(\d+)/)[1];
  328. break;
  329. }
  330. }
  331. }
  332. var xurl=page_url+'&ajax=1&pn='+next_page
  333. }
  334. xhr.onreadystatechange=function(){
  335. if(xhr.readyState==4&&xhr.status==200){
  336. var str=xhr.responseText;
  337. if(PageData.forum.version==2){
  338. var data=str.match(/<ul id="thread_list"[\s\S]*?>([\s\S]+)<\/ul>/)[1],
  339. node=document.getElementById('thread_list');
  340. p_node=document.createElement('div'),
  341. context='<a href="'+url+'">第 '+(parseInt(next_page/50)+1)+' 页,共 '+(parseInt(total_page/50)+1)+' 页</a>';
  342. }
  343. else{
  344. var data=JSON.parse(str).data.content.split('<tbody>')[1].split('</tbody>')[0],//str.split('<tbody>')[1].split('</tbody>')[0],
  345. node=document.querySelector('#thread_list tbody'),
  346. p_node=document.createElement('tr'),
  347. context='<td colspan="5"><a href="'+url+'">第 '+(parseInt(next_page/50)+1)+' 页,共 '+(parseInt(total_page/50)+1)+' 页</a></td>';
  348. }
  349. var //node=document.getElementById('thread_list'),
  350. t_node=document.createElement('div')/*,
  351. p_node=document.createElement('div')*/;
  352. p_node.className='tb_preload_page';
  353. p_node.innerHTML=context;
  354. node.appendChild(p_node);
  355. node.appendChild(t_node);
  356. t_node.outerHTML=data;
  357. kill_tieba_lazyload();
  358. cur_page+=50;
  359. next_page+=50;
  360. loading=false;
  361. if(cur_page==total_page)clearInterval(loader);
  362. notification.removeAttribute('show');
  363. }
  364. }
  365. xhr.open('GET',xurl);
  366. xhr.send();
  367. notification.setAttribute('show','true');
  368. show_notification(0,'正在加载第 '+(parseInt(next_page/50)+1)+' 页......');
  369. break;
  370. }
  371. }
  372.  
  373. function preload_listener(){
  374. if(cur_page!=total_page){
  375. //console.log('aaa');
  376. //window.onscroll=function(){ // 改用定时器以节省资源
  377. loader=setInterval(function(){whether_fetching()},1000);
  378. //}
  379. }
  380. }
  381.  
  382. function kill_tieba_lazyload_listener(){
  383. kill_tieba_lazyload();
  384. if(document.getElementById('frs_list_pager'))document.getElementById('frs_list_pager').onclick=function(){
  385. if(loader==null)loader=setInterval(function(){
  386. if(document.getElementById('frslistCodeArea')){
  387. //kill_tieba_lazyload();
  388. clearInterval(loader);
  389. loader=null;
  390. kill_tieba_lazyload_listener();
  391. }
  392. },1000);
  393. }
  394. }
  395.  
  396. function rebind_image(){
  397. var imglist=document.querySelectorAll('.d_post_content img[pic_type="0"]');//.BDE_Image
  398. $(imglist).unbind();
  399. Page._bindOpenImg();
  400.  
  401. }
  402.  
  403. //notification.onclick=function(){set_function(1)};
  404.  
  405. if(PageData.product=='frs'){
  406. /*if(document.getElementsByClassName('th_footer_l')[0]){
  407. var setting_node=document.createElement('a'),
  408. page_node=document.getElementsByClassName('th_footer_l')[0];
  409. setting_node.textContent=setting.thread_list_lazyload==1?'禁用自动去除首页 lazyload':'开启自动去除首页 lazyload'; // 好长 _(:з」∠)_
  410. setting_node.className='tb_preload_setting';
  411. setting_node.onclick=function(){set_function(2)};
  412. page_node.appendChild(setting_node);
  413. }*/
  414. notification.style.pointerEvents='none';
  415. var xhr=new XMLHttpRequest(),
  416. page_url=no_refresh_url_prefix?('//tieba.baidu.com'+no_refresh_url_prefix):location.href.replace(/&?pn=\d+/,''),
  417. cur_page=location.href.match(/pn=(\d+)/)?parseInt(location.href.match(/pn=(\d+)/)[1]):0,
  418. next_page=cur_page+50,
  419. total_page=PageData.forum.thread_num-PageData.forum.thread_num%50||document.querySelector('a.last').href.match(/pn=(\d+)/)[1],
  420. last_hash_data='';
  421. if(setting.thread_list_preload==1){
  422. kill_tieba_lazyload();
  423. preload_listener();
  424. }
  425. else if(setting.thread_list_lazyload==1)kill_tieba_lazyload_listener();
  426. }
  427. else if(PageData.product=='pb'&&PageData.pager){
  428. //Page._bindOpenImg=Page.bindOpenImg;
  429. //Page.bindOpenImg=rebind_image;
  430. kill_tieba_lazyload();
  431. // 以下语句中部分判断代码来自 Chrome 扩展程序 KK 贴吧工具箱 (by kookxiang | https://chrome.google.com/webstore/detail/bcmemjlkdbeephmnklgimfnjlmfhfdgi)
  432. /*cur_page=0,
  433. total_page=0,
  434. page_url='',
  435. see_lz=0,*/
  436. var xhr=new XMLHttpRequest(),
  437. cur_page=PageData.pager.cur_page,
  438. total_page=PageData.pager.total_page,
  439. page_url=PageData.thread_url?'//tieba.baidu.com'+PageData.thread_url:location.href.match(/\/\/tieba\.baidu\.com\/p\/\d+/)[0],
  440. see_lz=PageData.special.lz_only,
  441. next_page=cur_page+1;
  442.  
  443. var setting_node=document.createElement('li'),
  444. page_node=document.getElementsByClassName('l_posts_num');
  445. setting_node.textContent=setting.thread_preload==1?'关闭自动加载':'开启自动加载';
  446. setting_node.className='tb_preload_setting';
  447. var setting_node_2=setting_node.cloneNode(true);
  448. setting_node.onclick=function(){set_function(1)};
  449. setting_node_2.onclick=function(){set_function(1)};
  450. if(page_node[0])page_node[0].insertBefore(setting_node,page_node[0].getElementsByClassName('l_pager')[0].nextSibling);
  451. if(page_node[1])page_node[1].insertBefore(setting_node_2,page_node[1].getElementsByClassName('l_pager')[0].nextSibling);
  452. if(setting.thread_preload==1)preload_listener();
  453. for(var i in document.scripts){
  454. if(document.scripts[i].textContent.indexOf('ForumListV3')>=0){
  455. var lzl=document.scripts[i].textContent;
  456. show_lzl(lzl);
  457. break;
  458. }
  459. }
  460. }
  461. }