zhihu analysis

analysis zhihu

目前为 2022-02-18 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name zhihu analysis
  3. // @include https://www.zhihu.com/people/*
  4. // @supportURL https://github.com/sxlgkxk/browser_script/issues
  5. // @version 0.1
  6. // @description analysis zhihu
  7. // @namespace http://sxlgkxk.github.io/
  8. // @author sxlgkxk
  9. // @icon http://sxlgkxk.github.io/im/avatar.jpg
  10. // @license MIT
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant GM_xmlhttpRequest
  14. // ==/UserScript==
  15.  
  16. (function(){
  17.  
  18. let content=''
  19. let itemlist=[]
  20. let body=null
  21. let app=null
  22. let internal=null
  23.  
  24. // answerTest
  25. function answerTest(){
  26. itemlist=document.querySelectorAll('a[data-za-detail-view-element_name="Title"]')
  27.  
  28. // answer ready
  29. if (itemlist.length > 0){
  30. for(let i=0;i<itemlist.length;i++){
  31. content+='<li>'+itemlist[i].outerHTML+'</li>'
  32. }
  33. content+='</br>'
  34. app.innerHTML=content
  35.  
  36. // into next page
  37. document.querySelector('#ProfileMain > div.ProfileMain-header > ul > li:nth-child(9) > a').click()
  38.  
  39. // start next interval
  40. clearInterval(interval)
  41. interval=setInterval(followTest, 200)
  42. }
  43. }
  44.  
  45. // followTest
  46. function followTest(){
  47. itemlist=document.querySelectorAll('.UserItem-title a[data-za-detail-view-element_name="User"]')
  48.  
  49. // answer ready
  50. if (itemlist.length > 0){
  51.  
  52. content+=`<table style="width:100%">`
  53.  
  54. for(let i=0;i<itemlist.length;i++){
  55. let user=itemlist[i].outerHTML
  56. let desc=document.querySelector('#Profile-following > div:nth-child(2) > div:nth-child('+(i+1)+') > div > div > div.ContentItem-head > div > div > div.ztext')
  57. if (desc) desc=desc.innerHTML
  58. content+='<tr><td style="text-align: right; padding-right:20px">'+user+'</td><td>'+desc+'</td></tr>'
  59. }
  60. content+='</table>'
  61. app.innerHTML=content
  62.  
  63. // into next page
  64.  
  65. // start next interval
  66. clearInterval(interval)
  67. // interval=setInterval(followTest, 200)
  68. }
  69. }
  70.  
  71. let wait_dom_interval=setInterval(()=>{
  72. // into answer page
  73. let answer_tab=document.querySelector('#ProfileMain > div.ProfileMain-header > ul > li:nth-child(2) > a')
  74. if(!answer_tab)return
  75. clearInterval(wait_dom_interval)
  76. answer_tab.click()
  77.  
  78. // dom
  79. body=document.querySelector('#ProfileHeader > div')
  80. app=document.createElement('div')
  81. body.before(app)
  82.  
  83. // style
  84. app.style.lineHeight='2'
  85. app.style.color='#c6c6c6'
  86. app.style.backgroundColor='#333'
  87. app.style.padding='20px'
  88.  
  89. interval=setInterval(answerTest, 200)
  90. }, 200)
  91.  
  92. })();

QingJ © 2025

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