【发布时间】:2016-08-09 00:17:50
【问题描述】:
我目前正在尝试制作一个 google chrome 扩展程序,如果您在 Reddit 上投票,它将“喜欢”或“收藏”一个 youtube 视频。显然,您需要用户登录并对该用户进行身份验证,这样您才能喜欢或收藏该视频。
我的问题是我该如何做呢?我试过做一些研究,但我仍然完全不知道用户身份验证的来源或用户如何登录(如果还没有的话)。我假设我需要使用 OAuth2 才能喜欢 youtube 上的视频,但是如何在我的扩展程序中实现它?
到目前为止,我只有 content.js 和 manifest.json:
{
"name": "VideoUpLike",
"version": "1.0.0",
"description": "Likes the video on YouTube after upvoting a YouTube link on Reddit",
"manifest_version": 2,
"permissions": [
"https://www.googleapis.com/*"
],
"content_scripts": [
{
"matches": ["http://www.reddit.com/*", "https://www.reddit.com/*"],
"js" : [ "contentscript.js"]
}],
"background": {
"page": ["Auth.html"]
}
}
和我的文本 content.js 脚本来测试 upvote 按钮点击:
document.addEventListener('click', function(e) {
if (e.target.matches('.arrow.upmod')) {
alert("Oh hi there");
}
});
【问题讨论】:
标签: javascript google-chrome google-chrome-extension youtube