Ultra Smooth Zoom Slider (Fixed & Isolated UI)

Adds an ultra-smooth zoom slider with draggable functionality. Keeps slider always visible and unaffected by zoom.

  1. // ==UserScript==
  2. // @name Ultra Smooth Zoom Slider (Fixed & Isolated UI)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.9
  5. // @description Adds an ultra-smooth zoom slider with draggable functionality. Keeps slider always visible and unaffected by zoom.
  6. // @author tae
  7. // @match *://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. function createZoomSlider() {
  15. console.log("✅ Ultra Smooth Zoom Slider Initialized...");
  16.  
  17. // Create the slider
  18. const slider = document.createElement('input');
  19. slider.type = 'range';
  20. slider.min = '0.5';
  21. slider.max = '2';
  22. slider.step = '0.01';
  23. slider.value = '1';
  24. slider.style.width = '200px';
  25.  
  26. // Create a container for the slider
  27. const sliderContainer = document.createElement('div');
  28. Object.assign(sliderContainer.style, {
  29. position: 'fixed',
  30. bottom: '10px',
  31. left: '10px',
  32. zIndex: '999999', // High z-index to stay on top
  33. padding: '8px',
  34. backgroundColor: 'rgba(255, 255, 255, 0.9)',
  35. border: '1px solid #ccc',
  36. borderRadius: '5px',
  37. display: 'flex',
  38. alignItems: 'center',
  39. justifyContent: 'center',
  40. boxShadow: '0px 2px 10px rgba(0, 0, 0, 0.2)',
  41. cursor: 'grab',
  42. userSelect: 'none'
  43. });
  44.  
  45. sliderContainer.appendChild(slider);
  46. document.body.appendChild(sliderContainer);
  47.  
  48. console.log("🎯 Zoom slider added successfully.");
  49.  
  50. // Create a zoomable wrapper
  51. const zoomWrapper = document.createElement('div');
  52. zoomWrapper.id = 'zoom-wrapper';
  53. while (document.body.firstChild && document.body.firstChild !== sliderContainer) {
  54. zoomWrapper.appendChild(document.body.firstChild);
  55. }
  56. document.body.insertBefore(zoomWrapper, sliderContainer);
  57.  
  58. // Apply transform to wrapper, not the whole document
  59. zoomWrapper.style.transformOrigin = 'top left';
  60. zoomWrapper.style.transition = 'transform 0.2s ease-out';
  61.  
  62. slider.addEventListener('input', function () {
  63. zoomWrapper.style.transform = `scale(${slider.value})`;
  64. });
  65.  
  66. // Dragging functionality
  67. let isDragging = false;
  68. let startX, startY, initialLeft, initialBottom;
  69.  
  70. sliderContainer.addEventListener('mousedown', function (e) {
  71. isDragging = true;
  72. sliderContainer.style.cursor = 'grabbing';
  73. startX = e.clientX;
  74. startY = e.clientY;
  75. initialLeft = sliderContainer.offsetLeft;
  76. initialBottom = window.innerHeight - sliderContainer.offsetTop - sliderContainer.offsetHeight;
  77. document.addEventListener('mousemove', onMouseMove);
  78. document.addEventListener('mouseup', onMouseUp);
  79. });
  80.  
  81. function onMouseMove(e) {
  82. if (isDragging) {
  83. const dx = e.clientX - startX;
  84. const dy = e.clientY - startY;
  85. sliderContainer.style.left = `${Math.max(0, initialLeft + dx)}px`;
  86. sliderContainer.style.bottom = `${Math.max(0, initialBottom - dy)}px`;
  87. }
  88. }
  89.  
  90. function onMouseUp() {
  91. isDragging = false;
  92. sliderContainer.style.cursor = 'grab';
  93. document.removeEventListener('mousemove', onMouseMove);
  94. document.removeEventListener('mouseup', onMouseUp);
  95. }
  96. }
  97.  
  98. if (document.readyState === 'loading') {
  99. document.addEventListener('DOMContentLoaded', createZoomSlider);
  100. } else {
  101. createZoomSlider();
  102. }
  103. })();

QingJ © 2025

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