mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 13:37:04 +03:00
Added button to set edit to the current time.
This commit is contained in:
@@ -123,6 +123,12 @@ function messageListener(request, sender, sendResponse) {
|
|||||||
v.currentTime = request.time;
|
v.currentTime = request.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.message == "getCurrentTime") {
|
||||||
|
sendResponse({
|
||||||
|
currentTime: v.currentTime
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (request.message == "getChannelURL") {
|
if (request.message == "getChannelURL") {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
channelURL: channelURL
|
channelURL: channelURL
|
||||||
|
|||||||
@@ -86,6 +86,12 @@ h1.popupElement {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tinyLink.popupElement {
|
||||||
|
font-size: 10px;
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.whitelistButton.popupElement {
|
.whitelistButton.popupElement {
|
||||||
background-color:#3acc3a;
|
background-color:#3acc3a;
|
||||||
-moz-border-radius:28px;
|
-moz-border-radius:28px;
|
||||||
|
|||||||
36
popup.js
36
popup.js
@@ -551,6 +551,13 @@ function runThePopup() {
|
|||||||
|
|
||||||
let sponsorTimeContainer = document.getElementById("sponsorTimeContainer" + index);
|
let sponsorTimeContainer = document.getElementById("sponsorTimeContainer" + index);
|
||||||
|
|
||||||
|
//the button to set the current time
|
||||||
|
let startTimeNowButton = document.createElement("span");
|
||||||
|
startTimeNowButton.id = "startTimeNowButton" + index;
|
||||||
|
startTimeNowButton.innerText = "(Now)";
|
||||||
|
startTimeNowButton.className = "tinyLink popupElement";
|
||||||
|
startTimeNowButton.addEventListener("click", () => setEditTimeToCurrentTime("startTime", index));
|
||||||
|
|
||||||
//get sponsor time minutes and seconds boxes
|
//get sponsor time minutes and seconds boxes
|
||||||
let startTimeMinutes = document.createElement("input");
|
let startTimeMinutes = document.createElement("input");
|
||||||
startTimeMinutes.id = "startTimeMinutes" + index;
|
startTimeMinutes.id = "startTimeMinutes" + index;
|
||||||
@@ -565,7 +572,7 @@ function runThePopup() {
|
|||||||
startTimeSeconds.type = "text";
|
startTimeSeconds.type = "text";
|
||||||
startTimeSeconds.value = getTimeInFormattedSeconds(sponsorTimes[index][0]);
|
startTimeSeconds.value = getTimeInFormattedSeconds(sponsorTimes[index][0]);
|
||||||
startTimeSeconds.style.width = "60px";
|
startTimeSeconds.style.width = "60px";
|
||||||
|
|
||||||
let endTimeMinutes = document.createElement("input");
|
let endTimeMinutes = document.createElement("input");
|
||||||
endTimeMinutes.id = "endTimeMinutes" + index;
|
endTimeMinutes.id = "endTimeMinutes" + index;
|
||||||
endTimeMinutes.className = "sponsorTime popupElement";
|
endTimeMinutes.className = "sponsorTime popupElement";
|
||||||
@@ -579,6 +586,13 @@ function runThePopup() {
|
|||||||
endTimeSeconds.type = "text";
|
endTimeSeconds.type = "text";
|
||||||
endTimeSeconds.value = getTimeInFormattedSeconds(sponsorTimes[index][1]);
|
endTimeSeconds.value = getTimeInFormattedSeconds(sponsorTimes[index][1]);
|
||||||
endTimeSeconds.style.width = "60px";
|
endTimeSeconds.style.width = "60px";
|
||||||
|
|
||||||
|
//the button to set the current time
|
||||||
|
let endTimeNowButton = document.createElement("span");
|
||||||
|
endTimeNowButton.id = "endTimeNowButton" + index;
|
||||||
|
endTimeNowButton.innerText = "(Now)";
|
||||||
|
endTimeNowButton.className = "tinyLink popupElement";
|
||||||
|
endTimeNowButton.addEventListener("click", () => setEditTimeToCurrentTime("endTime", index));
|
||||||
|
|
||||||
let colonText = document.createElement("span");
|
let colonText = document.createElement("span");
|
||||||
colonText.innerText = ":";
|
colonText.innerText = ":";
|
||||||
@@ -591,6 +605,7 @@ function runThePopup() {
|
|||||||
sponsorTimeContainer.removeChild(sponsorTimeContainer.firstChild);
|
sponsorTimeContainer.removeChild(sponsorTimeContainer.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sponsorTimeContainer.appendChild(startTimeNowButton);
|
||||||
sponsorTimeContainer.appendChild(startTimeMinutes);
|
sponsorTimeContainer.appendChild(startTimeMinutes);
|
||||||
sponsorTimeContainer.appendChild(colonText);
|
sponsorTimeContainer.appendChild(colonText);
|
||||||
sponsorTimeContainer.appendChild(startTimeSeconds);
|
sponsorTimeContainer.appendChild(startTimeSeconds);
|
||||||
@@ -598,6 +613,7 @@ function runThePopup() {
|
|||||||
sponsorTimeContainer.appendChild(endTimeMinutes);
|
sponsorTimeContainer.appendChild(endTimeMinutes);
|
||||||
sponsorTimeContainer.appendChild(colonText);
|
sponsorTimeContainer.appendChild(colonText);
|
||||||
sponsorTimeContainer.appendChild(endTimeSeconds);
|
sponsorTimeContainer.appendChild(endTimeSeconds);
|
||||||
|
sponsorTimeContainer.appendChild(endTimeNowButton);
|
||||||
|
|
||||||
//add save button and remove edit button
|
//add save button and remove edit button
|
||||||
let saveButton = document.createElement("span");
|
let saveButton = document.createElement("span");
|
||||||
@@ -612,6 +628,24 @@ function runThePopup() {
|
|||||||
sponsorTimesContainer.replaceChild(saveButton, editButton);
|
sponsorTimesContainer.replaceChild(saveButton, editButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setEditTimeToCurrentTime(idStartName, index) {
|
||||||
|
chrome.tabs.query({
|
||||||
|
active: true,
|
||||||
|
currentWindow: true
|
||||||
|
}, tabs => {
|
||||||
|
chrome.tabs.sendMessage(
|
||||||
|
tabs[0].id,
|
||||||
|
{message: "getCurrentTime"},
|
||||||
|
function (response) {
|
||||||
|
let minutes = document.getElementById(idStartName + "Minutes" + index);
|
||||||
|
let seconds = document.getElementById(idStartName + "Seconds" + index);
|
||||||
|
|
||||||
|
minutes.value = getTimeInMinutes(response.currentTime);
|
||||||
|
seconds.value = getTimeInFormattedSeconds(response.currentTime);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//id start name is whether it is the startTime or endTime
|
//id start name is whether it is the startTime or endTime
|
||||||
//gives back the time in seconds
|
//gives back the time in seconds
|
||||||
function getSponsorTimeEditTimes(idStartName, index) {
|
function getSponsorTimeEditTimes(idStartName, index) {
|
||||||
|
|||||||
Reference in New Issue
Block a user