知乎免登陆自动跳转发现页

去除跳转登录(不可用)页,以及自动关闭登录(不可用)提示

  1. // ==UserScript==
  2. // @name 知乎免登陆自动跳转发现页
  3. // @namespace https://www.zhihu.com/
  4. // @version 0.6
  5. // @description 去除跳转登录(不可用)页,以及自动关闭登录(不可用)提示
  6. // @author chinaqsq@126.com
  7. // @match *://*.zhihu.com/*
  8. // @grant GM_addStyle
  9. // ==/UserScript==
  10.  
  11.  
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. let loginClick = 0;
  17.  
  18. document.querySelector('body').addEventListener('DOMNodeInserted', function (e) {
  19. if (e.target.getElementsByClassName('Modal signFlowModal').length !== 0 && loginClick === 0) {
  20. e.target.getElementsByClassName('Modal-closeButton')[0].click();
  21. }
  22. loginClick = 0;
  23. });
  24.  
  25. if (location.href.indexOf("zhihu.com/signin") != -1) {
  26. location.href = "https://www.zhihu.com/explore";
  27. } else if (location.href.indexOf("zhihu.com/explore") != -1) {
  28. let timeout=400;
  29. // console.log(timeout);
  30. setTimeout(function () {
  31. let searchInput = document.getElementById("Popover1-toggle");
  32. if (searchInput) {
  33. searchInput.focus();
  34. }
  35. }, timeout);
  36. }
  37.  
  38. //#root > div > div:nth-child(2) > header > div.AppHeader-inner > div.AppHeader-userInfo > div > div > button.Button.AppHeader-login.Button--blue
  39. document.querySelector('body').addEventListener('click', function (e) {
  40. //console.log(e.target.className);
  41. if (e.target.className.indexOf('Button--blue') != -1) {
  42. loginClick = 1;
  43. }
  44. },true);
  45.  
  46.  
  47. })();
  48.  
  49. // Question-sideColumn
  50. GM_addStyle('.Question-sideColumn{margin-right: -270px}')
  51. // Question-mainColumn
  52. GM_addStyle('.Question-mainColumn{width: 960px}')
  53. GM_addStyle('.ztext p{margin: 0.7em 0}')

QingJ © 2025

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