您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Copies the M3U8 for the specific video / audio to clipboard for use in other viewing programs such as MPV or VLC
- // ==UserScript==
- // @name TMGStudio M3U8 URL Grabber
- // @match *://*.tmgstudios.tv/supporters
- // @version 1.0
- // @description Copies the M3U8 for the specific video / audio to clipboard for use in other viewing programs such as MPV or VLC
- // @run-at document-end
- // @license MIT
- // @namespace https://greasyfork.org/users/784940
- // ==/UserScript==
- // Constants
- const obsnode = document.querySelector('#posts_list');
- const obsOpt = {childList: true};
- const btnColor = "var(--color-primary)";
- const btnColorText = "var(--color-on-primary)";
- const btnStyle = `margin-left:auto; color:${btnColorText}; background-color:${btnColor}; align-self:center; cursor:pointer`;
- const btnClass = "badge badge--pale badge--large M3U8";
- const btnText = "Copy M3U8 to clipboard";
- // Functions
- function copyStream(e) {
- let el = e.currentTarget;
- let m3u8Link = el.parentNode.parentNode.parentNode.parentNode.querySelector("[data-source]").getAttribute("data-source");
- navigator.clipboard.writeText(m3u8Link);
- }
- function addCopyButton() {
- let tagSec = document.querySelectorAll(".post__tags");
- for (let sec of tagSec) {
- if (sec.parentNode.querySelector(".M3U8")) continue;
- sec.parentNode.style.display="flex";
- let btn = document.createElement("div");
- btn.classList = btnClass;
- btn.style = btnStyle;
- btn.innerText = btnText;
- sec.parentNode.appendChild(btn);
- btn.addEventListener("click", copyStream);
- }
- }
- // Entry Point
- let mut = new MutationObserver(addCopyButton);
- mut.observe(obsnode, obsOpt);
- addCopyButton();