[via]知乎直接看

不用打开知乎app,直接看文章

  1. // ==UserScript==
  2. // @name [via]知乎直接看
  3. // @version 3.0
  4. // @license Anti 996 License
  5. // @namespace https://viayoo.com/
  6. // @homepageURL https://app.viayoo.com/addons/16
  7. // @author 谷花泰
  8. // @modifier qidian55
  9. // @description 不用打开知乎app,直接看文章
  10. // @run-at document-start
  11. // @match *://zhihu.com/*
  12. // @match *://www.zhihu.com/*
  13. // @grant none
  14. // @webRequest {"selector":"https://static.zhihu.com/heifetz/mobile.app.55f00d73470cd90b80cf.js","action":"cancel"}
  15. // ==/UserScript==
  16. (function () {
  17. Object.defineProperties(window.navigator, {
  18. 'userAgent': {
  19. enumerable: true,
  20. value: 'Mozilla/5.0 (Windows Phone 10)'
  21. },
  22. 'appVersion': {
  23. enumerable: true,
  24. value: '5.0 (Windows Phone 10)'
  25. },
  26. 'platform': {
  27. enumerable: true,
  28. value: 'Win32'
  29. }
  30. });
  31. class FixView {
  32. constructor() {
  33. this.init();
  34. };
  35. init() {
  36. const search = document.querySelector('.MobileAppHeader-searchBox');
  37. !search && this.addSearch();
  38. };
  39. addSearch() {
  40. const menu = document.querySelector('.MobileAppHeader-actions');
  41. const searchBox = document.createElement('div');
  42. const search = document.createElement('div');
  43. searchBox.setAttribute('style', `
  44. width: 100%;
  45. height: 100%;
  46. display: flex;
  47. align-items: center;
  48. justify-content: center;
  49. `);
  50. searchBox.className = 'via-zhihu-search';
  51. search.setAttribute('style', `
  52. width: 80%;
  53. height: 32px;
  54. border-radius: 20px;
  55. border: 1px solid #ebebeb;
  56. background-color: rgba(235, 235, 235, 0.7);
  57. display: flex;
  58. align-items: center;
  59. padding-left: 10px;
  60. `);
  61. search.addEventListener('click', () => {
  62. location.href = 'https://www.zhihu.com/search?type=content&q=';
  63. }, true);
  64. search.innerHTML = this.getSearchSvg();
  65. searchBox.appendChild(search);
  66. menu.parentNode.insertBefore(searchBox, menu);
  67. };
  68. getSearchSvg() {
  69. return `<svg class="Zi Zi--Search" fill="#999" viewBox="0 0 24 24" width="18" height="18"><path d="M17.068 15.58a8.377 8.377 0 0 0 1.774-5.159 8.421 8.421 0 1 0-8.42 8.421 8.38 8.38 0 0 0 5.158-1.774l3.879 3.88c.957.573 2.131-.464 1.488-1.49l-3.879-3.878zm-6.647 1.157a6.323 6.323 0 0 1-6.316-6.316 6.323 6.323 0 0 1 6.316-6.316 6.323 6.323 0 0 1 6.316 6.316 6.323 6.323 0 0 1-6.316 6.316z" fill-rule="evenodd"></path></svg>`;
  70. };
  71. };
  72. function hideDownApp() {
  73. const style = document.createElement('style');
  74. style.innerHTML = `
  75. .MobileAppHeader-downloadLink, .css-wfkf2m, .css-1gapyfo, .css-189wwwq {
  76. display: none !important;
  77. }
  78. .css-1aq8hf9 {
  79. width: 80% !important;
  80. }
  81. `;
  82. document.querySelector('head').appendChild(style);
  83. };
  84. function observe({ targetNode, config = {}, callback = () => { } }) {
  85. if (!targetNode) {
  86. return;
  87. };
  88.  
  89. config = Object.assign({
  90. attributes: true,
  91. childList: true,
  92. subtree: true
  93. }, config);
  94.  
  95. const observer = new MutationObserver(callback);
  96. observer.observe(targetNode, config);
  97. };
  98. try {
  99. console.log('嘿嘿嘿');
  100. observe({
  101. targetNode: document.documentElement,
  102. config: {
  103. attributes: false
  104. },
  105. callback(mutations, observer) {
  106. const mysearch = document.querySelector('.via-zhihu-search');
  107. const menu = document.querySelector('.MobileAppHeader-actions');
  108. const zhihuSearch = document.querySelector('.MobileAppHeader-searchBox');
  109. if (!mysearch && menu && !zhihuSearch) {
  110. new FixView();
  111. };
  112. }
  113. });
  114. hideDownApp();
  115. } catch (err) {
  116. console.log('知乎直接看:', err)
  117. };
  118. })();

QingJ © 2025

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