YouTube Disable Force Mix Playlist On songs

Disable Force Mix Playlist On songs. will cause a offline error half seconds.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         YouTube Disable Force Mix Playlist On songs 
// @match        https://www.youtube.com/*
// @grant        none
// @description  Disable Force Mix Playlist On songs. will cause a offline error half seconds.
// @version      1.0
// @author       Lucia “LuciaTheDragon” Ekberg.
// @license MIT
// @namespace https://greasyfork.org/users/1520424
// ==/UserScript==
(function() {
    'use strict';

    let lastRedirect = '';

    function cleanURL() {
        try {
            const url = new URL(location.href);
            if (url.pathname === '/watch' && url.searchParams.has('v') && url.searchParams.has('start_radio')) {
                const v = url.searchParams.get('v');
                const clean = `${url.origin}/watch?v=${encodeURIComponent(v)}`;
                if (clean !== lastRedirect) {  // only redirect once per URL
                    lastRedirect = clean;
                    location.replace(clean);
                }
            }
        } catch(e){}
    }

    // Persistent check — can be very short interval
    setInterval(cleanURL, 1);

})();