mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +03:00
Added basic time submission code
This commit is contained in:
29
popup.js
29
popup.js
@@ -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"
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user