Youtube meta handler

If you use youtube in a PWA with tabs enabled, this will fix the coloring

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Youtube meta handler
// @namespace    http://youtube.com/
// @version      2025-11-24
// @description  If you use youtube in a PWA with tabs enabled, this will fix the coloring
// @author       Pooiod7
// @match        https://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const settings={base:'#f0f0f0',scrim:'#ffffff',overlay:'#1f1f1f',interval:10}
    function hexToRgb(h){h=h.replace('#','');if(h.length===3)h=h.split('').map(c=>c+c).join('');const n=parseInt(h,16);return [(n>>16)&255,(n>>8)&255,n&255]}
    function lerp(a,b,t){return Math.round(a+(b-a)*t)}
    function mixHex(a,b,t){const A=hexToRgb(a),B=hexToRgb(b);return `rgb(${lerp(A[0],B[0],t)},${lerp(A[1],B[1],t)},${lerp(A[2],B[2],t)})`}
    setInterval(()=>{
        let m=document.querySelector('meta[name="theme-color"]')
        if(!m){m=document.createElement('meta');m.setAttribute('name','theme-color');document.head.appendChild(m);m=document.querySelector('meta[name="theme-color"]')}
        const overlay=document.querySelector('tp-yt-iron-overlay-backdrop')
        if(overlay){
            const o=parseFloat(getComputedStyle(overlay).opacity)
            if(!isNaN(o)&&o>0){m.content=mixHex(settings.base,settings.overlay,Math.max(0,Math.min(1,o)));return}
        }
        const scrim=document.querySelector('#scrim')
        if(scrim){
            const o=parseFloat(getComputedStyle(scrim).opacity)
            if(!isNaN(o)&&o>0){m.content=mixHex(settings.base,settings.scrim,Math.max(0,Math.min(1,o)));return}
        }
        m.content=settings.base
    },settings.interval)
})();