Colab Kitties

add Google Colab's Kitty & Corgi modes to Twitch

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Colab Kitties
// @namespace    https://www.twitch.tv/riallymundane
// @version      0.1
// @description  add Google Colab's Kitty & Corgi modes to Twitch
// @author       Ria
// @match        https://www.twitch.tv/*
// @grant        none
// ==/UserScript==

let kitties = [
  'https://colab.research.google.com/v2/common/img/halloween_chocolatechip.gif',
  'https://colab.research.google.com/v2/common/img/halloween_oreo.gif',
  'https://colab.research.google.com/v2/common/img/halloween_redvelvet.gif',
  'https://colab.research.google.com/v2/common/img/xX_vampiregoth91_Xx.gif',
  'https://colab.research.google.com/v2/common/img/PUMPKINSPICELATTE.gif',
  'https://colab.research.google.com/v2/common/img/GHOSTPUFFS.gif'
];

let header = document.querySelector(".top-nav__menu");
let right = true;
let flip = (banner) => {
  if (banner.style.transform === 'scaleX(-1)') {
    banner.style.transform = '';
  } else {
    banner.style.transform = 'scaleX(-1)';
  }
}
let createBanner = () => {
  let random = Math.round(Math.random() * (kitties.length-1));
  let div = document.createElement('div');
  div.innerHTML = `<img src="${kitties[random]}">`;
  if (random === 1) {flip(div)}
  div.style.position = "absolute";
  div.style.top = "0px";
  div.style.zIndex = "0";
  div.style.width = "65px";
  div.style.left = "0px";
  return div;
}
let banner = createBanner();
header.insertAdjacentElement('beforebegin', banner);
let animate = () => {
  const len = parseInt(banner.style.left.split('px')[0]);
  let w = window.innerWidth;
  if (len === (w-65)) {
    right = false;
    flip(banner);
  } else if (len === 0) {
    right = true;
    flip(banner);
  }
  if (right) {
    banner.style.left = `${len+1}px`;
  } else {
    banner.style.left = `${len-1}px`;
  }
}
setInterval(animate, 10);