mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 11:37:02 +03:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d01ffee1b | ||
|
|
9c51df9159 | ||
|
|
3a29fcc3d8 | ||
|
|
b18f2ae60d | ||
|
|
ab07478e25 | ||
|
|
d6aeec933a | ||
|
|
cd5207f816 | ||
|
|
381c11ed99 |
@@ -24,9 +24,6 @@
|
||||
"409": {
|
||||
"message": "This has already been submitted before"
|
||||
},
|
||||
"502": {
|
||||
"message": "It seems the server is down. Contact the dev to inform them."
|
||||
},
|
||||
"channelWhitelisted": {
|
||||
"message": "Channel Whitelisted!"
|
||||
},
|
||||
@@ -217,10 +214,10 @@
|
||||
"message": "This is the button that allows you to clear all sponsors on the YouTube player."
|
||||
},
|
||||
"disableViewTracking": {
|
||||
"message": "Disable Sponsor View Tracking"
|
||||
"message": "Disable Sponsor Skip Count Tracking"
|
||||
},
|
||||
"enableViewTracking": {
|
||||
"message": "Enable Sponsor View Tracking"
|
||||
"message": "Enable Sponsor Skip Count Tracking"
|
||||
},
|
||||
"whatViewTracking": {
|
||||
"message": "This feature tracks which sponsors you have skipped to let users know how much their submission has helped others and\nused as a metric along with upvotes to ensure that spam doesn't get into the database. The extension sends a message\nto the server each time you skip a sponsor. Hopefully most people don't change this setting so that the view numbers are accurate. :)"
|
||||
@@ -272,5 +269,50 @@
|
||||
"yourWork": {
|
||||
"message": "Your Work",
|
||||
"description": "Used to describe the section that will show you the statistics from your submissions."
|
||||
},
|
||||
"502": {
|
||||
"message": "The server seems to be overloaded. Try again in a few seconds."
|
||||
},
|
||||
"errorCode": {
|
||||
"message": "Error Code: "
|
||||
},
|
||||
"noticeTitleNotSkipped": {
|
||||
"message": "Skip Sponsor?"
|
||||
},
|
||||
"skip": {
|
||||
"message": "Skip"
|
||||
},
|
||||
"disableAutoSkip": {
|
||||
"message": "Disable Auto Skip"
|
||||
},
|
||||
"enableAutoSkip": {
|
||||
"message": "Enable Auto Skip"
|
||||
},
|
||||
"autoSkipDescription": {
|
||||
"message": "Auto skip will skip sponsors for you. If disabled, a notice will appear asking if you'd like to skip."
|
||||
},
|
||||
"youHaveSkipped": {
|
||||
"message": "You have skipped "
|
||||
},
|
||||
"youHaveSaved": {
|
||||
"message": "You have saved yourself "
|
||||
},
|
||||
"minLower": {
|
||||
"message": "minute"
|
||||
},
|
||||
"minsLower": {
|
||||
"message": "minutes"
|
||||
},
|
||||
"hourLower": {
|
||||
"message": "hour"
|
||||
},
|
||||
"hoursLower": {
|
||||
"message": "hours"
|
||||
},
|
||||
"youHaveSavedTime": {
|
||||
"message": "You have saved people"
|
||||
},
|
||||
"youHaveSavedTimeEnd": {
|
||||
"message": " of their lives."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
"409": {
|
||||
"message": "Déja soumis"
|
||||
},
|
||||
"502": {
|
||||
"message": "Le serveur ne fonctionne pas. Contactez le développeur."
|
||||
},
|
||||
"channelWhitelisted": {
|
||||
"message": "Cette chaîne est sur la liste blanche !"
|
||||
},
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
"409": {
|
||||
"message": "Questo spezzone è già stato inviato"
|
||||
},
|
||||
"502": {
|
||||
"message": "Sembra che il server non funzioni. Contatta lo sviluppatore."
|
||||
},
|
||||
"channelWhitelisted": {
|
||||
"message": "Canale aggiunto alla whitelist!"
|
||||
},
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
"409": {
|
||||
"message": "Isso já foi enviado antes"
|
||||
},
|
||||
"502": {
|
||||
"message": "Parece que o servidor caiu. Contate o desenvolvedor para informá-los."
|
||||
},
|
||||
"channelWhitelisted": {
|
||||
"message": "Canal adicionado à lista branca!"
|
||||
},
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
"409": {
|
||||
"message": "Isso já foi enviado antes"
|
||||
},
|
||||
"502": {
|
||||
"message": "Parece que o servidor caiu. Contacte o desenvolvedor para o informar."
|
||||
},
|
||||
"channelWhitelisted": {
|
||||
"message": "Canal adicionado à whitelist!"
|
||||
},
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
"409": {
|
||||
"message": "Этот запрос был отправлен ранее."
|
||||
},
|
||||
"502": {
|
||||
"message": "Сервер недоступен. Свяжитесь с разработчиком и сообщите ему об этом."
|
||||
},
|
||||
"channelWhitelisted": {
|
||||
"message": "Канал добавлен в белый список!"
|
||||
},
|
||||
|
||||
67
content.js
67
content.js
@@ -10,6 +10,9 @@ var sponsorVideoID = null;
|
||||
//these are sponsors that have been downvoted
|
||||
var hiddenSponsorTimes = [];
|
||||
|
||||
/** @type {Array[boolean]} Has the sponsor been skipped */
|
||||
var sponsorSkipped = [];
|
||||
|
||||
//the video
|
||||
var v;
|
||||
|
||||
@@ -76,6 +79,15 @@ chrome.storage.sync.get(["disableSkipping"], function(result) {
|
||||
}
|
||||
});
|
||||
|
||||
//should skips be manual
|
||||
var disableAutoSkip = false;
|
||||
chrome.storage.sync.get(["disableAutoSkip"], function(result) {
|
||||
let disableAutoSkipStorage = result.disableAutoSkip;
|
||||
if (disableAutoSkipStorage != undefined) {
|
||||
disableAutoSkip = disableAutoSkipStorage;
|
||||
}
|
||||
});
|
||||
|
||||
//should view counts be tracked
|
||||
var trackViewCount = false;
|
||||
chrome.storage.sync.get(["trackViewCount"], function(result) {
|
||||
@@ -409,6 +421,9 @@ function sponsorsLookup(id, channelIDPromise) {
|
||||
sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes;
|
||||
UUIDs = JSON.parse(xmlhttp.responseText).UUIDs;
|
||||
|
||||
// Reset skip save
|
||||
sponsorSkipped = [];
|
||||
|
||||
//update the preview bar
|
||||
//leave the type blank for now until categories are added
|
||||
if (lastPreviewBarUpdate == id || (lastPreviewBarUpdate == null && !isNaN(v.duration))) {
|
||||
@@ -606,7 +621,9 @@ function checkIfTimeToSkip(currentVideoTime, startTime, endTime) {
|
||||
|
||||
//skip fromt he start time to the end time for a certain index sponsor time
|
||||
function skipToTime(v, index, sponsorTimes, openNotice) {
|
||||
v.currentTime = sponsorTimes[index][1];
|
||||
if (!disableAutoSkip) {
|
||||
v.currentTime = sponsorTimes[index][1];
|
||||
}
|
||||
|
||||
lastSponsorTimeSkipped = sponsorTimes[index][0];
|
||||
|
||||
@@ -616,7 +633,7 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
|
||||
if (openNotice) {
|
||||
//send out the message saying that a sponsor message was skipped
|
||||
if (!dontShowNotice) {
|
||||
let skipNotice = new SkipNotice(this, currentUUID);
|
||||
let skipNotice = new SkipNotice(this, currentUUID, disableAutoSkip);
|
||||
|
||||
if (dontShowNoticeOld) {
|
||||
//show why this notice is showing
|
||||
@@ -628,15 +645,31 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
|
||||
}
|
||||
|
||||
//auto-upvote this sponsor
|
||||
if (trackViewCount) {
|
||||
if (trackViewCount && !disableAutoSkip) {
|
||||
vote(1, currentUUID, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//send telemetry that a this sponsor was skipped happened
|
||||
if (trackViewCount) {
|
||||
if (trackViewCount && !sponsorSkipped[index]) {
|
||||
sendRequestToServer("GET", "/api/viewedVideoSponsorTime?UUID=" + currentUUID);
|
||||
|
||||
if (!disableAutoSkip) {
|
||||
// Count this as a skip
|
||||
chrome.storage.sync.get(["minutesSaved"], function(result) {
|
||||
if (result.minutesSaved === undefined) result.minutesSaved = 0;
|
||||
|
||||
chrome.storage.sync.set({"minutesSaved": result.minutesSaved + (sponsorTimes[index][1] - sponsorTimes[index][0]) / 60 });
|
||||
});
|
||||
chrome.storage.sync.get(["skipCount"], function(result) {
|
||||
if (result.skipCount === undefined) result.skipCount = 0;
|
||||
|
||||
chrome.storage.sync.set({"skipCount": result.skipCount + 1 });
|
||||
});
|
||||
|
||||
sponsorSkipped[index] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -905,6 +938,30 @@ function vote(type, UUID, skipNotice) {
|
||||
skipNotice.resetNoticeInfoMessage.bind(skipNotice)();
|
||||
}
|
||||
|
||||
let sponsorIndex = UUIDs.indexOf(UUID);
|
||||
|
||||
// See if the local time saved count and skip count should be reverted
|
||||
if (type == 0 && sponsorSkipped[sponsorIndex] || type == 1 && !sponsorSkipped[sponsorIndex]) {
|
||||
let factor = 1;
|
||||
if (type == 0) {
|
||||
factor = -1;
|
||||
}
|
||||
|
||||
// Count this as a skip
|
||||
chrome.storage.sync.get(["minutesSaved"], function(result) {
|
||||
if (result.minutesSaved === undefined) result.minutesSaved = 0;
|
||||
|
||||
chrome.storage.sync.set({"minutesSaved": result.minutesSaved + factor * (sponsorTimes[sponsorIndex][1] - sponsorTimes[sponsorIndex][0]) / 60 });
|
||||
});
|
||||
chrome.storage.sync.get(["skipCount"], function(result) {
|
||||
if (result.skipCount === undefined) result.skipCount = 0;
|
||||
|
||||
chrome.storage.sync.set({"skipCount": result.skipCount + factor * 1 });
|
||||
});
|
||||
|
||||
sponsorSkipped[sponsorIndex] = !sponsorSkipped[sponsorIndex];
|
||||
}
|
||||
|
||||
chrome.runtime.sendMessage({
|
||||
message: "submitVote",
|
||||
type: type,
|
||||
@@ -1048,7 +1105,7 @@ function sendSubmitMessage(){
|
||||
//treat them the same
|
||||
if (response.statusCode == 503) response.statusCode = 502;
|
||||
|
||||
alert(chrome.i18n.getMessage(response.statusCode + ""));
|
||||
alert(chrome.i18n.getMessage(response.statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + response.statusCode);
|
||||
} else {
|
||||
alert(chrome.i18n.getMessage("connectionError") + response.statusCode);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "__MSG_fullName__",
|
||||
"short_name": "__MSG_Name__",
|
||||
"version": "1.1.9.6",
|
||||
"version": "1.1.9.8",
|
||||
"default_locale": "en",
|
||||
"description": "__MSG_Description__",
|
||||
"content_scripts": [
|
||||
|
||||
52
popup.html
52
popup.html
@@ -114,25 +114,49 @@
|
||||
<h2 class="recordingSubtitle popupElement">__MSG_yourWork__</h2>
|
||||
|
||||
<p class="popupElement">
|
||||
<span id=sponsorTimesContributionsContainer class="popupElement" style="display: none">
|
||||
<span id="sponsorTimesContributionsContainer" class="popupElement" style="display: none">
|
||||
__MSG_soFarUHSubmited__
|
||||
<span id="sponsorTimesContributionsDisplay" class="popupElement">
|
||||
0
|
||||
</span>
|
||||
<span id="sponsorTimesContributionsDisplayEndWord" class="popupElement">
|
||||
__MSG_Sponsors__.
|
||||
</span>
|
||||
<span id="sponsorTimesContributionsDisplayEndWord" class="popupElement">__MSG_Sponsors__</span>.
|
||||
</span>
|
||||
|
||||
<span id=sponsorTimesViewsContainer class="popupElement" style="display: none">
|
||||
<span id="sponsorTimesViewsContainer" class="popupElement" style="display: none">
|
||||
__MSG_savedPeopleFrom__
|
||||
<span id="sponsorTimesViewsDisplay" class="popupElement">
|
||||
0
|
||||
</span>
|
||||
<span id="sponsorTimesViewsDisplayEndWord" class="popupElement">
|
||||
__MSG_Segments__.
|
||||
__MSG_savedPeopleFrom__
|
||||
</span>
|
||||
<span id="sponsorTimesViewsDisplayEndWord" class="popupElement">__MSG_Segments__</span>.
|
||||
</span>
|
||||
|
||||
<span id="sponsorTimesOthersTimeSavedContainer" class="popupElement" style="display: none">
|
||||
__MSG_youHaveSavedTime__
|
||||
<span id="sponsorTimesOthersTimeSavedDisplay" class="popupElement">
|
||||
0
|
||||
</span>
|
||||
<span id="sponsorTimesOthersTimeSavedEndWord" class="popupElement">__MSG_minsLower__</span>
|
||||
|
||||
<span class="popupElement">__MSG_youHaveSavedTimeEnd__</span>
|
||||
</span>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<span id="sponsorTimesSkipsDoneContainer" class="popupElement" style="display: none">
|
||||
__MSG_youHaveSkipped__
|
||||
<span id="sponsorTimesSkipsDoneDisplay" class="popupElement">
|
||||
0
|
||||
</span>
|
||||
<span id="sponsorTimesSkipsDoneEndWord" class="popupElement">__MSG_Segments__</span> since December 5th.
|
||||
</span>
|
||||
|
||||
<span id="sponsorTimeSavedContainer" class="popupElement" style="display: none">
|
||||
__MSG_youHaveSaved__
|
||||
<span id="sponsorTimeSavedDisplay" class="popupElement">
|
||||
0
|
||||
</span>
|
||||
<span id="sponsorTimeSavedEndWord" class="popupElement">__MSG_minsLower__</span> since December 5th.
|
||||
</span>
|
||||
|
||||
<div class="popupElement">
|
||||
@@ -176,6 +200,16 @@
|
||||
|
||||
<h3>__MSG_Options__</h3>
|
||||
|
||||
<button id="disableAutoSkip" class="warningButton popupElement">__MSG_disableAutoSkip__</button>
|
||||
<button id="enableAutoSkip" style="display: none" class="warningButton popupElement">__MSG_enableAutoSkip__</button>
|
||||
<br/>
|
||||
<sub class="popupElement">
|
||||
__MSG_autoSkipDescription__
|
||||
</sub>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<span id="keybindButtons">
|
||||
<button id="setStartSponsorKeybind" class="warningButton popupElement">__MSG_setStartSponsorShortcut__</button>
|
||||
<br/>
|
||||
|
||||
100
popup.js
100
popup.js
@@ -34,7 +34,10 @@ function runThePopup() {
|
||||
// More controls
|
||||
"clearTimes",
|
||||
"submitTimes",
|
||||
// options
|
||||
"showNoticeAgain",
|
||||
"disableAutoSkip",
|
||||
"enableAutoSkip",
|
||||
"hideVideoPlayerControls",
|
||||
"showVideoPlayerControls",
|
||||
"hideInfoButtonPlayerControls",
|
||||
@@ -53,6 +56,18 @@ function runThePopup() {
|
||||
"sponsorTimesViewsContainer",
|
||||
"sponsorTimesViewsDisplay",
|
||||
"sponsorTimesViewsDisplayEndWord",
|
||||
// sponsorTimesOthersTimeSaved
|
||||
"sponsorTimesOthersTimeSavedContainer",
|
||||
"sponsorTimesOthersTimeSavedDisplay",
|
||||
"sponsorTimesOthersTimeSavedEndWord",
|
||||
// sponsorTimesSkipsDone
|
||||
"sponsorTimesSkipsDoneContainer",
|
||||
"sponsorTimesSkipsDoneDisplay",
|
||||
"sponsorTimesSkipsDoneEndWord",
|
||||
// sponsorTimeSaved
|
||||
"sponsorTimeSavedContainer",
|
||||
"sponsorTimeSavedDisplay",
|
||||
"sponsorTimeSavedEndWord",
|
||||
// discordButtons
|
||||
"discordButtonContainer",
|
||||
"hideDiscordButton",
|
||||
@@ -89,6 +104,8 @@ function runThePopup() {
|
||||
SB.clearTimes.addEventListener("click", clearTimes);
|
||||
SB.submitTimes.addEventListener("click", submitTimes);
|
||||
SB.showNoticeAgain.addEventListener("click", showNoticeAgain);
|
||||
SB.disableAutoSkip.addEventListener("click", () => setAutoSkip(true));
|
||||
SB.enableAutoSkip.addEventListener("click", () => setAutoSkip(false));
|
||||
SB.setStartSponsorKeybind.addEventListener("click", () => setKeybind(true));
|
||||
SB.setSubmitKeybind.addEventListener("click", () => setKeybind(false));
|
||||
SB.hideVideoPlayerControls.addEventListener("click", hideVideoPlayerControls);
|
||||
@@ -157,6 +174,15 @@ function runThePopup() {
|
||||
SB.showNoticeAgain.style.display = "unset";
|
||||
}
|
||||
});
|
||||
|
||||
//show proper auto skip option
|
||||
chrome.storage.sync.get(["disableAutoSkip"], function(result) {
|
||||
let disableAutoSkip = result.disableAutoSkip;
|
||||
if (disableAutoSkip != undefined && disableAutoSkip) {
|
||||
SB.disableAutoSkip.style.display = "none";
|
||||
SB.enableAutoSkip.style.display = "unset";
|
||||
}
|
||||
});
|
||||
|
||||
//show proper video player controls options
|
||||
chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
|
||||
@@ -222,10 +248,55 @@ function runThePopup() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//get this time in minutes
|
||||
sendRequestToServer("GET", "/api/getSavedTimeForUser?userID=" + userID, function(xmlhttp) {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
let minutesSaved = JSON.parse(xmlhttp.responseText).timeSaved;
|
||||
if (minutesSaved != 0) {
|
||||
if (minutesSaved != 1) {
|
||||
SB.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower");
|
||||
} else {
|
||||
SB.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
|
||||
}
|
||||
|
||||
SB.sponsorTimesOthersTimeSavedDisplay.innerText = getFormattedHours(minutesSaved);
|
||||
SB.sponsorTimesOthersTimeSavedContainer.style.display = "unset";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//get the amount of times this user has skipped a sponsor
|
||||
chrome.storage.sync.get(["skipCount"], function(result) {
|
||||
if (result.skipCount != undefined) {
|
||||
if (result.skipCount != 1) {
|
||||
SB.sponsorTimesSkipsDoneEndWord.innerText = chrome.i18n.getMessage("Sponsors");
|
||||
} else {
|
||||
SB.sponsorTimesSkipsDoneEndWord.innerText = chrome.i18n.getMessage("Sponsor");
|
||||
}
|
||||
|
||||
SB.sponsorTimesSkipsDoneDisplay.innerText = result.skipCount;
|
||||
SB.sponsorTimesSkipsDoneContainer.style.display = "unset";
|
||||
}
|
||||
});
|
||||
|
||||
//get the amount of time this user has saved.
|
||||
chrome.storage.sync.get(["minutesSaved"], function(result) {
|
||||
if (result.minutesSaved != undefined) {
|
||||
if (result.minutesSaved != 1) {
|
||||
SB.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower");
|
||||
} else {
|
||||
SB.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
|
||||
}
|
||||
|
||||
SB.sponsorTimeSavedDisplay.innerText = getFormattedHours(result.minutesSaved);
|
||||
SB.sponsorTimeSavedContainer.style.display = "unset";
|
||||
}
|
||||
});
|
||||
|
||||
chrome.tabs.query({
|
||||
active: true,
|
||||
@@ -830,7 +901,7 @@ function runThePopup() {
|
||||
//treat them the same
|
||||
if (response.statusCode == 503) response.statusCode = 502;
|
||||
|
||||
errorMessage = chrome.i18n.getMessage(response.statusCode + "");
|
||||
errorMessage = chrome.i18n.getMessage(response.statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + response.statusCode;
|
||||
} else {
|
||||
errorMessage = chrome.i18n.getMessage("connectionError") + response.statusCode;
|
||||
}
|
||||
@@ -859,6 +930,21 @@ function runThePopup() {
|
||||
|
||||
SB.showNoticeAgain.style.display = "none";
|
||||
}
|
||||
|
||||
function setAutoSkip(value) {
|
||||
chrome.storage.sync.set({"disableAutoSkip": value});
|
||||
|
||||
if (value) {
|
||||
// If it isn't shown, they can't manually skip
|
||||
showNoticeAgain();
|
||||
|
||||
SB.disableAutoSkip.style.display = "none";
|
||||
SB.enableAutoSkip.style.display = "unset";
|
||||
} else {
|
||||
SB.enableAutoSkip.style.display = "none";
|
||||
SB.disableAutoSkip.style.display = "unset";
|
||||
}
|
||||
}
|
||||
|
||||
function hideVideoPlayerControls() {
|
||||
chrome.storage.sync.set({"hideVideoPlayerControls": true});
|
||||
@@ -1348,6 +1434,18 @@ function runThePopup() {
|
||||
//submit this request
|
||||
xmlhttp.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts time in hours to 5h 25.1
|
||||
* If less than 1 hour, just returns minutes
|
||||
*
|
||||
* @param {float} seconds
|
||||
* @returns {string}
|
||||
*/
|
||||
function getFormattedHours(minues) {
|
||||
let hours = Math.floor(minues / 60);
|
||||
return (hours > 0 ? hours + "h " : "") + (minues % 60).toFixed(1);
|
||||
}
|
||||
|
||||
//end of function
|
||||
}
|
||||
|
||||
@@ -1,10 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
//The notice that tells the user that a sponsor was just skipped
|
||||
/**
|
||||
* The notice that tells the user that a sponsor was just skipped
|
||||
*/
|
||||
class SkipNotice {
|
||||
constructor(parent, UUID) {
|
||||
/**
|
||||
* @param {HTMLElement} parent
|
||||
* @param {String} UUID
|
||||
* @param {String} noticeTitle
|
||||
* @param {boolean} manualSkip
|
||||
*/
|
||||
constructor(parent, UUID, manualSkip = false) {
|
||||
this.parent = parent;
|
||||
this.UUID = UUID;
|
||||
this.manualSkip = manualSkip;
|
||||
|
||||
let noticeTitle = chrome.i18n.getMessage("noticeTitle");
|
||||
|
||||
if (manualSkip) {
|
||||
noticeTitle = chrome.i18n.getMessage("noticeTitleNotSkipped");
|
||||
}
|
||||
|
||||
this.maxCountdownTime = () => 4;
|
||||
//the countdown until this notice closes
|
||||
@@ -54,7 +69,7 @@ class SkipNotice {
|
||||
noticeMessage.id = "sponsorSkipMessage" + this.idSuffix;
|
||||
noticeMessage.classList.add("sponsorSkipMessage");
|
||||
noticeMessage.classList.add("sponsorSkipObject");
|
||||
noticeMessage.innerText = chrome.i18n.getMessage("noticeTitle");
|
||||
noticeMessage.innerText = noticeTitle;
|
||||
|
||||
//create the first column
|
||||
logoColumn.appendChild(logoElement);
|
||||
@@ -136,7 +151,10 @@ class SkipNotice {
|
||||
dontShowAgainButton.className = "sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeRightButton";
|
||||
dontShowAgainButton.addEventListener("click", dontShowNoticeAgain);
|
||||
|
||||
dontshowContainer.appendChild(dontShowAgainButton);
|
||||
// Don't let them hide it if manually skipping
|
||||
if (!this.manualSkip) {
|
||||
dontshowContainer.appendChild(dontShowAgainButton);
|
||||
}
|
||||
|
||||
//add to row
|
||||
secondRow.appendChild(voteButtonsContainer);
|
||||
@@ -165,6 +183,10 @@ class SkipNotice {
|
||||
|
||||
referenceNode.prepend(noticeElement);
|
||||
|
||||
if (manualSkip) {
|
||||
this.unskippedMode(chrome.i18n.getMessage("skip"));
|
||||
}
|
||||
|
||||
this.startCountdown();
|
||||
}
|
||||
|
||||
@@ -228,10 +250,13 @@ class SkipNotice {
|
||||
unskip() {
|
||||
unskipSponsorTime(this.UUID);
|
||||
|
||||
this.unskippedMode(chrome.i18n.getMessage("reskip"));
|
||||
}
|
||||
|
||||
/** Sets up notice to be not skipped yet */
|
||||
unskippedMode(buttonText) {
|
||||
//change unskip button to a reskip button
|
||||
let unskipButton = document.getElementById("sponsorSkipUnskipButton" + this.idSuffix);
|
||||
unskipButton.innerText = chrome.i18n.getMessage("reskip");
|
||||
unskipButton.removeEventListener("click", this.unskipCallback);
|
||||
let unskipButton = this.changeUnskipButton(buttonText);
|
||||
|
||||
//setup new callback
|
||||
this.unskipCallback = this.reskip.bind(this);
|
||||
@@ -252,10 +277,8 @@ class SkipNotice {
|
||||
reskip() {
|
||||
reskipSponsorTime(this.UUID);
|
||||
|
||||
//change unskip button to a reskip button
|
||||
let unskipButton = document.getElementById("sponsorSkipUnskipButton" + this.idSuffix);
|
||||
unskipButton.innerText = chrome.i18n.getMessage("unskip");
|
||||
unskipButton.removeEventListener("click", this.unskipCallback);
|
||||
//change reskip button to a unskip button
|
||||
let unskipButton = this.changeUnskipButton(chrome.i18n.getMessage("unskip"));
|
||||
|
||||
//setup new callback
|
||||
this.unskipCallback = this.unskip.bind(this);
|
||||
@@ -265,6 +288,27 @@ class SkipNotice {
|
||||
this.maxCountdownTime = () => 4;
|
||||
this.countdownTime = this.maxCountdownTime();
|
||||
this.updateTimerDisplay();
|
||||
|
||||
// See if the title should be changed
|
||||
if (this.manualSkip) {
|
||||
this.changeNoticeTitle(chrome.i18n.getMessage("noticeTitle"));
|
||||
|
||||
vote(1, this.UUID, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the text on the reskip button
|
||||
*
|
||||
* @param {string} text
|
||||
* @returns {HTMLElement} unskipButton
|
||||
*/
|
||||
changeUnskipButton(text) {
|
||||
let unskipButton = document.getElementById("sponsorSkipUnskipButton" + this.idSuffix);
|
||||
unskipButton.innerText = text;
|
||||
unskipButton.removeEventListener("click", this.unskipCallback);
|
||||
|
||||
return unskipButton;
|
||||
}
|
||||
|
||||
afterDownvote() {
|
||||
@@ -293,6 +337,12 @@ class SkipNotice {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeNoticeTitle(title) {
|
||||
let noticeElement = document.getElementById("sponsorSkipMessage" + this.idSuffix);
|
||||
|
||||
noticeElement.innerText = title;
|
||||
}
|
||||
|
||||
addNoticeInfoMessage(message, message2) {
|
||||
let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix);
|
||||
|
||||
Reference in New Issue
Block a user