var ytid = document.getElementsByTagName("button")
.getElementsByClassName("yt-uix-button")
.getAttribute("data-channel-external-id");
Uncaught TypeError: document.getElementsByTagName(...).getElementsByClassName is not a function(…)
var buttonWithAttribute;
Array.prototype.forEach.call(document.getElementsByClassName("yt-uix-button"), function(button){
if(button.hasAttribute("data-channel-external-id"))
buttonWithAttribute = button;
})
console.log(buttonWithAttribute.getAttribute("data-channel-external-id"));