Twitch BetterTTV without extension

This script load bttv without having to download the extension;

  1. // ==UserScript==
  2. // @run-at document-start
  3. // @name Twitch BetterTTV without extension
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.1.2
  6. // @description This script load bttv without having to download the extension;
  7. // @author Daybr3akz
  8. // @license MIT
  9. // @copyright 2017, daybreakz (https://openuserjs.org/users/daybreakz)
  10. // @match https://www.twitch.tv/*
  11. // @grant unsafeWindow
  12. // ==/UserScript==
  13.  
  14. // // ==OpenUserJS==
  15. // @author daybreakz
  16. // ==/OpenUserJS==
  17.  
  18. /*
  19. * This user script loads 1 external scripts aka
  20. * https://cdn.betterttv.net/betterttv.js, see https://github.com/night/BetterTTV
  21. */
  22.  
  23. const STORAGE_ENTRY = 'bttv_from_localhost';
  24. const LOCALHOST_WARNING = `Add ' chrome://flags/#allow-insecure-localhost ' to allow loading from localhost;
  25. Don't forget to change the CDN url in "src/utils/cdn.js" to localhost, otherwise styles won't reflect your changes.`;
  26.  
  27. let BTTV_URL = 'https://cdn.betterttv.net/betterttv.js';
  28. const fromLocalhost = localStorage.getItem(STORAGE_ENTRY) === 'true';
  29. if (fromLocalhost) {
  30. BTTV_URL = 'https://localhost/betterttv.js';
  31. }
  32. unsafeWindow.toggleBttvDev = () => {
  33. const fromLocalhost = localStorage.getItem(STORAGE_ENTRY) === 'true';
  34. localStorage.setItem(STORAGE_ENTRY, !fromLocalhost);
  35. console.log(`changed bttv script to ${fromLocalhost ? 'cdn.betterttv.net' : 'localhost'}. You can refresh to see the changes.`);
  36. if (!fromLocalhost) {
  37. console.warn(LOCALHOST_WARNING);
  38. }
  39. };
  40.  
  41. (function patchCss() {
  42. // fix screen glitch when player goes from theatre mode to full screen.
  43. const css = `
  44. .video-player--theatre.video-player--fullscreen .video-player__container {
  45. bottom: 0rem!important
  46. }`;
  47. const style = document.createElement('style');
  48. style.textContent = css;
  49. document.documentElement.appendChild(style);
  50. })();
  51.  
  52. (function betterttv() {
  53. const script = document.createElement('script');
  54. script.type = 'text/javascript';
  55. if (fromLocalhost) {
  56. console.warn(LOCALHOST_WARNING);
  57. }
  58. script.src = BTTV_URL;
  59. script.onload = () => {
  60. console.warn(`BetterTTV loaded from ${fromLocalhost ? 'localhost' : 'cdn.betterttv.net'}`);
  61. };
  62. document.documentElement.appendChild(script);
  63. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址