tastedive yohoho injector

inject yohoho iframe replace youtube iframe in tastedive site

Fra 17.04.2023. Se den seneste versjonen.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         tastedive yohoho injector
// @description  inject yohoho iframe replace youtube iframe in tastedive site
// @match        https://tastedive.com/*
// @grant        GM_getResourceText
// @license MIT
// @version 0.3
// @namespace https://greasyfork.org/users/739921
// ==/UserScript==

let search = true;
let observer = new MutationObserver(mutationRecords => {
    if (search) {
        const ifr = document.querySelector('div > iframe[class^="JustWatchWidget"]');
        if (ifr && !document.querySelector('div[id="yohoho"][data-title]')) {
            search = false;
            const script = document.createElement('script');
            script.src = "https://yohoho.cc/yo.js";
            document.body.appendChild(script);
            const title = document.querySelector(`meta[itemprop="name"][content]`).getAttribute("content");
            const year = document.querySelector(`meta[itemprop="url"][content]`).getAttribute("content").split("-").slice(-1)[0];
            const yohoho = document.createElement('div');
            yohoho.id = "yohoho";
            yohoho.setAttribute("data-title", `${title} (${year})`);
            ifr.parentNode.replaceChild(yohoho, ifr);
            console.log(`mounted: <div id="yohoho" data-title="${title} (${year})"></div>`);
            search = true;
        }
    }
});

observer.observe(document, {
    childList: true,
    subtree: true,
    characterDataOldValue: true
});