Merge pull request #431 from ajayyy/react

General fixes
This commit is contained in:
Ajay Ramachandran 2020-08-06 22:35:32 -04:00 committed by GitHub
commit df58e3670e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 69 deletions

View file

@ -1,7 +1,7 @@
{
"name": "__MSG_fullName__",
"short_name": "SponsorBlock",
"version": "2.0.4.2",
"version": "2.0.5",
"default_locale": "en",
"description": "__MSG_Description__",
"content_scripts": [{

View file

@ -20,16 +20,16 @@
"message": "Channel Whitelisted!"
},
"Sponsor": {
"message": "sponsor"
"message": "segment"
},
"Sponsors": {
"message": "sponsors"
"message": "segments"
},
"Segment": {
"message": "sponsor segment"
"message": "segment"
},
"Segments": {
"message": "sponsor segments"
"message": "segments"
},
"upvoteButtonInfo": {
"message": "Upvote this submission"
@ -80,16 +80,16 @@
"message": "There was an error submitting your sponsor times, please try again later."
},
"sponsorFound": {
"message": "This video's sponsors are in the database!"
"message": "This video has segments in the database!"
},
"sponsor404": {
"message": "No sponsors found"
"message": "No segments found"
},
"sponsorStart": {
"message": "Sponsorship Starts Now"
"message": "Segment Starts Now"
},
"sponsorEnd": {
"message": "Sponsorship Ends Now"
"message": "Segment Ends Now"
},
"noVideoID": {
"message": "No YouTube video found at this tab. If you know this is a YouTube tab, close this popup and open it again. If that does not work, try reloading the tab."
@ -107,19 +107,19 @@
"message": "A connection error has occured. Error code: "
},
"wantToSubmit": {
"message": "Do you want to submit the sponsor times for video id"
"message": "Do you want to submit for video id"
},
"leftTimes": {
"message": "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted)."
"message": "You seem to have left some segments unsubmitted. Go back to that page to submit them (they are not deleted)."
},
"clearTimes": {
"message": "Clear Sponsor Times"
"message": "Clear Segments"
},
"openPopup": {
"message": "Open SponsorBlock Popup"
},
"SubmitTimes": {
"message": "Submit Sponsor Times"
"message": "Submit Segments"
},
"submitCheck": {
"message": "Are you sure you want to submit this?"
@ -131,10 +131,7 @@
"message": "Remove Channel From Whitelist"
},
"voteOnTime": {
"message": "Vote On A Sponsor Time"
},
"recordTimes": {
"message": "Record the times of a sponsorship"
"message": "Vote On A Segment"
},
"soFarUHSubmited": {
"message": "So far, you've submitted"
@ -149,13 +146,10 @@
"message": "here"
},
"recordTimesDescription": {
"message": "Click the button below when the sponsorship starts and ends to record and\nsubmit it to the database."
"message": "Click the button below when the segment starts and ends to record and submit it to the database."
},
"popupHint": {
"message": "Hint: Press the semicolon key while focused on a video to report the start/end of a sponsor and quote to submit. (This can be changed in the options)"
},
"lastTimes": {
"message": "Latest Sponsor Message Times Chosen"
"message": "Hint: Press the semicolon key while focused on a video to report the start/end of a segment and quote to submit. (This can be changed in the options)"
},
"clearTimesButton": {
"message": "Clear Times"
@ -205,20 +199,17 @@
"whatDeleteButton": {
"message": "This is the button on the YouTube player that will clear all your un-submitted segments for the current video."
},
"disableViewTracking": {
"message": "Disable Sponsor Skip Count Tracking"
},
"enableViewTracking": {
"message": "Enable Sponsor Skip Count Tracking"
"message": "Enable 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. :)"
"message": "This feature tracks which segments you have skipped to let users know how much their submission has helped others and used as a metric along with upvotes to ensure that spam doesn't get into the database. The extension sends a message to the server each time you skip a segment. Hopefully most people don't change this setting so that the view numbers are accurate. :)"
},
"showNotice": {
"message": "Show Notice Again"
},
"longDescription": {
"message": "SponsorBlock lets you skip over sponsors, intros, outros subscription reminders, and other annoying parts of YouTube videos. SponsorBlock is a crowdsourced browser extension that let's anyone submit the start and end time's of sponsored segments and other segments of YouTube videos. Once one person submits this information, everyone else with this extension will skip right over the sponsored segment. You can also skip over non music sections of music videos.",
"message": "SponsorBlock lets you skip over sponsors, intros, outros, subscription reminders, and other annoying parts of YouTube videos. SponsorBlock is a crowdsourced browser extension that let's anyone submit the start and end time's of sponsored segments and other segments of YouTube videos. Once one person submits this information, everyone else with this extension will skip right over the sponsored segment. You can also skip over non music sections of music videos.",
"description": "Full description of the extension on the store pages."
},
"website": {
@ -238,7 +229,7 @@
"description": "The second line of the message displayed after the notice was upgraded."
},
"setStartSponsorShortcut": {
"message": "Set key for start sponsor keybind"
"message": "Set key for start segment keybind"
},
"setSubmitKeybind": {
"message": "Set key for submission keybind"
@ -280,14 +271,11 @@
"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."
},
"audioNotification": {
"message": "Audio Notification On Skip"
},
"audioNotificationDescription": {
"message": "Audio notification on skip will play a sound whenever a sponsor is skipped. If disabled (or auto skip is disabled), no sound will be played."
"message": "Audio notification on skip will play a sound whenever a segment is skipped. If disabled (or auto skip is disabled), no sound will be played."
},
"showTimeWithSkips": {
"message": "Show Time With Skips Removed"
@ -319,9 +307,6 @@
"youHaveSavedTimeEnd": {
"message": " of their lives."
},
"guildlinesSummary": {
"message": "- Make sure your segment only contains paid promotion segment, nothing else.\n- Make sure skipping this segment will not skip valuable content\n- If the whole video is a sponsor, please do not report it. A full video reporting system will come out soon.\n- Please do not report disclaimers that could show bias (if a review video is sponsored, don't skip when they mention that)."
},
"statusReminder": {
"message": "Check status.sponsor.ajay.app for server status."
},
@ -344,7 +329,7 @@
"message": "Auto Skip"
},
"showSkipNotice": {
"message": "Show Notice After A Sponsor Is Skipped"
"message": "Show Notice After A Segment Is Skipped"
},
"keybindCurrentlySet": {
"message": ". It is currently set to:"
@ -383,7 +368,7 @@
"message": "Minimum duration (seconds):"
},
"minDurationDescription": {
"message": "Sponsor segments shorter than the set value will not be skipped or show in the player."
"message": "Segments shorter than the set value will not be skipped or show in the player."
},
"shortCheck": {
"message": "The following submission is shorter than your minimum duration option. This could mean that this is already submitted, and just being ignored due to this option. Are you sure you would like to submit?"
@ -413,13 +398,13 @@
"message": "Are you sure you would like to reset this?"
},
"confirmPrivacy": {
"message": "The video has been detected as unlisted. Click cancel if you do not want to check for sponsors."
"message": "The video has been detected as unlisted. Click cancel if you do not want to check for skip segments."
},
"unlistedCheck": {
"message": "Ignore Unlisted/Private Videos"
},
"whatUnlistedCheck": {
"message": "This setting will slightly slow down SponsorBlock. Sponsor lookups require sending the video ID to the server. If you are concerned about unlisted video IDs being sent over the internet, enable this option."
"message": "This setting will slightly slow down SponsorBlock. Skip segment lookups require sending the video ID to the server. If you are concerned about unlisted video IDs being sent over the internet, enable this option."
},
"mobileUpdateInfo": {
"message": "m.youtube.com is now supported"
@ -477,7 +462,7 @@
},
"to": {
"message": "to",
"description": "Used between sponsor times. Example: 1:20 to 1:30"
"description": "Used between segments. Example: 1:20 to 1:30"
},
"category_sponsor": {
"message": "Sponsor"
@ -498,7 +483,7 @@
"message": "Endcards/Credits"
},
"category_outro_description": {
"message": "Credits or when the YouTube endcards appear. Not for spoken conclusions. This should not include useful content. This should not be used on music videos."
"message": "Credits or when the YouTube endcards appear. Not for conclusions with information. This should not be used on music videos."
},
"category_interaction": {
"message": "Interaction Reminder (Subscribe)"
@ -596,13 +581,13 @@
"message": "If this keeps occuring, it could be caused by your ad blocker. Please check https://github.com/ajayyy/SponsorBlock/wiki/Fix-Ad-Blocker-Blocking-SponsorBlock's-Requests"
},
"forceChannelCheck": {
"message": "Force Channel Check Before Skipping Sponsors"
"message": "Force Channel Check Before Skipping"
},
"whatForceChannelCheck": {
"message": "By default, it will skip sponsors right away before it even knows what the channel is. By default, some zero second sponsors might be skipped on whitelisted channels. Enabling this option will prevent this but making all skipping have a slight delay as getting the channelID can take some time. This delay might be unnoticeable if you have fast internet."
"message": "By default, it will skip segments right away before it even knows what the channel is. By default, some segments at the start of the video might be skipped on whitelisted channels. Enabling this option will prevent this but making all skipping have a slight delay as getting the channelID can take some time. This delay might be unnoticeable if you have fast internet."
},
"forceChannelCheckPopup": {
"message": "Consider Enabling Force Channel Check Before Skipping Sponsors"
"message": "Consider Enabling \"Force Channel Check Before Skipping\""
},
"downvoteDescription": {
"message": "Incorrect/Wrong Timing"

View file

@ -38,8 +38,6 @@
<sub class="popupElement">__MSG_popupHint__</sub>
<div id="submissionSection" class="popupElement" style="display: none">
<h3 class="popupElement">__MSG_lastTimes__</h3>
<b>Sponsor Editing has been moved and will appear after you click submit</b>
<br/>

View file

@ -448,7 +448,7 @@ function cancelSponsorSchedule(): void {
*
* @param currentTime Optional if you don't want to use the actual current time
*/
function startSponsorSchedule(includeIntersectingSegments: boolean = false, currentTime?: number): void {
function startSponsorSchedule(includeIntersectingSegments = false, currentTime?: number, includeNonIntersectingSegments = true): void {
cancelSponsorSchedule();
// Don't skip if advert playing and reset last checked time
@ -470,7 +470,7 @@ function startSponsorSchedule(includeIntersectingSegments: boolean = false, curr
if (currentTime === undefined || currentTime === null) currentTime = video.currentTime;
let skipInfo = getNextSkipIndex(currentTime, includeIntersectingSegments);
let skipInfo = getNextSkipIndex(currentTime, includeIntersectingSegments, includeNonIntersectingSegments);
if (skipInfo.index === -1) return;
@ -499,6 +499,7 @@ function startSponsorSchedule(includeIntersectingSegments: boolean = false, curr
let skippingFunction = () => {
let forcedSkipTime: number = null;
let forcedIncludeIntersectingSegments = false;
let forcedIncludeNonIntersectingSegments = true;
if (incorrectVideoCheck(videoID, currentSkip)) return;
@ -510,10 +511,11 @@ function startSponsorSchedule(includeIntersectingSegments: boolean = false, curr
} else {
forcedSkipTime = skipTime[1];
forcedIncludeIntersectingSegments = true;
forcedIncludeNonIntersectingSegments = false;
}
}
startSponsorSchedule(forcedIncludeIntersectingSegments, forcedSkipTime);
startSponsorSchedule(forcedIncludeIntersectingSegments, forcedSkipTime, forcedIncludeNonIntersectingSegments);
};
if (timeUntilSponsor <= 0) {
@ -566,8 +568,9 @@ function sponsorsLookup(id: string) {
// Check if an ad is playing
updateAdFlag();
// Make sure it doesn't get double called with the playing event
if (lastCheckVideoTime !== video.currentTime && Date.now() - lastCheckTime > 2000) {
// Make sure it doesn't get double called with the playing event
if (Math.abs(lastCheckVideoTime - video.currentTime) > 0.3
|| (lastCheckVideoTime !== video.currentTime && Date.now() - lastCheckTime > 2000)) {
lastCheckTime = Date.now();
lastCheckVideoTime = video.currentTime;
@ -577,7 +580,8 @@ function sponsorsLookup(id: string) {
});
video.addEventListener('playing', () => {
// Make sure it doesn't get double called with the play event
if (lastCheckVideoTime !== video.currentTime && Date.now() - lastCheckTime > 2000) {
if (Math.abs(lastCheckVideoTime - video.currentTime) > 0.3
|| (lastCheckVideoTime !== video.currentTime && Date.now() - lastCheckTime > 2000)) {
lastCheckTime = Date.now();
lastCheckVideoTime = video.currentTime;
@ -585,11 +589,11 @@ function sponsorsLookup(id: string) {
}
});
video.addEventListener('seeking', () => {
// Reset lastCheckVideoTime
lastCheckVideoTime = -1
lastCheckTime = 0;
if (!video.paused){
// Reset lastCheckVideoTime
lastCheckTime = Date.now();
lastCheckVideoTime = video.currentTime;
startSponsorSchedule();
}
});
@ -714,7 +718,7 @@ function startSkipScheduleCheckingForStartSponsors() {
}
if (startingSponsor !== -1) {
startSponsorSchedule(false, startingSponsor);
startSponsorSchedule(undefined, startingSponsor);
} else {
startSponsorSchedule();
}
@ -843,23 +847,23 @@ function whitelistCheck() {
}
// check if the start of segments were missed
if (sponsorTimes && sponsorTimes.length > 0) startSkipScheduleCheckingForStartSponsors();
if (Config.config.forceChannelCheck && sponsorTimes && sponsorTimes.length > 0) startSkipScheduleCheckingForStartSponsors();
}
/**
* Returns info about the next upcoming sponsor skip
*/
function getNextSkipIndex(currentTime: number, includeIntersectingSegments: boolean):
function getNextSkipIndex(currentTime: number, includeIntersectingSegments: boolean, includeNonIntersectingSegments: boolean):
{array: SponsorTime[], index: number, endIndex: number, openNotice: boolean} {
let sponsorStartTimes = getStartTimes(sponsorTimes, includeIntersectingSegments);
let sponsorStartTimesAfterCurrentTime = getStartTimes(sponsorTimes, includeIntersectingSegments, currentTime, true, true);
let sponsorStartTimes = getStartTimes(sponsorTimes, includeIntersectingSegments, includeNonIntersectingSegments);
let sponsorStartTimesAfterCurrentTime = getStartTimes(sponsorTimes, includeIntersectingSegments, includeNonIntersectingSegments, currentTime, true, true);
let minSponsorTimeIndex = sponsorStartTimes.indexOf(Math.min(...sponsorStartTimesAfterCurrentTime));
let endTimeIndex = getLatestEndTimeIndex(sponsorTimes, minSponsorTimeIndex);
let previewSponsorStartTimes = getStartTimes(sponsorTimesSubmitting, includeIntersectingSegments);
let previewSponsorStartTimesAfterCurrentTime = getStartTimes(sponsorTimesSubmitting, includeIntersectingSegments, currentTime, false, false);
let previewSponsorStartTimes = getStartTimes(sponsorTimesSubmitting, includeIntersectingSegments, includeNonIntersectingSegments);
let previewSponsorStartTimesAfterCurrentTime = getStartTimes(sponsorTimesSubmitting, includeIntersectingSegments, includeNonIntersectingSegments, currentTime, false, false);
let minPreviewSponsorTimeIndex = previewSponsorStartTimes.indexOf(Math.min(...previewSponsorStartTimesAfterCurrentTime));
let previewEndTimeIndex = getLatestEndTimeIndex(sponsorTimesSubmitting, minPreviewSponsorTimeIndex);
@ -933,14 +937,16 @@ function getLatestEndTimeIndex(sponsorTimes: SponsorTime[], index: number, hideH
* @param includeIntersectingSegments If true, it will include segments that start before
* the current time, but end after
*/
function getStartTimes(sponsorTimes: SponsorTime[], includeIntersectingSegments: boolean, minimum?: number,
onlySkippableSponsors: boolean = false, hideHiddenSponsors: boolean = false): number[] {
function getStartTimes(sponsorTimes: SponsorTime[], includeIntersectingSegments: boolean, includeNonIntersectingSegments: boolean,
minimum?: number, onlySkippableSponsors: boolean = false, hideHiddenSponsors: boolean = false): number[] {
if (sponsorTimes === null) return [];
let startTimes: number[] = [];
for (let i = 0; i < sponsorTimes?.length; i++) {
if ((minimum === undefined || (sponsorTimes[i].segment[0] >= minimum || (includeIntersectingSegments && sponsorTimes[i].segment[1] > minimum)))
if ((minimum === undefined
|| ((includeNonIntersectingSegments && sponsorTimes[i].segment[0] >= minimum)
|| (includeIntersectingSegments && sponsorTimes[i].segment[0] < minimum && sponsorTimes[i].segment[1] > minimum)))
&& (!onlySkippableSponsors || utils.getCategorySelection(sponsorTimes[i].category).option !== CategorySkipOption.ShowOverlay)
&& (!hideHiddenSponsors || sponsorTimes[i].hidden === SponsorHideType.Visible)) {
@ -970,7 +976,7 @@ function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: S
// There will only be one submission if it is manual skip
let autoSkip: boolean = utils.getCategorySelection(skippingSegments[0].category)?.option === CategorySkipOption.AutoSkip;
if (autoSkip || sponsorTimesSubmitting.includes(skippingSegments[0])) {
if ((autoSkip || sponsorTimesSubmitting.includes(skippingSegments[0])) && v.currentTime !== skipTime[1]) {
v.currentTime = skipTime[1];
}
@ -1604,5 +1610,5 @@ function showTimeWithoutSkips(allSponsorTimes): void {
display.appendChild(duration);
}
duration.innerText = (skipDuration <= 0 || isNaN(skipDuration)) ? "" : " ("+formatedTime+")";
duration.innerText = (skipDuration <= 0 || isNaN(skipDuration) || formatedTime.includes("NaN")) ? "" : " ("+formatedTime+")";
}