FastPic & TurboImageHost & ImageBam & ImageVenue expand image Link Replacer

Заменяет ссылку страницы просмотра изображения на прямую ссылку изображения

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         FastPic & TurboImageHost & ImageBam & ImageVenue expand image Link Replacer
// @description  Заменяет ссылку страницы просмотра изображения на прямую ссылку изображения
// @match        https://fastpic.org/view/*
// @match        https://fastpic.org/fullview/*
// @match        https://www.turboimagehost.com/*
// @match        https://www.imagebam.com/image/*
// @match        https://imx.to/i/*
// @match        https://www.imagevenue.com/*
// @match        https://imgbox.com/*
// @match        https://prnt.sc/*
// @grant        none
// @version      1.345
// @namespace https://greasyfork.org/users/789838
// ==/UserScript==

(function() {
    'use strict';

    // Функция для проверки URL изображения и перенаправления на него
    function checkAndRedirect(imageSrc) {
        // Проверяем, если изображение заканчивается на .ext,
        if (imageSrc && (imageSrc.endsWith('.jpg') || imageSrc.endsWith('.jpeg') || imageSrc.endsWith('.gif') || imageSrc.endsWith('.png') || imageSrc.endsWith('.webp'))) {
            window.location.href = imageSrc;
        }
    }
    
    // Проверяем, находимся ли мы на странице просмотра или fullview fastpic.org
    if (window.location.href.startsWith('https://fastpic.org/view/') || window.location.href.startsWith('https://fastpic.org/fullview/')) {
        var image = document.querySelector('img.image');
        var src = image ? image.getAttribute('src') : null;
        if (src && src.startsWith('https://i')) {
            window.location.href = src;
        }
    }

    // Проверяем, находимся ли мы на странице www.turboimagehost.com
    if (window.location.href.startsWith('https://www.turboimagehost.com/')) {
        var turboImage = document.querySelector('img.uImage');
        var turboSrc = turboImage ? turboImage.getAttribute('src') : null;
        checkAndRedirect(turboSrc);
    }

    // Проверяем, находимся ли мы на странице imagebam.com
    if (window.location.href.startsWith('https://www.imagebam.com/image/')) {
        let continueLink = document.querySelector('#continue a');
        if (continueLink) {
            continueLink.click();
        }

        let mainImage = document.querySelector('.main-image');
        if (mainImage) {
            let src = mainImage.getAttribute('src');
            checkAndRedirect(src);
        }

        let fullImageLink = document.querySelector('a[data-toggle="full"]');
        if (fullImageLink) {
            let fullImageSrc = fullImageLink.href;
            checkAndRedirect(fullImageSrc);
        }
    }

    // Проверяем, находимся ли мы на странице imx.to
if (window.location.href.startsWith('https://imx.to/i/')) {
    const observer = new MutationObserver(() => {
        const anchor = document.querySelector('div[style*="text-align:center;"] > a[href*="/u/i/"]');
        if (anchor && anchor.href) {
            observer.disconnect();
            window.location.href = anchor.href;
        }
    });

    const continueBtn = document.querySelector('#continuetoimage input[type="submit"]');
    if (continueBtn) {
        observer.observe(document.body, { childList: true, subtree: true });
        continueBtn.click();
    } else {
        const anchor = document.querySelector('div[style*="text-align:center;"] > a[href*="/u/i/"]');
        if (anchor && anchor.href) {
            window.location.href = anchor.href;
        }
    }
}

    // Поддержка www.imagevenue.com
    if (window.location.href.startsWith('https://www.imagevenue.com/')) {
        // Находим изображение с классом main-image
        let imageVenueImage = document.querySelector('img#main-image');
        let imageVenueSrc = imageVenueImage ? imageVenueImage.getAttribute('src') : null;
        checkAndRedirect(imageVenueSrc);
    }

    // Проверяем, находимся ли мы на странице imgbox.com
    if (window.location.href.startsWith('https://imgbox.com/')) {
        // Находим изображение с классом image-content и id img
        let imgBoxImage = document.querySelector('img.image-content#img');
        let imgBoxSrc = imgBoxImage ? imgBoxImage.getAttribute('src') : null;
        checkAndRedirect(imgBoxSrc);
    }

    if (window.location.href.startsWith('https://prnt.sc/')) {
        let prntImage = document.querySelector('img.screenshot-image');
        let prntSrc = prntImage ? prntImage.getAttribute('src') : null;
        checkAndRedirect(prntSrc);
    }
})();