CB时光鸡

一只带你看过去的鸡

  1. // ==UserScript==
  2. // @name CB时光鸡
  3. // @namespace http://www.fishlee.net/
  4. // @version 1.2
  5. // @description 一只带你看过去的鸡
  6. // @author 木鱼(iFish)
  7. // @match http://www.cnbeta.com/articles/*
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. var injectFunction = function (fun) {
  16. if (typeof (fun) === 'string')
  17. fun = fun + '';
  18. var script = document.createElement("script");
  19. script.textContent = '(' + fun + ')();';
  20. document.head.appendChild(script);
  21. document.head.removeChild(script);
  22. };
  23. var injectStyle = function (style) {
  24. var ele = document.createElement("style");
  25. ele.textContent = style;
  26. document.head.appendChild(ele);
  27. };
  28. injectStyle("#cbtc{display:none;padding:10px;background:#fafbde;border:1px solid #cdd073;border-bottom:none;color:#707143}#cbtc a{color:#707143;font-weight:bold;text-decoration:none}#cbtc a:hover{text-decoration:underline}#cbtc a.extra{float:right}");
  29.  
  30. //main
  31. injectFunction(function () {
  32. var injectFunction = function (fun) {
  33. if (typeof (fun) === 'string')
  34. fun = fun + '';
  35. var script = document.createElement("script");
  36. script.textContent = '(' + fun + ')();';
  37. document.head.appendChild(script);
  38. document.head.removeChild(script);
  39. };
  40. var entry = function () {
  41. setTimeout(checkLoop, 1000);
  42. };
  43. var checkLoop = function () {
  44. var ems = $("div.post_count em");
  45. if (!ems.length) {
  46. setTimeout(checkLoop, 1000);
  47. } else {
  48. var total = parseInt($.trim(ems[0].innerText));
  49. var showing = parseInt($.trim(ems[1].innerText));
  50. if (document.querySelector("div.cb-comment-close") || (total && !showing)) {
  51. doCommentShadow();
  52. }
  53. }
  54. }.bind(this);
  55. var patchMethod = function () {
  56. var code = $.cmtOnload + '';
  57. code = code.replace(/,\s*bindAction\s*=[\w\W]*initData\(/i, ";GV.COMMENTS.CLICKED=0;initData(");
  58. code = code.replace(/bindAction\(\);?/i, "$('#cbtc').fadeIn();");
  59. code = code.replace(/type\s*:\s*['"]POST['"],/i, "type:'GET',");
  60. code = code.replace(/url\s*:\s*GV\.DETAIL\.POST_VIEW_URL/i,
  61. "url: 'http://cb.apps.fishlee.net/comment/archive/'+GV.DETAIL.SID+'-'+GV.COMMENTS.MORENUM+'-'+page+'.json'");
  62. code = code.replace(/cache\s*:\s*!\s*0/i, "cache: 1");
  63. code = code.replace(/data\s*:\s*{\s*['"]op['"]\s*:\s*page\+.*?}\s*,/i, "data:{csrf_token:null},");
  64. return code;
  65. };
  66. var doCommentShadow = function () {
  67. if (typeof GV === 'undefined')
  68. window.GV = {};
  69. if (!GV || !GV.DETAIL || GV.DETAIL.SID < 493587)
  70. return;
  71.  
  72. GV.COMMENTS.POSTED = 0;
  73.  
  74. var scripts = [];
  75. //restore comments
  76. if (!GV.EMOTION) {
  77. var data = JSON.parse(localStorage.getItem("cbemotion") || "{}");
  78. if (!data || !data.time || (new Date().getTime() - data.time) / 1000 > 60 * 60 * 24) {
  79. data = {
  80. time: new Date().getTime(),
  81. data: GV && GV.EMOTION ||
  82. {
  83. PAGE_SIZE: 30,
  84. SHOW_SIZE: 2,
  85. EMO_DATA: [
  86. {
  87. "category": "\u5927\u7ae0\u9c7c",
  88. "emotion": [
  89. { "sign": "[s:\u7231\u5fc3]", "url": "\/assets\/images\/emotion\/octopus\/01.gif", "name": "\u7231\u5fc3" },
  90. { "sign": "[s:\u6c57]", "url": "\/assets\/images\/emotion\/octopus\/02.gif", "name": "\u6c57" },
  91. { "sign": "[s:\u9ed1]", "url": "\/assets\/images\/emotion\/octopus\/03.gif", "name": "\u9ed1" },
  92. { "sign": "[s:\u52a0\u73ed]", "url": "\/assets\/images\/emotion\/octopus\/04.gif", "name": "\u52a0\u73ed" },
  93. { "sign": "[s:\u8d31\u7b11]", "url": "\/assets\/images\/emotion\/octopus\/05.gif", "name": "\u8d31\u7b11" },
  94. { "sign": "[s:\u60ca\u8bb6]", "url": "\/assets\/images\/emotion\/octopus\/06.gif", "name": "\u60ca\u8bb6" },
  95. { "sign": "[s:\u62a0\u9f3b]", "url": "\/assets\/images\/emotion\/octopus\/07.gif", "name": "\u62a0\u9f3b" },
  96. { "sign": "[s:\u54ed]", "url": "\/assets\/images\/emotion\/octopus\/08.gif", "name": "\u54ed" },
  97. { "sign": "[s:\u55b7]", "url": "\/assets\/images\/emotion\/octopus\/09.gif", "name": "\u55b7" },
  98. { "sign": "[s:\u6c99\u53d1]", "url": "\/assets\/images\/emotion\/octopus\/10.gif", "name": "\u6c99\u53d1" },
  99. { "sign": "[s:\u751f\u6c14]", "url": "\/assets\/images\/emotion\/octopus\/11.gif", "name": "\u751f\u6c14" },
  100. {
  101. "sign": "[s:\u53cc\u8d1f\u4e94]",
  102. "url": "\/assets\/images\/emotion\/octopus\/12.gif",
  103. "name": "\u53cc\u8d1f\u4e94"
  104. }, { "sign": "[s:\u7b11]", "url": "\/assets\/images\/emotion\/octopus\/13.gif", "name": "\u7b11" },
  105. { "sign": "[s:\u6655]", "url": "\/assets\/images\/emotion\/octopus\/14.gif", "name": "\u6655" }
  106. ]
  107. }
  108. ]
  109. }
  110. };
  111. localStorage.setItem("cbemotion", JSON.stringify(data));
  112. }
  113. scripts.push("GV.EMOTION=" + JSON.stringify(data.data) + ";");
  114. }
  115. scripts.push("(" + patchMethod() + ")('.commt_list');");
  116.  
  117. $(".commt_list").show();
  118. $("#J_commt_list").prepend("<div id='cbtc'>评论已被CB关闭显示。本页评论由 <a href='http://www.fishlee.net/soft/cbtc/' target='_blank' style=''>CB时光鸡</a> 为您提供快照!偶不是一只普通的鸡!<a href='http://www.fishlee.net/soft/cbtc/' target='_blank' class='extra'>了解更多...</a></div>");
  119. injectFunction("function(){" + scripts.join("") + ";}");
  120. };
  121. entry();
  122. });
  123. })();

QingJ © 2025

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