Better DGG Kick Embed

24/02/2025, 21:06:45 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-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Better DGG Kick Embed
  3. // @namespace yuniDev.kickembed
  4. // @match https://kick.com/*
  5. // @match https://www.destiny.gg/bigscreen
  6. // @match https://destiny.gg/bigscreen
  7. // @grant none
  8. // @version 1.0
  9. // @author yuniDev
  10. // @license MIT
  11. // @description 24/02/2025, 21:06:45 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.
  12. // ==/UserScript==
  13.  
  14. function htmlToNode(html) {
  15. const template = document.createElement('template');
  16. template.innerHTML = html;
  17. const nNodes = template.content.childNodes.length;
  18. return template.content.firstChild;
  19. }
  20.  
  21. function hideSurroundings() {
  22. [...document.querySelectorAll("nav")].forEach(el => el.style = "display: none;");
  23. const channelChatroom = document.getElementById("channel-chatroom");
  24. if (channelChatroom) channelChatroom.style = "display: none";
  25.  
  26. const sidebarWrapper = document.getElementById("sidebar-wrapper");
  27. if (sidebarWrapper) sidebarWrapper.style = "display: none";
  28.  
  29. const channelContent = document.getElementById("channel-content");
  30. if (channelContent) channelContent.style = "display: none";
  31.  
  32. const injectedChannelPlayer = document.getElementById("injected-channel-player");
  33. if (injectedChannelPlayer) {
  34. injectedChannelPlayer.style = "padding: 0px; max-height: max-content;";
  35. injectedChannelPlayer.parentNode.style = "max-height: max-content;";
  36. }
  37. document.body.firstChild.style = "height: min-content;";
  38. document.body.style = "height: min-content;";
  39. [...document.body.firstChild.children].forEach(el => el.style = el.getAttribute("style") ?? "" + ";padding-top: 0px;");
  40. }
  41.  
  42. if (window.location.hostname === "kick.com" && window.self !== window.top) { // Kick inside of iframe
  43. hideSurroundings();
  44. setInterval(() => {
  45. if (![...document.querySelectorAll("nav")].find(el => el.getAttribute("style") && el.getAttribute("style").indexOf("display: none") > -1)) hideSurroundings();
  46. }, 200);
  47. } else {
  48. const { origin, hash } = window.location;
  49.  
  50. // Check if the URL starts with the desired base
  51. const isValidStart = hash.startsWith("#kick/") && window.location.pathname === "/bigscreen";
  52.  
  53. // Extract the channel name
  54. const channel = isValidStart ? hash.split("/")[1] : null;
  55.  
  56. if (channel && isValidStart) { // We are watching a kick embed on Destiny.gg
  57. document.body.appendChild(htmlToNode(`<script type="module" src="https://unpkg.com/x-frame-bypass"></script>`));
  58. const targetUrl = `https://kick.com/${channel}`;
  59.  
  60. id = setInterval(() => {
  61. const embedContainer = document.getElementById("embed");
  62. const existingIframe = embedContainer.querySelector(".embed-frame");
  63. if (!existingIframe) return;
  64.  
  65. existingIframe.remove();
  66.  
  67. clearInterval(id);
  68.  
  69. const iframe = htmlToNode(`<iframe is="x-frame-bypass" class="embed-frame" src="${targetUrl}" allow="fullscreen; autoplay; encrypted-media; picture-in-picture; web-share"></iframe>`);
  70. embedContainer.appendChild(iframe);
  71. }, 100);
  72.  
  73. }
  74. }