Force YouTube Desktop

Forces use of the Desktop version of YouTube

目前为 2023-10-21 提交的版本,查看 最新版本

// ==UserScript==
// @name         Force YouTube Desktop
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Forces use of the Desktop version of YouTube
// @author       TheTank20
// @license      Unlicense
// @match        https://m.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    let isRunAlready = false;
    let doShit = function() {
        let URL = window.location.href;
        if (isRunAlready === true) {
            return;
        }
        isRunAlready = true;
        URL = URL.replace("m.youtube.com", "www.youtube.com");
        URL += (getURLParameterCount(URL) > 0) ? "&app=desktop" : "?app=desktop";
        location.replace(URL);
    };
    function getURLParameterCount(urlString) {
        const url = new URL(urlString);
        return Array.from(url.searchParams.keys()).length;
    }
    doShit();
})();