Guest User

Untitled

a guest
May 27th, 2026
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         OLX Full Resolution Images
  3. // @namespace    http://tampermonkey.net/
  4. // @version      1.0
  5. // @description  Replace OLX images gallery with full resolution versions and add a button to preview full resolution images
  6. // @author       BeginEnd
  7. // @match        https://www.olx.pl/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.     // Nasza alternatywna galeria
  15.     const gallery = document.createElement('div');
  16.     gallery.style.position = 'fixed';
  17.     gallery.style.top = '50%';
  18.     gallery.style.left = '50%';
  19.     gallery.style.transform = 'translate(-50%, -50%)';
  20.     gallery.style.maxHeight = '80vh';
  21.     gallery.style.maxWidth = '80vw';
  22.     gallery.style.overflow = 'auto';
  23.     gallery.style.display = 'none';
  24.     gallery.style.zIndex = '1001';
  25.     gallery.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
  26.     gallery.style.padding = '20px';
  27.     gallery.style.borderRadius = '10px';
  28.     gallery.style.textAlign = 'center'
  29.     document.body.appendChild(gallery);
  30.  
  31.     // Tekst przycisku do pokazywania
  32.     const button = document.createElement('div');
  33.     button.id = 'alt-gallery';
  34.     button.textContent = 'Pokaż galerię ogłoszenia';
  35.     button.style.padding = '10px 20px';
  36.     button.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
  37.     button.style.color = '#fff';
  38.     button.style.borderRadius = '10px';
  39.     button.style.cursor = 'pointer';
  40.     button.style.zIndex = '1000';
  41.     button.style.fontSize = '14px';
  42.     button.style.textAlign = 'center';
  43.     button.style.boxShadow = '0px 4px 6px rgba(0, 0, 0, 0.1)';
  44.  
  45.     button.addEventListener('click', () => {
  46.         gallery.innerHTML = '';
  47.  
  48.         const images = document.querySelectorAll('img[src*=";s="]');
  49.         images.forEach(img => {
  50.             const i = document.createElement('img');
  51.             i.src = img.src.replace(/;s=\d+x\d+/, ';s=0x0');
  52.             i.style.maxHeight = '80vh';
  53.             i.style.maxWidth = '80vw';
  54.             i.style.margin = '10px';
  55.             gallery.appendChild(i);
  56.  
  57.             const l = document.createElement('a');
  58.             l.href = img.src;
  59.             l.target = '_blank';
  60.             l.appendChild(i);
  61.  
  62.             gallery.appendChild(l);
  63.         });
  64.         gallery.style.display = 'block';
  65.     });
  66.  
  67.     // Hide preview container when clicking outside of it
  68.     document.addEventListener('click', (event) => {
  69.         if (!gallery.contains(event.target) && event.target !== button) {
  70.             gallery.style.display = 'none';
  71.         }
  72.     });
  73.  
  74.     const interval = setInterval(() => {
  75.         const element = document.querySelector('[id="gallery-open-button"]');
  76.  
  77.         // Ukrywanie domyślnego przycisku
  78.         if (element && element.style.display != 'none') {
  79.             console.log('Ukrywam domyslny przycisk', element);
  80.             element.style.display = 'none';
  81.         }
  82.  
  83.         const olxGallery = element.parentNode;
  84.         if (button.parentNode != olxGallery) {
  85.             console.log('Dodałem przycisk', olxGallery);
  86.             olxGallery.appendChild(button);
  87.         }
  88.  
  89.         //clearInterval(interval);
  90.     }, 1000); // Check every 100ms
  91. })();
  92.  
Tags: olx
Advertisement
Add Comment
Please, Sign In to add comment