zombie / YouTube RSS feed generator

// ==UserScript==
// @name        YouTube RSS feed generator
// @namespace   com.vsubhash.js.youtube-rss-feed-generator
// @description Adds a RSS feed button to YouTube channels
// @include     https://www.youtube.com/watch*
// @version     2018
// @license			GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @copyright		V. Subhash, 2019 (https://gist.github.com/vsubhash)
// @grant       none
// ==/UserScript==

document.addEventListener("DOMContentLoaded", startItDelayed, false);
 
function startItDelayed() {
  if (document.getElementById("YT_RSS_Feed") == null) {
    window.setTimeout(addRssButton, 6*1000);    
  }  
}

function addRssButton() { 
  console.log("Executing YouTube RSS feed generator")
  var oDivs = document.getElementsByTagName("div");
  if ((oDivs != null) && (oDivs.length > 0)) {
    
    for (var i = 0; i < oDivs.length; i++) { if (oDivs[i].className == "yt-user-info") { 
      //console.log("YRFG Error: Here"); 
      var oAnchors = oDivs[i].getElementsByTagName("a"); if ((oAnchors != null) && (oDivs.length>1)) {
          var bFound = false;
          for (var j = 0; j < oAnchors.length; j++) {
            //console.log("YRFG Error: " + oAnchors[j].href.substring(0, "https://www.youtube.com/channel/".length));
            if (oAnchors[j].href.substring(0, "https://www.youtube.com/channel/".length) == "https://www.youtube.com/channel/") {
              var sChannelId = oAnchors[j].href.substring("https://www.youtube.com/channel/".length);
              
              var oRssElement = document.createElement("a");
              oRssElement.id = "YT_RSS_Feed";
              oRssElement.href = "https://www.youtube.com/feeds/videos.xml?channel_id=" + sChannelId;
              oRssElement.innerHTML = "<img src=\"https://www.google.com/images/rss.png\" style=\"margin: auto 1em; \" />";
              oAnchors[j].appendChild(oRssElement);
              
              var oLinkElement = document.createElement("link");
              oLinkElement.setAttribute("rel", "alternate");
              oLinkElement.setAttribute("title", oAnchors[j].textContent);
              oLinkElement.setAttribute("type", "application/rss+xml");
              oLinkElement.setAttribute("href", "https://www.youtube.com/feeds/videos.xml?channel_id=" + sChannelId);
              document.getElementsByTagName("head")[0].appendChild(oLinkElement);
              
              bFound = true;
              break;
            }
          }
          if (bFound) { break; }
        }
      }
    }
  }
}