Replace Kick Embed with Channel Page and Enable Theatre Mode

Replaces Kick embed with a full channel page and enables theatre mode on Kick.com only when loaded as an embed replacement

当前为 2025-03-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Replace Kick Embed with Channel Page and Enable Theatre Mode
  3. // @namespace https://player.kick.com/
  4. // @version 1.3
  5. // @description Replaces Kick embed with a full channel page and enables theatre mode on Kick.com only when loaded as an embed replacement
  6. // @author nobody
  7. // @match *://player.kick.com/*
  8. // @match *://kick.com/*
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @grant GM_addStyle
  12. // @license GPL-3.0-or-later
  13. // ==/UserScript==
  14.  
  15. if (window.location.host.includes("player.kick.com")) {
  16. // Code for the embed page: Replace the Kick player with a full channel page
  17. const observer = new MutationObserver(() => {
  18. const playerContainer = document.querySelector(".video-container");
  19. if (playerContainer) {
  20. // Extract channel information from the URL
  21. const channelUrl = window.location.href;
  22. console.log("Channel URL:", channelUrl);
  23. const channelId = channelUrl.split("/")[3]; // Assumes URL is like: https://player.kick.com/channel/{channelId}
  24. console.log("Channel ID:", channelId);
  25.  
  26. // Create an iframe for the full Kick channel page
  27. const iframe = document.createElement("iframe");
  28. iframe.src = `https://kick.com/${channelId}`;
  29. iframe.style.width = "100%";
  30. iframe.style.height = "100vh"; // Full viewport height
  31. iframe.style.border = "none";
  32.  
  33. // Replace the embed with the full channel page
  34. playerContainer.innerHTML = "";
  35. playerContainer.appendChild(iframe);
  36.  
  37. // Stop observing and mark that we replaced the embed
  38. observer.disconnect();
  39. GM_setValue("embedReplaced", true);
  40. }
  41. });
  42. observer.observe(document.body, {
  43. subtree: true,
  44. childList: true,
  45. });
  46. } else if (window.location.host.includes("kick.com")) {
  47. // Code for kick.com: Only run if the embed was replaced and the referrer indicates it came from player.kick.com
  48. const embedReplacedValue = GM_getValue("embedReplaced", false);
  49. if (embedReplacedValue && document.referrer.includes("player.kick.com")) {
  50. console.log("Embed replacement detected via referrer. Enabling theatre mode...");
  51. const observer2 = new MutationObserver(() => {
  52. const el = document.querySelector('[data-sidebar]');
  53. el.dataset.sidebar = 'false';
  54. el.dataset.chat = 'false';
  55. el.dataset.theatre = 'true';
  56.  
  57. GM_addStyle(`
  58. [data-sidebar] > .w-xvw {
  59. padding-top: unset !important;
  60. }
  61.  
  62. #channel-content {
  63. display: none;
  64. }
  65. `);
  66.  
  67. observer2.disconnect();
  68. // Clear the flag so subsequent direct visits to kick.com don't trigger theatre mode
  69. GM_setValue("embedReplaced", false);
  70. });
  71. observer2.observe(document.body, {
  72. subtree: true,
  73. childList: true,
  74. });
  75. }
  76. }