Make Zhihu Great Again

在知乎的话题页面加载你关注的主题的最新动态,请使用Tampermonkey安装本插件。

  1. // ==UserScript==
  2. // @name Make Zhihu Great Again
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2.1
  5. // @author 5night
  6. // @require http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js
  7. // @require http://cdn.bootcss.com/jquery-noty/2.2.2/packaged/jquery.noty.packaged.js
  8. // @match https://www.zhihu.com/topic
  9. // @description 在知乎的话题页面加载你关注的主题的最新动态,请使用Tampermonkey安装本插件。
  10. // ==/UserScript==
  11. function log(x)
  12. {
  13. noty({ text: JSON.parse(JSON.stringify(x)), type: 'information', layout: 'bottomRight', timeout: 3000});
  14. }
  15. function getCookie(name) {
  16. var nameEQ = name + "=";
  17. var ca = document.cookie.split(';');
  18. for (var i = 0; i < ca.length; i++) {
  19. var c = ca[i];
  20. while (c.charAt(0) == ' ') c = c.substring(1, c.length);
  21. if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
  22. }
  23. return null;
  24. }
  25. // https://juejin.im/post/5ad1cab8f265da238a30e137
  26. async function getTopicIds() {
  27. const result = await $.ajax({
  28. method: 'GET',
  29. url: `followed_topics?offset=0&limit=100`
  30. });
  31. const ids = result.payload.map(item => item.id);
  32. return ids;
  33. }
  34. async function getPage(id){
  35. const result = await $.ajax({
  36. method: 'POST',
  37. url: `node/TopicFeedList`,
  38. headers: {
  39. "X-Xsrftoken": getCookie("_xsrf"),
  40. },
  41. data: { method: "next", params: "{\"offset\":0,\"topic_id\":" + id+ ",\"feed_type\":\"smart_feed\"}" }
  42. });
  43. const page = result.msg.join("");
  44. return page;
  45. }
  46. async function init(){
  47. const ids = await getTopicIds();
  48. const pagePromises = ids.map(id => getPage(id))
  49. const pages = await Promise.all(pagePromises)
  50. return pages;
  51. }
  52. function enableExpand(){
  53. $("body").on("click", (".zh-summary"), function(e) {
  54. // debugger
  55. $this = $(this);
  56. $this.after("<div class=\"feed\">" + $(this).prev().text() + "</div>")
  57. $this.hide();
  58. e.preventDefault();
  59. return false;
  60. });
  61. }
  62. (function() {
  63. "use strict";
  64. log("读取话题中,请稍候")
  65. init().then( pages => {
  66. $(".zh-general-list").prepend(pages);
  67. enableExpand();
  68. $("h2").css('cssText', 'font-size:16px;');
  69. $(".zm-topic-list-container").css('cssText', 'font-size:16px;');
  70. log("载入完成")
  71. })
  72. })();
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  

QingJ © 2025

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