Hide VScode Live Server

12/28/2021, 9:44:59 AM

当前为 2024-07-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Hide VScode Live Server
  3. // @namespace Violentmonkey Scripts
  4. // @match http://127.0.0.1:550*/*
  5. // @run-at document-idle
  6. // @grant none
  7. // @version 1.3
  8. // @author Mikhail 'UniBreakfast' Ninin
  9. // @license MIT
  10. // @description 12/28/2021, 9:44:59 AM
  11. // ==/UserScript==
  12.  
  13. hideLiveServer()
  14.  
  15. function hideLiveServer() {
  16. const {body} = document
  17. const script = findScriptByText('LiveServer')
  18. const comment = findCommentByText('live-server')
  19. if (script) script.remove()
  20. if (comment) comment.remove()
  21. setTimeout(() => {
  22. body.classList.remove('vsc-initialized')
  23. if (!body.className) body.removeAttribute('class')
  24. }, 500)
  25. }
  26.  
  27. function findCommentByText(text) {
  28. return Array.from(document.body.childNodes).find(node => node.textContent.includes('live-server'))
  29. }
  30.  
  31. function findScriptByText(text) {
  32. return Array.from(document.scripts).find(script => script.textContent.includes(text))
  33. }