SheridanCoriana6

Google Play - Image Fullscreen

Apr 16th, 2026
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | Software | 0 0
  1. // ==UserScript==
  2. // @name Google Play - Image Fullscreen
  3. // @namespace http://tampermonkey.net/
  4. // @version 6.1
  5. // @description Powiększanie zdjęć w Google Play z obsługą strzałek i bezpieczną składnią.
  6. // @author marek7400
  7. // @match *://play.google.com/*
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let galleryImages = [];
  16. let currentIndex = 0;
  17.  
  18. // FUNKCJA POMOCNICZA DO STYLOWANIA
  19. function applyStyles(el, styles) {
  20. Object.assign(el.style, styles);
  21. }
  22.  
  23. // 1. TWORZENIE ELEMENTÓW INTERFEJSU (Bezpieczne metody)
  24. const overlay = document.createElement('div');
  25. applyStyles(overlay, {
  26. position: 'fixed', top: '0', left: '0', width: '100vw', height: '100vh',
  27. backgroundColor: 'rgba(0,0,0,0.98)', zIndex: '2147483647',
  28. display: 'none', justifyContent: 'center', alignItems: 'center', userSelect: 'none'
  29. });
  30.  
  31. const bigImg = document.createElement('img');
  32. applyStyles(bigImg, {
  33. maxWidth: '95%', maxHeight: '95%', objectFit: 'contain', boxShadow: '0 0 30px black'
  34. });
  35.  
  36. const btnPrev = document.createElement('div');
  37. btnPrev.textContent = '❮';
  38. applyStyles(btnPrev, {
  39. position: 'absolute', left: '20px', color: 'white', fontSize: '60px',
  40. cursor: 'pointer', padding: '40px 20px', zIndex: '2147483648', opacity: '0.5',
  41. transition: 'opacity 0.2s'
  42. });
  43.  
  44. const btnNext = document.createElement('div');
  45. btnNext.textContent = '❯';
  46. applyStyles(btnNext, {
  47. position: 'absolute', right: '20px', color: 'white', fontSize: '60px',
  48. cursor: 'pointer', padding: '40px 20px', zIndex: '2147483648', opacity: '0.5',
  49. transition: 'opacity 0.2s'
  50. });
  51.  
  52. const counter = document.createElement('div');
  53. applyStyles(counter, {
  54. position: 'absolute', bottom: '20px', color: 'white', fontSize: '16px',
  55. fontFamily: 'Arial', background: 'rgba(0,0,0,0.5)', padding: '5px 15px', borderRadius: '20px'
  56. });
  57.  
  58. overlay.appendChild(btnPrev);
  59. overlay.appendChild(bigImg);
  60. overlay.appendChild(btnNext);
  61. overlay.appendChild(counter);
  62. document.body.appendChild(overlay);
  63.  
  64. // 2. LOGIKA AKTUALIZACJI OBRAZU
  65. function updateImage(index) {
  66. if (galleryImages.length === 0) return;
  67.  
  68. if (index < 0) index = galleryImages.length - 1;
  69. if (index >= galleryImages.length) index = 0;
  70. currentIndex = index;
  71.  
  72. // Pobieranie URL i wymuszanie jakości s0
  73. const rawUrl = galleryImages[currentIndex];
  74. const highResUrl = rawUrl.split('=')[0] + "=s0";
  75.  
  76. bigImg.src = highResUrl;
  77. counter.textContent = (currentIndex + 1) + " / " + galleryImages.length;
  78. }
  79.  
  80. function closeOverlay() {
  81. overlay.style.display = 'none';
  82. bigImg.src = '';
  83. }
  84.  
  85. // 3. OBSŁUGA ZDARZEŃ (Poprawiona składnia)
  86. btnPrev.addEventListener('click', (e) => {
  87. e.stopPropagation();
  88. updateImage(currentIndex - 1);
  89. });
  90.  
  91. btnNext.addEventListener('click', (e) => {
  92. e.stopPropagation();
  93. updateImage(currentIndex + 1);
  94. });
  95.  
  96. // Fix dla "no-return-assign" - dodane klamry {}
  97. btnPrev.addEventListener('mouseenter', () => { btnPrev.style.opacity = '1'; });
  98. btnPrev.addEventListener('mouseleave', () => { btnPrev.style.opacity = '0.5'; });
  99. btnNext.addEventListener('mouseenter', () => { btnNext.style.opacity = '1'; });
  100. btnNext.addEventListener('mouseleave', () => { btnNext.style.opacity = '0.5'; });
  101.  
  102. overlay.addEventListener('click', (e) => {
  103. if (e.target === overlay || e.target === bigImg) {
  104. closeOverlay();
  105. }
  106. });
  107.  
  108. window.addEventListener('keydown', (e) => {
  109. if (overlay.style.display === 'flex') {
  110. if (e.key === 'ArrowLeft') updateImage(currentIndex - 1);
  111. if (e.key === 'ArrowRight') updateImage(currentIndex + 1);
  112. if (e.key === 'Escape') closeOverlay();
  113. }
  114. });
  115.  
  116. // 4. WYKRYWANIE KLIKNIĘĆ W SKLEPIE
  117. window.addEventListener('click', function(e) {
  118. const target = e.target.closest('img');
  119. if (!target) return;
  120.  
  121. if (target.src.includes('googleusercontent.com')) {
  122. // Szukamy kontenera galerii (zazwyczaj role="list")
  123. const parent = target.closest('[role="list"]') || target.parentElement.parentElement;
  124. const allImgs = Array.from(parent.querySelectorAll('img[src*="googleusercontent.com"]'));
  125.  
  126. if (allImgs.length > 0) {
  127. e.preventDefault();
  128. e.stopPropagation();
  129. e.stopImmediatePropagation();
  130.  
  131. galleryImages = allImgs.map(img => img.src);
  132. currentIndex = allImgs.indexOf(target);
  133.  
  134. overlay.style.display = 'flex';
  135. updateImage(currentIndex);
  136. }
  137. }
  138. }, true);
  139.  
  140. })();
Advertisement
Add Comment
Please, Sign In to add comment