知乎回答独立显示

沉浸式看知乎编的故事

  1. // ==UserScript==
  2. // @name 知乎回答独立显示
  3. // @namespace KDX Group
  4. // @version 1.3
  5. // @description 沉浸式看知乎编的故事
  6. // @author AceKadoce
  7. // @match https://www.zhihu.com/question/**
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=zhihu.com
  9. // @grant none
  10. // @require https://code.jquery.com/jquery-2.1.4.min.js
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. let reset = () => {
  16. $(".Question-sideColumn").remove();
  17. $(".Question-main").css("width", "800px");
  18. $(".Question-main").css("margin", "0 auto");
  19. $(".Question-mainColumn").css("width", "100%");
  20.  
  21. let containerDiv = $(".Question-mainColumn").children();
  22. let contentDiv = null;
  23. if(containerDiv.length == 1){
  24. contentDiv = containerDiv[0];
  25. }else{
  26. for(let i = 0; i < containerDiv.length; i++){
  27. let preDiv = containerDiv[i];
  28. let handler = $(preDiv);
  29. let className = handler.attr('class');
  30. if(className == null){
  31. continue;
  32. }
  33. if(className.search('AnswerCard') >= 0){
  34. contentDiv = preDiv;
  35. }else if(className.search('MoreAnswers') >= 0){
  36. handler.remove();
  37. }
  38. }
  39. }
  40.  
  41. if(contentDiv != null){
  42. let contentChildren = $(contentDiv).children();
  43.  
  44. for(let i = 0; i < contentChildren.length; i++){
  45. let preDiv = contentChildren[i];
  46. let handler = $(preDiv);
  47. console.log(handler.attr('class').search('QuestionInvitation'));
  48.  
  49. if(handler.attr('class').search('QuestionInvitation') >= 0){
  50. handler.remove();
  51. }else if(handler.attr('id') != 'QuestionAnswers-answers'){
  52. let className = handler.attr("class");
  53. if(className.startsWith('Card') && className.length > 4){
  54. $(handler).css("position", "fixed");
  55. $(handler).css("bottom", "10px");
  56. $(handler).css("left", "10px");
  57. $(handler).css("z-index", "10");
  58. $(handler).css("max-width", "400px");
  59.  
  60. let progressItemContentDiv = $(handler).children("div")[1];
  61. $(progressItemContentDiv).css("max-height", "700px");
  62. $(progressItemContentDiv).css("overflow-y", "scroll");
  63. }
  64. }
  65. }
  66. }
  67.  
  68. $('.RichContent-actions').css('width', '800px');
  69. $('.RichContent-actions').css('left', $('.Question-mainColumn').offset().left + 'px');
  70. $(".ContentItem-meta .AuthorInfo").css('max-width', '800px');
  71. }
  72.  
  73. $(() => {
  74. reset();
  75. $(".ViewAll a").click(function(e){
  76. console.log(this)
  77. e.preventDefault();
  78. let link = $(this).attr("href");
  79. window.location.href = link;
  80. })
  81.  
  82. $(document).scroll(() => {
  83. $(".ContentItem-meta .AuthorInfo").css('max-width', '800px');
  84. })
  85. })
  86. })();

QingJ © 2025

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