去除标题中的(消息提示)

知乎,CSDN等网站打开时,浏览器的标题栏会显示消息提示,例如「(10条消息)首页 - 知乎」,「(5条消息)某CSDN博客」。本脚本可以去除标题中括号里的消息这一段文字,简化标签。

目前为 2024-08-01 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 去除标题中的(消息提示)
  3. // @version 1.0
  4. // @description 知乎,CSDN等网站打开时,浏览器的标题栏会显示消息提示,例如「(10条消息)首页 - 知乎」,「(5条消息)某CSDN博客」。本脚本可以去除标题中括号里的消息这一段文字,简化标签。
  5. // @author Zhou Yucheng
  6. // @match *://*.zhihu.com/*
  7. // @match *://*.csdn.net/*
  8. // @grant none
  9. // @namespace http://tampermonkey.net/
  10. // ==/UserScript==
  11.  
  12. function removeNotification () {
  13. let t=document.querySelector("head > title")
  14. let s=t.innerHTML
  15. console.log('title', s)
  16.  
  17. let i=s.indexOf('(')
  18. let k=s.indexOf('消息')
  19. let j=s.indexOf(')')
  20. if (i==0 && i<k && k<j){
  21. t.innerHTML = s.substring(j+1).trim()
  22. document.title = t.innerHTML
  23. }
  24.  
  25. i=s.indexOf('(')
  26. j=s.indexOf(')')
  27. if (i==0 && i<k && k<j){
  28. t.innerHTML=s.substring(j+1).trim()
  29. document.title = t.innerHTML
  30. }
  31. }
  32.  
  33.  
  34. (function() {
  35. 'use strict';
  36. document.addEventListener('DOMContentLoaded', () => setTimeout(removeNotification, 500));
  37. document.addEventListener('DOMContentLoaded', () => setTimeout(removeNotification, 2000));
  38. window.addEventListener('load', () => setTimeout(removeNotification, 500));
  39. window.addEventListener('load', () => setTimeout(removeNotification, 2000));
  40. })();

QingJ © 2025

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