DGG - Add close stream button

2024-10-03, tfw you learn javashit to do Jaydr's job

当前为 2024-12-14 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        DGG - Add close stream button
// @namespace   Jaydr do your job
// @match       https://www.destiny.gg/bigscreen
// @match       https://www.destiny.gg/bigscreen*
// @match       https://www.destiny.gg/embed/chat
// @match       https://www.omniliberal.dev/bigscreen
// @match       https://www.omniliberal.dev/bigscreen*
// @match       https://www.omniliberal.dev/embed/chat
// @match       https://www.twitch.tv/destiny
// @grant       none
// @version     0.2
// @author      mif
// @license     MIT
// @description 2024-10-03, tfw you learn javashit to do Jaydr's job
// ==/UserScript==

function scuffed_function() { // idk how to do events so I'm clicking the other button
  document.getElementById("close-embed-btn").click()
}

function blank_embed_function() {
  window.location.href = "#twitch/destiny"
}

function css_overwrite (cssStr) {
    var D               = document;
    var newNode         = D.createElement ('style');
    newNode.textContent = cssStr;

    var targ    = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
    targ.appendChild (newNode);
}

let target_element = document.querySelector('#theater-mode') // set a base element to attach to (CINEMA one)
let custom_close_embed_button = document.createElement("button") // making the new button
let blank_button = document.createElement("button") // making the new button


// configuring the new button
// custom_close_embed_button.id = "close-embed-custom"; // useless
custom_close_embed_button.textContent = "✖️ Embed"; // name the button
// custom_close_embed_button.style = "color:dedede!important"; // make it distinct
// custom_close_embed_button.style = "color:teal!important"; // make it distinct
custom_close_embed_button.addEventListener("click", scuffed_function, false); // can't copy the initial listner so target the other button

// blank_button to hide forced hosted embeds
blank_button.textContent = "⬛"; // name the button
blank_button.href = "#twitch/destiny"
blank_button.addEventListener("click", blank_embed_function, false);

// Blackstiny
css_overwrite('[src="https://player.twitch.tv/?channel=destiny&parent=www.destiny.gg&parent=stage.destiny.gg"] {display: None;}');

target_element.after(custom_close_embed_button); // actually add the button after target_element
target_element.after(blank_button); // actually add the button after target_element
target_element.textContent = "🎥"; // text too long, make this one shorter also