Extension Update. WE HAVE BEEN APPROVED ON FIREFOX!

Just got the approval email for firefox. i had to make it super vague but search up viewerCanPlay on the addons store.


bandicam2024-04-1712-08-01-357-ezgif.com-video-to-gif-converter
bandicam2024-04-1712-09-36-248-ezgif.com-video-to-gif-converter

Space to close
L to load more
hover over a thread to preview

I will also post the code on github but i cannot put links in here. just incase anyone wants to customize it for themselves.

49 Likes

if it works for anyone please let me know! if you have any issues getting it to work also please lmk and i will sort it out for u when i have the time

2 Likes

also still some glitches but if you hover over a thread and its not loading just wait like 5 seconds. it takes longer if your internet is slower ofc

1 Like
const selectors = '.top-row > a, .title.raw-link, .search-link, .inline-onebox-loading, .not-found-topic > a:first-child, .inline-onebox, .quote.quote-modified > div.title > a, .post-link, .quote.group-VIP > div > a';

// Function to remove the previewContainer
function loadMore() {
    const previewContainer = document.querySelector('.preview-container');
    const loadMoreButton = document.querySelector('#load-more-button-ext');
    if (previewContainer) {
        loadMoreButton.click();
        loadMoreButton.remove();
    }
}

// Create a function to fetch images from a link URL
function fetchAndPreviewImages(linkUrl, initialLoadCount = 5) {
    fetch(linkUrl)
        .then(response => response.text())
        .then(html => {
            const parser = new DOMParser();
            const doc = parser.parseFromString(html, 'text/html');
            const imageSrcs = Array.from(doc.querySelectorAll('img')).map(img => img.src);
            // Create a preview container
            const previewContainer = document.createElement('div');
            previewContainer.classList.add('preview-container'); // Add a class for easier removal
            previewContainer.style.position = 'fixed';
            previewContainer.style.top = '50%';
            previewContainer.style.right = '10%';
            previewContainer.style.transform = 'translate(0, -50%)';
            previewContainer.style.backgroundColor = 'white';
            previewContainer.style.padding = '10px';
            previewContainer.style.zIndex = '9999';
            previewContainer.style.maxHeight = '100%';
            previewContainer.style.overflowY = 'auto'; 

            // Add initial images to the preview container
            let loadedCount = 0;
            imageSrcs.forEach(src => {
                if (loadedCount < initialLoadCount && src.indexOf("uploads") !== -1) {
                    const img = document.createElement('img');
                    img.src = src;
                    img.style.height = '300px'; // Adjust as needed
                    previewContainer.appendChild(img);
                    loadedCount++;
                }
            });
            
            // Add button to load more images
            const loadMoreButton = document.createElement('button');
            loadMoreButton.id = 'load-more-button-ext';
            loadMoreButton.textContent = 'Load More';
            loadMoreButton.addEventListener('click', function() {
                previewContainer.querySelectorAll('img').forEach(img => img.remove());
                imageSrcs.forEach(src => {
                    if (loadedCount < imageSrcs.length && src.indexOf("uploads") !== -1) {
                        const img = document.createElement('img');
                        img.src = src;
                        img.style.height = '500px'; // Adjust as needed
                        previewContainer.appendChild(img);
                        loadedCount++;
                    }
                });
                loadMoreButton.style.display = loadedCount >= imageSrcs.length ? 'none' : 'block';
                loadMoreButton.remove();
            });

            //add button to close the preview container
            const closeButton = document.createElement('button');
            closeButton.style.position = 'sticky';
            closeButton.style.top = '0';
            closeButton.style.right = '0';
            closeButton.style.zIndex = '99999';
            closeButton.textContent = 'Close';
            closeButton.addEventListener('click', function() {
                previewContainer.remove();
            });
            previewContainer.appendChild(closeButton);
            previewContainer.appendChild(loadMoreButton);

            // Remove previous preview container, if any
            const previousPreviewContainer = document.querySelector('.preview-container');
            if (previousPreviewContainer) {
                previousPreviewContainer.remove();
            }
            // Append the new preview container to the body
            document.body.appendChild(previewContainer);

        })
        .catch(error => console.error('Error fetching images:', error));
}


// Function to remove existing event listeners
function removeEventListeners() {
    document.querySelectorAll(selectors).forEach(link => {
        link.removeEventListener('mouseenter', mouseEnterHandler);
    });
}

// Function to add event listeners
function addEventListeners() {
    document.querySelectorAll(selectors).forEach(link => {
        link.addEventListener('mouseenter', mouseEnterHandler);
    });
}

// Event handler function
function mouseEnterHandler() {
    const previewContainer = document.querySelector('.preview-container');
    if (previewContainer) {
        previewContainer.remove();
    }
    fetchAndPreviewImages(this.href);
    document.querySelectorAll(selectors).forEach(link => {
        link.style.border = '3px solid #000';
    });
    this.style.border = '3px solid red';
    this.style.color = 'grey'
}

function handleSpacebarEvent(event) {
    if (event.keyCode === 32) {
        const previewContainer = document.querySelector('.preview-container');
        if (previewContainer){
            event.preventDefault();
            previewContainer.remove(); // Clear the container
        }
    }
}

document.addEventListener("keydown", handleSpacebarEvent);

// Initial call to add event listeners
document.querySelectorAll(selectors).forEach(link => {
    link.addEventListener('mouseenter', function() {
        const previewContainer = document.querySelector('.preview-container');
        if (previewContainer) {
            previewContainer.remove();
        }
        fetchAndPreviewImages(this.href);
        document.querySelectorAll('.title.raw-link, .search-link, .inline-onebox-loading, .not-found-topic > a:first-child, .inline-onebox').forEach(link1 => {
            link1.style.border = '3px solid #000';
        })
        link.style.border = '3px solid red';
        link.style.color = 'grey';
    });
    link.style.border = '3px solid #000';
});

// Event listener for keydown event
document.addEventListener('keydown', function(event) {
    if (event.key === 'l' || event.key === 'L') {
        loadMore();
    }
});


// Repeating the process every second
setInterval(() => {
    removeEventListeners();
    addEventListeners();
}, 1000);

entire code. make your own extension with it if you dont trust the one i uploaded

6 Likes

game changer :+1:

1 Like

Thanks mann! thank you guys for the site fr

does it work for chrome?

1 Like

Works for me this is a much needed extension for users of this site. Thanks!

1 Like

Yes!! love to hear it helped man

im waiting for approval from chrome store but in the meantime the source code is there so you can use it and make ur own local extension for your personal chrome browser if youre a little more tech savvy.

2 Likes

Will this be desktop only or mobile too?

1 Like

ill work on something for mobile as well. ill let you know when i do!

2 Likes

Impressive, nice contribution to the community :+1:

2 Likes

thx bro. sick cap btw

1 Like

You gotta get promoted for that

1 Like

haha, glad you like it man

Not sure what’s more impressive, the programming skills or the vision in itself. Kudos!

Cheers bro :beers:. If u have any improvements u think i should add ill do it when i have the time. Literally anything. A way to save photos from a specific tag or anythingg

1 Like