Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name OLX Full Resolution Images
- // @namespace http://tampermonkey.net/
- // @version 1.0
- // @description Replace OLX images gallery with full resolution versions and add a button to preview full resolution images
- // @author BeginEnd
- // @match https://www.olx.pl/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Nasza alternatywna galeria
- const gallery = document.createElement('div');
- gallery.style.position = 'fixed';
- gallery.style.top = '50%';
- gallery.style.left = '50%';
- gallery.style.transform = 'translate(-50%, -50%)';
- gallery.style.maxHeight = '80vh';
- gallery.style.maxWidth = '80vw';
- gallery.style.overflow = 'auto';
- gallery.style.display = 'none';
- gallery.style.zIndex = '1001';
- gallery.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
- gallery.style.padding = '20px';
- gallery.style.borderRadius = '10px';
- gallery.style.textAlign = 'center'
- document.body.appendChild(gallery);
- // Tekst przycisku do pokazywania
- const button = document.createElement('div');
- button.id = 'alt-gallery';
- button.textContent = 'Pokaż galerię ogłoszenia';
- button.style.padding = '10px 20px';
- button.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
- button.style.color = '#fff';
- button.style.borderRadius = '10px';
- button.style.cursor = 'pointer';
- button.style.zIndex = '1000';
- button.style.fontSize = '14px';
- button.style.textAlign = 'center';
- button.style.boxShadow = '0px 4px 6px rgba(0, 0, 0, 0.1)';
- button.addEventListener('click', () => {
- gallery.innerHTML = '';
- const images = document.querySelectorAll('img[src*=";s="]');
- images.forEach(img => {
- const i = document.createElement('img');
- i.src = img.src.replace(/;s=\d+x\d+/, ';s=0x0');
- i.style.maxHeight = '80vh';
- i.style.maxWidth = '80vw';
- i.style.margin = '10px';
- gallery.appendChild(i);
- const l = document.createElement('a');
- l.href = img.src;
- l.target = '_blank';
- l.appendChild(i);
- gallery.appendChild(l);
- });
- gallery.style.display = 'block';
- });
- // Hide preview container when clicking outside of it
- document.addEventListener('click', (event) => {
- if (!gallery.contains(event.target) && event.target !== button) {
- gallery.style.display = 'none';
- }
- });
- const interval = setInterval(() => {
- const element = document.querySelector('[id="gallery-open-button"]');
- // Ukrywanie domyślnego przycisku
- if (element && element.style.display != 'none') {
- console.log('Ukrywam domyslny przycisk', element);
- element.style.display = 'none';
- }
- const olxGallery = element.parentNode;
- if (button.parentNode != olxGallery) {
- console.log('Dodałem przycisk', olxGallery);
- olxGallery.appendChild(button);
- }
- //clearInterval(interval);
- }, 1000); // Check every 100ms
- })();
Advertisement
Add Comment
Please, Sign In to add comment