饭否-免刷新显示无限多新消息

免刷新饭否首页, 去掉显示多于19条新消息需要刷新的限制

  1. // ==UserScript==
  2. // @name 饭否-免刷新显示无限多新消息
  3. // @author HackMyBrain
  4. // @version 1.0.1
  5. // @description 免刷新饭否首页, 去掉显示多于19条新消息需要刷新的限制
  6. // @create 2013-07-21
  7. // @include http://fanfou.com/home
  8. // @namespace https://gf.qytechs.cn/users/2844
  9. // ==/UserScript==
  10.  
  11.  
  12. (function (){
  13. var original_title = document.title;
  14. var count = document.getElementById("timeline-count");
  15. var noti = document.getElementById("timeline-notification");
  16. var buffereds = document.getElementsByClassName("buffered");
  17.  
  18. function updateTime(){
  19. var time = new Date().getTime();
  20. var gap_s, gap_m, gap_h;
  21. var datestring;
  22. var stime_list = document.querySelectorAll("[stime]");
  23. for(var i = 0, l = stime_list.length; i < l; i++){
  24. if (stime_list[i].innerHTML != stime_list[i].title){
  25. datestring = stime_list[i].getAttribute("stime");
  26. gap_s = (time - Date.parse(datestring)) / 1000;
  27. if (gap_s < 60){
  28. stime_list[i].innerHTML = gap_s.toFixed() + " 秒前";
  29. } else if (60 <= gap_s && gap_s < 3600){
  30. gap_m = gap_s / 60;
  31. stime_list[i].innerHTML = gap_m.toFixed() + " 分钟前";
  32. } else if (3600 <= gap_s && gap_s < 86400){
  33. gap_h = gap_s / 3600;
  34. stime_list[i].innerHTML = "约 " + gap_h.toFixed() + " 小时前";
  35. } else {
  36. stime_list[i].innerHTML = stime_list[i].title;
  37. }
  38. }
  39. else return;
  40. }
  41. }
  42.  
  43. function showBuffered(e){
  44. updateTime();
  45. while(buffereds.length > 0){
  46. buffereds[0].removeAttribute("class");
  47. }
  48. e.stopPropagation();
  49. e.preventDefault();
  50. noti.style.display = "none";
  51. document.title = original_title;
  52. count.innerHTML = 0;
  53. }
  54.  
  55. noti.addEventListener('click', showBuffered, true);
  56. })()

QingJ © 2025

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