-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
26 lines (23 loc) · 959 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var token = ""
var userId = ""
var videoId = ""
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.tokenWithUrl != null) {
token = request.tokenWithUrl.replace("https://www.youtube.com/deleteallcomments#access_token=", "").replace(/&.*/g, "")
let url = chrome.runtime.getURL("deleting.html");
chrome.tabs.remove(sender.tab.id);
chrome.tabs.create({url});
} else if (request.toDeleteUserId != null) {
userId = request.toDeleteUserId.replace("https://www.youtube.com/channel/", "");
} else if (request.videoUrl != null) {
videoId = request.videoUrl.replace("https://www.youtube.com/watch?v=", "").replace(/&.*/g, "");
} else if (request.closeMe != null) {
chrome.tabs.remove(sender.tab.id);
} else {
sendResponse({
youtubetoken: token,
toDeleteUserId: userId,
videoId: videoId
});
}
});