如何使用没有YouTube API的JavaScript获取YouTube视频的标题?
我正在制作Chrome扩展名,我需要获取YouTube视频的标题。我不想使用YouTube API。
I am making a chrome extension and I need to grab the title of youtube videos. I don't want to use the youtube api.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过执行
var videotitle = document.title.split(“ - youtube”)[0];
来解决它。Solved it by doing
var videotitle = document.title.split(" - YouTube")[0];
您可以在后台获取标题标题。JS,它将返回YouTube视频标题
});
You can grab the tab title in the background.js, it will return the youtube video title
});
您还可以在F12开发人员工具中使用此代码线:
同样的代码也应在您的扩展程序上工作。
You can also use this line of code in the F12 developer tools:
The same line of code should work on your extension as well.