Added basic time submission code

This commit is contained in:
Ajay Ramachandran
2019-07-09 15:55:33 -04:00
parent b9f321f3f7
commit 3869049088
4 changed files with 68 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
document.getElementById("sponsorStart").addEventListener("click", sendSponsorStartMessage);
document.getElementById("clearTimes").addEventListener("click", clearTimes);
document.getElementById("submitTimes").addEventListener("click", submitTimes);
//if true, the button now selects the end time
var startTimeChosen = false;
@@ -26,11 +27,24 @@ chrome.tabs.query({
}, tabs => {
chrome.tabs.sendMessage(
tabs[0].id,
{from: 'popup', message: 'infoFound'},
{from: 'popup', message: 'isInfoFound'},
infoFound
);
})
// //get the tab's video ID
// var videoID = undefined;
// chrome.tabs.query({
// active: true,
// currentWindow: true
// }, tabs => {
// chrome.tabs.sendMessage(
// tabs[0].id,
// {from: 'popup', message: 'getVideoID'},
// setVideoID
// );
// })
function infoFound(request) {
//if request is undefined, then the page currently being browsed is not YouTube
if (request != undefined) {
@@ -42,6 +56,13 @@ function infoFound(request) {
}
}
function setVideoID(request) {
//if request is undefined, then the page currently being browsed is not YouTube
if (request != undefined) {
videoID = request.videoID;
}
}
function sendSponsorStartMessage() {
//the content script will get the message if a YouTube page is open
chrome.tabs.query({
@@ -111,4 +132,10 @@ function clearTimes() {
chrome.storage.local.set({"videoTimes": videoTimes});
displayVideoTimes();
}
function submitTimes() {
chrome.runtime.sendMessage({
message: "submitTimes"
});
}