Twitch BetterTTV without extension

This script load bttv without having to download the extension;

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @run-at       document-start
// @name         Twitch BetterTTV without extension
// @namespace    http://tampermonkey.net/
// @version      1.1.2
// @description  This script load bttv without having to download the extension;
// @author       Daybr3akz
// @license      MIT
// @copyright    2017, daybreakz (https://openuserjs.org/users/daybreakz)
// @match        https://www.twitch.tv/*
// @grant        unsafeWindow
// ==/UserScript==

// // ==OpenUserJS==
// @author daybreakz
// ==/OpenUserJS==

/*
 * This user script loads 1 external scripts aka
 * https://cdn.betterttv.net/betterttv.js, see https://github.com/night/BetterTTV
 */

const STORAGE_ENTRY = 'bttv_from_localhost';
const LOCALHOST_WARNING = `Add ' chrome://flags/#allow-insecure-localhost ' to allow loading from localhost;
Don't forget to change the CDN url in "src/utils/cdn.js" to localhost, otherwise styles won't reflect your changes.`;

let BTTV_URL = 'https://cdn.betterttv.net/betterttv.js';
const fromLocalhost = localStorage.getItem(STORAGE_ENTRY) === 'true';
if (fromLocalhost) {
    BTTV_URL = 'https://localhost/betterttv.js';
}
unsafeWindow.toggleBttvDev = () => {
    const fromLocalhost = localStorage.getItem(STORAGE_ENTRY) === 'true';
    localStorage.setItem(STORAGE_ENTRY, !fromLocalhost);
    console.log(`changed bttv script to ${fromLocalhost ? 'cdn.betterttv.net' : 'localhost'}. You can refresh to see the changes.`);
    if (!fromLocalhost) {
        console.warn(LOCALHOST_WARNING);
    }
};

(function patchCss() {
    // fix screen glitch when player goes from theatre mode to full screen.
    const css = `
    .video-player--theatre.video-player--fullscreen .video-player__container {
        bottom: 0rem!important
    }`;
    const style = document.createElement('style');
    style.textContent = css;
    document.documentElement.appendChild(style);
})();

(function betterttv() {
    const script = document.createElement('script');
    script.type = 'text/javascript';
    if (fromLocalhost) {
        console.warn(LOCALHOST_WARNING);
    }
    script.src = BTTV_URL;
    script.onload = () => {
        console.warn(`BetterTTV loaded from ${fromLocalhost ? 'localhost' : 'cdn.betterttv.net'}`);
    };
    document.documentElement.appendChild(script);
})();