Allover30 Images & Videos

Access to full size content and download buttons

// ==UserScript==
// @name         Allover30 Images & Videos
// @namespace    https://greasyfork.org/en/users/1384264-atman
// @version      2024-11-28
// @description  Access to full size content and download buttons
// @author       atman
// @match        https://new.allover30.com/model-pages/*
// @match        https://new.allover30.com/Model_Directory*
// @match        https://tour.allover30.com/Model-Pages/*
// @grant        GM.xmlHttpRequest
// @license      GPL-3.0
// ==/UserScript==

(function() {
    'use strict';

    const modelBox = document.querySelectorAll('.modelBox:not(.vid):not(.disabled)');
    const modelBoxes = document.querySelectorAll('.modelBox:not(.disabled)');
    const models = document.querySelectorAll('.allModels li');

    const oldSite = document.querySelectorAll('img.border');
    let setNumber = null;

    const checkUrls = async () => {
        if (modelBox.length > 0) {
            const imgSrc = modelBox[0].querySelector('img');
            const regex = /allover30.com\/(.)\/(\w+)\/(\d+)(?=\/cover)/;
            const match = imgSrc.src.match(regex);
            const [_, letter, model, set] = match;
            const numbers = [2, 14, 39, 44, 45, 46, 48, 50, 51]; // STUDIO/Photographer
            const urlPromises = numbers.map(async (number) => {
                const url = `https://members.allover30.com/media/${letter}/${model}/${set}/1536/${model}${number}${set}_1.jpg`;
                return new Promise((resolve) => {
                    GM.xmlHttpRequest({
                        method: 'HEAD',
                        url: url,
                        onload: (response) => {
                            if (response.status === 200) {
                                setNumber = number;
                                console.log(`STUDIO/Photographer number: ${setNumber}`);
                            }
                            resolve(setNumber);
                        },
                        onerror: (error) => {
                            console.error(`Error fetching URL: ${url}`, error);
                            resolve(null);
                        }
                    });
                });
            });

            await Promise.all(urlPromises);
        }
    };


    const updateLinks = () => {
        modelBoxes.forEach(box => {
            const img = box.querySelector('img');
            //console.log('Image Element:', img);
            const modelPLink = box.querySelector('.modelP a');
            const regex = /allover30.com\/(.)\/(\w+)\/(\d+)(?=\/cover)/;
            const match = img.src.match(regex);
            //console.log('Regex Match:', match);

            if (match) {
                const [_, letter, model, set] = match;
                const imageUrl = `https://members.allover30.com/media/${letter}/${model}/${set}/4800/${model}${setNumber}${set}_1.jpg`;
                const downloadUrl = `https://members.allover30.com/media/${letter}/${model}/${set}/4800/${model}-${set}-4800.zip`;
                const vidHD = `https://members.allover30.com/media/${letter}/${model}/${set}/${model}-${set}-720.mp4`;
                const vidFHD = `https://members.allover30.com/media/${letter}/${model}/${set}/${model}-${set}-1080.mp4`;
                const vid4k = `https://members.allover30.com/media/${letter}/${model}/${set}/${model}-${set}-4k.mp4`;

                const type = box.querySelector('.modelttl');
                if (type.textContent.includes('Photo')) {
                    modelPLink.href = imageUrl;
                    modelPLink.target = '_blank';

                    const downloadZIP = addButton(downloadUrl);
                    const detailsList = box.querySelector('.modelPdtls');
                    detailsList.appendChild(downloadZIP);
                }
                else {
                    modelPLink.href = vidHD;
                    modelPLink.target = '_blank';

                    // Create buttons
                    const buttonHD = addButtonVid(vidHD, '720p');
                    const buttonFHD = addButtonVid(vidFHD, '1080p');
                    const button4k = addButtonVid(vid4k, '4K');

                    const detailsList = box.querySelector('.modelPdtls');
                    detailsList.appendChild(buttonHD);
                    detailsList.appendChild(buttonFHD);
                    detailsList.appendChild(button4k);
                }
            }
        });
    };

    const updateModelLinks = () => {
        models.forEach(model => {
            const imageElement = model.querySelector('li a');
            const nameElement = model.querySelector('.amTtl a');
            if (nameElement) {
                const modelName = nameElement.textContent.trim();
                const newHref = `https://www.google.com/search?q=${encodeURIComponent('site:*.allover30.com/model-pages ' + modelName)}`;
                nameElement.href = newHref;
                nameElement.target = '_blank';
                imageElement.href = newHref;
                imageElement.target = '_blank';
            }
        });
    };

    const updateLinksOLD = () => {
        oldSite.forEach(img => {
            const url = img.src;
            const match = url.match(/index\/(\w{6})(\w{3})(\w{6})/);
            if (match) {
                const [_, model, studio, setNumber] = match;
                const letter = model.charAt(0);
                const resolution = (setNumber < 17500) ? 2400 : 4800;
                const imageUrl = `https://members.allover30.com/media/${letter}/${model}/${setNumber}/${resolution}/${model}${studio}${setNumber}001.jpg`;
                const zipUrl = `https://members.allover30.com/media/${letter}/${model}/${setNumber}/${model}${studio}_${setNumber}_${resolution}.zip`;
                const videoWMV = `https://members.allover30.com/media/${letter}/${model}/${setNumber}/wmv/${model}${studio}${setNumber}001.wmv`;
                const videoMPG = `https://members.allover30.com/media/${letter}/${model}/${setNumber}/mpg/${model}${studio}${setNumber}001.mpg`;

                const previousTr = img.closest('tr').previousElementSibling;
                if (previousTr && previousTr.textContent.includes('PICTURES')) {
                    // Make the image clickable
                    const link = document.createElement('a');
                    link.href = imageUrl;
                    link.target = '_blank';
                    link.appendChild(img.cloneNode());

                    img.parentNode.replaceChild(link, img);

                    const downloadZIP = addButton(zipUrl);
                    link.parentNode.insertBefore(downloadZIP, link.nextSibling);
                }
                else if (previousTr && previousTr.textContent.includes('MOVIE')) {
                    const link = document.createElement('a');
                    link.href = videoWMV;
                    link.target = '_blank';
                    link.appendChild(img.cloneNode());

                    img.parentNode.replaceChild(link, img);

                    const downloadWMV = addButtonVid(videoWMV, 'WMW');
                    const downloadMPG = addButtonVid(videoMPG, 'MPG');
                    link.parentNode.insertBefore(downloadWMV, link.nextSibling);
                    link.parentNode.insertBefore(downloadMPG, link.nextSibling);
                }
            }
        });
    };

    function addButton(url) {
        const button = document.createElement('a');
        button.href = url;
        button.textContent = 'Download ZIP';
        button.style.cssText = `
            display: block;
            width:90%;
            margin: 5px;
            padding: 10px 6px;
            background: linear-gradient(90deg, #00d478, #297d58);
            color: #FFFFFF;
            text-decoration: none;
            border-radius: 5px;
            text-align: center;
            font-weight: bold;
            transition: background 0.5s linear;
            `;
        return button;
    }

    function addButtonVid(url, label) {
        const button = document.createElement('a');
        button.href = url;
        button.textContent = label;
        button.style.cssText = `
            display: inline-block;
            max-width:30%;
            margin: 6px;
            padding: 10px 6px;
            background: linear-gradient(90deg, #00d478, #297d58);
            color: #FFFFFF;
            text-decoration: none;
            border-radius: 5px;
            text-align: center;
            font-weight: bold;
            transition: background 0.5s linear;
            `;
        return button;
    }

    const main = async () => {
        if (modelBoxes.length > 0) {
            await checkUrls();
            if(setNumber){
                updateLinks();
            }
        }
        if (models.length > 0) {
            updateModelLinks();
        }

        if (oldSite.length > 0) {
            updateLinksOLD();
            const links = document.querySelectorAll('a[href*="signup.php"]');
            links.forEach(link => {
                if (link.querySelector('img[src*="join.gif"]')) {
                    link.remove(); // Remove only the specific link
                }
            });
        }

        let pp = document.querySelector('.paypal');
        if(pp){
            pp.remove();
        }
    };

    main();
})();