No Fcking Bing Videos

Обход Bing Videos при поиске видео в Bing

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         No Fcking Bing Videos
// @name:en      No Fcking Bing Videos
// @name:uk      No Fcking Bing Videos
// @name:de      No Fcking Bing Videos
// @namespace    http://tampermonkey.net/
// @version      1
// @description:uk  Обхід Bing Videos під час пошуку відео в Bing
// @description:en  Bypass Bing Videos when searching video in Bing
// @description:de  Bing Videos bei der Videosuche in Bing umgehen
// @description  Обход Bing Videos при поиске видео в Bing
// @author       SSYLON
// @match        https://www.bing.com/videos/riverview/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bing.com
// @grant        none
// @license      GPL-3.0-or-later
// ==/UserScript==


//КОД ВАЩЕ СОЧНЫЙ, АПТИМИЗИРОВАННЫЙ ВАЙ ТЫ ШО, ПАКУПАЙ, НЕ ПАЖАЛЕЕШ
(function () {
    'use strict';

    // проверка YT iframe
    const redirectToYouTubeWatch = () => {
        const iframes = document.querySelectorAll('iframe'); // ищем iframe на странице
        for (const iframe of iframes) {
            const src = iframe.getAttribute('src'); // Получаем src атрибут
            if (src && src.includes('youtube.com/embed')) { // ID ютубовский?
                const videoId = new URL(src).pathname.split('/')[2]; // ID видео
                const watchUrl = `https://www.youtube.com/watch?v=${videoId}`; // чут-чут меняем ссылку
                console.log('YouTube видео найдено. Переход на:', watchUrl);
                window.location.href = watchUrl; // ну и переходим типаа
                return;
            }
        }
        console.log('YouTube iframe не найден');
    };

    // праверочка после загрузки
    document.addEventListener('DOMContentLoaded', () => {
        console.log('DOM загружен. Проверяем iframe.');
        redirectToYouTubeWatch();
    });

    // обсервер если вдруг грузиться уёбищно будет
    const observer = new MutationObserver(() => {
        console.log('Обнаружено изменение DOM. Проверяем iframe.');
        redirectToYouTubeWatch();
    });

    // наблюдаем за изменениями DOM
    observer.observe(document.body, { childList: true, subtree: true });

    // на всякий проверяем ещё раз, вдруг оно там пиздец уёбищно грузит
    setTimeout(redirectToYouTubeWatch, 3000);
})();