Bing Videos redirector

Redirects to youtube/tiktok when you open a video on bing videos. Credit goes to qoiqoi (https://greasyfork.org/en/users/1328793-qoiqoi) for making the script more reliable

< Feedback on Bing Videos redirector

Review: OK - script works, but has bugs

§
Posted: 05-07-2024

Hello matey, this was something that always bugged me too. I've edited the code slightly to check for DOM changes so it's a little more reliable, I also remove the previous page from history so when you click the back button you don't get stuck in a loop. It seems to garner a little more success this way. Feel free to update with this version as you see fit:

// ==UserScript==
// @name        Bing Videos redirector
// @match       https://www.bing.com/videos/riverview/*
// ==/UserScript==

(function() {
    'use strict';

    const regexPattern = /youtube\.com\/embed\/(.+)\?.*/;

    const checkIframes = () => {
        const iframes = document.getElementsByTagName('iframe');
        for (let iframe of iframes) {
            let match = iframe.src.match(regexPattern);
            if (match && match[1]) {
                let newUrl = 'https://youtu.be/' + match[1];
                history.replaceState(null, null, window.location.href);
                window.location.replace(newUrl);
                break;
            }
        }
    };

    checkIframes();

    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            if (mutation.addedNodes.length > 0) {
                checkIframes();
            }
        });
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();```
KZiadAuthor
§
Posted: 09-07-2024
Edited: 09-07-2024

Hello! Your script is awesome and way faster! I'm a newbie in javascript so this is like magic to me lol.

I will update to your version and i'll modify to add tiktok support since that's apparently also being embeded in bing videos

Also i just realized my latest version broke the whole script

Thanks for your help!

Post reply

Sign in to post a reply.