Greasy Fork

Greasy Fork is available in English.

Better DGG Kick Embed

MIGHT NOT WORK WITH TAMPERMONKEY. VIOLENTMONKEY SHOULD WORK. Hacky solution to embed full kick site instead of the embed. I can't promise it will continue to work indefinitely. If it bugs out when resizing the window, try refreshing the page.

当前为 2025-02-25 提交的版本,查看 最新版本

// ==UserScript==
// @name        Better DGG Kick Embed
// @namespace   yuniDev.kickembed
// @match       https://kick.com/*
// @match       https://www.destiny.gg/bigscreen
// @match       https://destiny.gg/bigscreen
// @grant       none
// @version     1.1
// @author      yuniDev
// @license     MIT
// @description MIGHT NOT WORK WITH TAMPERMONKEY. VIOLENTMONKEY SHOULD WORK. Hacky solution to embed full kick site instead of the embed. I can't promise it will continue to work indefinitely. If it bugs out when resizing the window, try refreshing the page.
// ==/UserScript==

let prevHash = "";

function htmlToNode(html) {
    const template = document.createElement('template');
    template.innerHTML = html;
    const nNodes = template.content.childNodes.length;
    return template.content.firstChild;
}

function hideSurroundings() {
  [...document.querySelectorAll("nav")].forEach(el => el.style = "display: none;");
  const channelChatroom = document.getElementById("channel-chatroom");
  if (channelChatroom) channelChatroom.style = "display: none";

  const sidebarWrapper = document.getElementById("sidebar-wrapper");
  if (sidebarWrapper) sidebarWrapper.style = "display: none";

  const channelContent = document.getElementById("channel-content");
  if (channelContent) channelContent.style = "display: none";

  const injectedChannelPlayer = document.getElementById("injected-channel-player");
  if (injectedChannelPlayer) {
    injectedChannelPlayer.style = "padding: 0px; max-height: max-content;";
    injectedChannelPlayer.parentNode.style = "max-height: max-content;";
  }

  const bodyChild = document.body.firstChild;
  if (bodyChild) {
    bodyChild.style = "height: min-content;";
    [...bodyChild.children].forEach(el => el.style = el.getAttribute("style") ?? "" +  ";padding-top: 0px;");
  }
  document.body.style = "height: min-content;";
}

function loadDestinyGG() {
  const { origin, hash } = window.location;

  if (prevHash.startsWith("#kick/") && !hash.startsWith("#kick")) location.reload(); // Reload page if switching away from kick embed
  prevHash = hash;

  // Check if the URL starts with the desired base
  const isValidStart = hash.startsWith("#kick/") && window.location.pathname === "/bigscreen";

  // Extract the channel name
  const channel = isValidStart ? hash.split("/")[1] : null;

  if (channel && isValidStart) { // We are watching a kick embed on Destiny.gg
    document.body.appendChild(htmlToNode(`<script type="module" src="https://unpkg.com/x-frame-bypass"></script>`));
    const targetUrl = `https://kick.com/${channel}`;

    id = setInterval(() => {
      const embedContainer = document.getElementById("embed");
      const existingIframe = embedContainer.querySelector(".embed-frame");
      if (!existingIframe) return;

      existingIframe.remove();

      clearInterval(id);

      const iframe = htmlToNode(`<iframe is="x-frame-bypass" class="embed-frame" src="${targetUrl}" allow="fullscreen; autoplay; encrypted-media; picture-in-picture; web-share"></iframe>`);
      embedContainer.appendChild(iframe);
    }, 100);
  }
}

if (window.location.hostname === "kick.com" && window.self !== window.top) { // Kick inside of iframe
  hideSurroundings();
  setInterval(() => {
    if (![...document.querySelectorAll("nav")].find(el => el.getAttribute("style") && el.getAttribute("style").indexOf("display: none") > -1)) hideSurroundings();
  }, 200);
} else {
  loadDestinyGG();
  addEventListener('hashchange', loadDestinyGG);
}