I'm currently working on a project to automatically retrieve YouTube URLs and incorporate a download button feature. I found a tutorial suggesting the use of
'ytplayer.config.args.url_encoded_fmt_stream.map.split(",");'
After attempting to execute this command both in the console and within my project, I encountered the following error message:
VM765:1 Uncaught TypeError: Cannot read property 'map' of undefined
at <anonymous>:1:45'
Although I came across similar discussions on Stack Overflow where users recommended using the same line of code, I am uncertain as to why it is not functioning properly.
manifest.json
"name" : "Simple Youtube Downloader",
"description" : "Simplify your YouTube video downloads.",
"version" : "0.1",
"author" : "Nick Germaine",
"web_accessible_resources" : ["src/youtubedl.js"],
"manifest_version" : 2,
"content_scripts" : [
{
"matches" : ["https://www.youtube.com/watch*"],
"js" : ["src/loader.js"]
}
]
loader.js
s = document.createElement("script");
s.src = chrome.extension.getURL("src/youtubedl.js");
s.onload = function(){
this.remove();
}
document.head.appendChild(s);
youtubedl.js
var videoUrls = window.ytplayer.config.args.loaderUrl.map.split(',');
console.log("Our extension has been loaded", videoUrls)