Youtube/Twitch to streamlink

Add button to youtube and twitch player to watch the video/stream in streamlink

  1. // ==UserScript==
  2. // @name Youtube/Twitch to streamlink
  3. // @namespace fke9fgjew89gjwe89
  4. // @version 1.2
  5. // @description Add button to youtube and twitch player to watch the video/stream in streamlink
  6. // @author https://gf.qytechs.cn/en/users/432346-fke9fgjew89gjwe89
  7. // @match https://*.youtube.com/*
  8. // @match https://*.twitch.tv/*
  9. // @run-at document-end
  10. // @grant none
  11. // ==/UserScript==
  12. (function () {
  13. 'use strict';
  14.  
  15. if (location.href.includes("youtube.com/watch")) {
  16. var button_list = document.getElementsByClassName('ytp-right-controls')[0];
  17. var directdl = '<a href="streamlink://' + window.location + '" class="ytp-play-button ytp-button" aria-label="Play in streamlink" title="Play in streamlink"><svg height="100%" version="1.1" viewBox="0 0 36 36" width="100%"><use class="ytp-svg-shadow" xlink:href="#ytp-id-42"></use><path class="ytp-svg-fill" d="M 12,26 18.5,22 18.5,14 12,10 z M 18.5,22 25,18 25,18 18.5,14 z" id="ytp-id-42"></path></svg></a>';
  18. button_list.insertAdjacentHTML('afterbegin', directdl);
  19. }
  20.  
  21. if (location.host.includes("twitch.tv")) {
  22. window.onload = function () {
  23. var button_list_tw = document.getElementsByClassName('player-controls__right-control-group')[0];
  24. var directdltw = '<div class="tw-inline-flex tw-relative tw-tooltip-wrapper"><a href="streamlink://' + window.location + '" class="tw-align-items-center tw-align-middle tw-border-bottom-left-radius-medium tw-border-bottom-right-radius-medium tw-border-top-left-radius-medium tw-border-top-right-radius-medium tw-button-icon tw-button-icon--overlay tw-core-button tw-core-button--overlay tw-inline-flex tw-interactive tw-justify-content-center tw-overflow-hidden tw-relative" aria-label="Play in streamlink"><span class="tw-button-icon__icon"><div style="width: 2rem; height: 2rem;"><div class="tw-icon"><div class="tw-aspect"></div><svg width="100%" height="100%" version="1.1" viewBox="0 0 20 20" x="0px" y="0px" style="fill: currentcolor"><g><path d="M5 17.066V2.934a.5.5 0 01.777-.416L17 10 5.777 17.482A.5.5 0 015 17.066z"></path></g></svg></div></div></span></a><div class="tw-tooltip tw-tooltip--align-right tw-tooltip--up" data-a-target="tw-tooltip-label" role="tooltip">Play in streamlink</div></div>';
  25. button_list_tw.insertAdjacentHTML('beforeend', directdltw);
  26. }
  27. }
  28. }());

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址