Perfetto Pin 区域高度调整

调整 Perfetto Viewer 的 Pinned 区域高度,提供可视化控制按钮和实时比例显示

  1. // ==UserScript==
  2. // @name Perfetto Pin 区域高度调整
  3. // @namespace https://github.com/shadowwingz
  4. // @version 0.2
  5. // @description 调整 Perfetto Viewer 的 Pinned 区域高度,提供可视化控制按钮和实时比例显示
  6. // @description:en Adjust the height of Pinned area in Perfetto Viewer with visual controls and real-time percentage display
  7. // @description:de Passen Sie die Höhe des fixierten Bereichs im Perfetto Viewer mit visuellen Steuerelementen und Echtzeit-Prozentsatzanzeige an
  8. // @description:es Ajuste la altura del área fijada en Perfetto Viewer con controles visuales y visualización de porcentaje en tiempo real
  9. // @description:fr Ajustez la hauteur de la zone épinglée dans Perfetto Viewer avec des contrôles visuels et un affichage en temps réel du pourcentage
  10. // @description:zh-CN 调整 Perfetto Viewer 的固定区域高度,提供可视化控制按钮和实时比例显示
  11. // @description:ru Настройте высоту закрепленной области в Perfetto Viewer с визуальными элементами управления и отображением процентов в реальном времени
  12. // @description:ja Perfetto Viewerのピン留め領域の高さを視覚的コントロールとリアルタイムパーセンテージ表示で調整
  13. // @description:pt-BR Ajuste a altura da área fixada no Perfetto Viewer com controles visuais e exibição de porcentagem em tempo real
  14. // @description:hi Perfetto Viewer में पिन किए गए क्षेत्र की ऊंचाई को विज़ुअल नियंत्रण और रीयल-टाइम प्रतिशत प्रदर्शन के साथ समायोजित करें
  15. // @description:ar اضبط ارتفاع المنطقة المثبتة في Perfetto Viewer باستخدام عناصر تحكم مرئية وعرض النسبة المئوية في الوقت الفعلي
  16. // @description:it Regola l'altezza dell'area bloccata in Perfetto Viewer con controlli visivi e visualizzazione della percentuale in tempo reale
  17. // @description:ko 시각적 컨트롤과 실시간 백분율 표시로 Perfetto Viewer의 고정 영역 높이 조정
  18. // @author shadowwingz
  19. // @match https://ui.perfetto.dev/*
  20. // @license MIT
  21. // @grant GM_addStyle
  22. // @run-at document-idle
  23. // ==/UserScript==
  24.  
  25. (function() {
  26. 'use strict';
  27.  
  28. let currentHeight = 40;
  29. const MIN_HEIGHT = 10;
  30. const MAX_HEIGHT = 90;
  31. const STEP = 5;
  32.  
  33. // 创建控制容器
  34. const createControls = () => {
  35. const controls = document.createElement('div');
  36. controls.id = 'perfetto-pin-controls';
  37. GM_addStyle(`
  38. #perfetto-pin-controls {
  39. position: fixed;
  40. top: 70px;
  41. right: 25px;
  42. background: #fff;
  43. padding: 12px;
  44. border-radius: 8px;
  45. box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  46. z-index: 2147483647;
  47. display: flex;
  48. align-items: center;
  49. gap: 8px;
  50. }
  51. #perfetto-pin-controls button {
  52. padding: 6px 12px;
  53. background: #1976d2;
  54. color: white;
  55. border: none;
  56. border-radius: 4px;
  57. cursor: pointer;
  58. font-size: 14px;
  59. transition: background 0.2s;
  60. }
  61. #perfetto-pin-controls button:hover {
  62. background: #1565c0;
  63. }
  64. #perfetto-pin-controls span {
  65. font-family: Roboto, Arial;
  66. font-size: 14px;
  67. color: #444;
  68. min-width: 50px;
  69. text-align: center;
  70. }
  71. `);
  72.  
  73. return controls;
  74. };
  75.  
  76. // 初始化界面
  77. const initUI = () => {
  78. if (document.getElementById('perfetto-pin-controls')) return;
  79.  
  80. const controls = createControls();
  81. const status = document.createElement('span');
  82. status.textContent = '40%';
  83. const btnPlus = document.createElement('button');
  84. btnPlus.textContent = '+';
  85. const btnMinus = document.createElement('button');
  86. btnMinus.textContent = '-';
  87.  
  88. controls.appendChild(btnMinus);
  89. controls.appendChild(status);
  90. controls.appendChild(btnPlus);
  91. // 插入到页面顶部容器
  92. const mainContainer = document.querySelector('body');
  93. if (mainContainer) {
  94. mainContainer.appendChild(controls);
  95. }
  96.  
  97. // 功能实现
  98. const updateHeight = () => {
  99. const pinArea = document.querySelector('.pf-viewer-page__pinned-track-tree');
  100. if (pinArea) {
  101. pinArea.style.maxHeight = `${currentHeight}%`;
  102. status.textContent = `${currentHeight}%`;
  103. }
  104. };
  105.  
  106. btnPlus.addEventListener('click', () => {
  107. currentHeight = Math.min(currentHeight + STEP, MAX_HEIGHT);
  108. updateHeight();
  109. });
  110.  
  111. btnMinus.addEventListener('click', () => {
  112. currentHeight = Math.max(currentHeight - STEP, MIN_HEIGHT);
  113. updateHeight();
  114. });
  115.  
  116. // 初始检查
  117. updateHeight();
  118. };
  119.  
  120. // 使用MutationObserver确保动态加载后执行
  121. const observer = new MutationObserver((mutations) => {
  122. if (document.querySelector('.pf-viewer-page__pinned-track-tree')) {
  123. initUI();
  124. }
  125. });
  126.  
  127. observer.observe(document.body, {
  128. childList: true,
  129. subtree: true
  130. });
  131.  
  132. // 初始执行
  133. initUI();
  134. })();

QingJ © 2025

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