UI debug tool

便于前端开发者调试ui 技巧来源于 https://juejin.im/post/5d74b29d6fb9a06aea61b8b9

  1. // ==UserScript==
  2. // @name UI debug tool
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 便于前端开发者调试ui 技巧来源于 https://juejin.im/post/5d74b29d6fb9a06aea61b8b9
  6. // @author You
  7. // @include *
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var KEY_CODE = 117 // F6 修改这里绑定自己的快捷键
  15. var remove // 用于记录remove函数 以及判端移除还是插入
  16.  
  17. function insertStyle(){
  18. var styleContent = 'body * {outline: 1px solid red}'
  19. var styleTag = document.createElement('style')
  20.  
  21. styleTag.innerHTML = styleContent
  22. document.head.appendChild(styleTag)
  23. return function removeStyle(){
  24. styleTag.parentNode.removeChild(styleTag)
  25. }
  26. }
  27.  
  28. window.addEventListener('keydown', function(e){
  29. if(e.keyCode === KEY_CODE) {
  30. if(remove){
  31. remove()
  32. remove = null
  33. }else {
  34. remove = insertStyle()
  35. }
  36. }
  37. })
  38. })();

QingJ © 2025

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