Twitch RSS Button

Add link to a channel's RSS feed

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Twitch RSS Button
// @namespace   http://domain.com/directory
// @description Add link to a channel's RSS feed
// @include     *://*.twitch.*/*
// @run-at document-start
// @version 0.0.1.20191107015349
// ==/UserScript==

setInterval(function()
{

    var cur_url = window.document.URL;

//// Get Rss Link
    var fields = cur_url.split('/');
    var junk1 = fields[0];
    var junk2 = fields[1];
    var twitchlink = fields[2];
    window.channellink = fields[3];
    var junk3 = fields[4];
    window.targetlink = "https://twitchrss.appspot.com/vod/" + window.channellink;

    var btn = document.getElementById('button')

        if (window.channellink != "")
        {
          if (window.channellink != "directory")
          {
              btn.style.visibility = "visible";
          }
          else
          {
              btn.style.visibility = "hidden";
          }
        }
        else
        {
            btn.style.visibility = "hidden";
        }
}, 500);

        //Make Button
    addButton("RSS Feed", rssFeedFn)

    function addButton(text, onclick, cssObj) {
        cssObj = cssObj || {position: 'absolute', bottom: '86%', left:'75%', 'z-index': 3}
        let button = document.createElement('button'), btnStyle = button.style
        document.body.appendChild(button)
        button.innerHTML = text
        button.onclick = onclick
        button.id = "button"
        Object.keys(cssObj).forEach(key => btnStyle[key] = cssObj[key])
        return button
    }


    //Clck Button

    function rssFeedFn()
    {
        if (window.channellink != "")
        {
          if (window.channellink != "directory")
          {
              window.open(window.targetlink);
          }
        }

    }