Merge pull request #414 from ajayyy/react

Improvements
This commit is contained in:
Ajay Ramachandran
2020-07-18 22:11:44 -04:00
committed by GitHub
3 changed files with 13 additions and 13 deletions

View File

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

View File

@@ -4,7 +4,7 @@
"description": "Name of the extension." "description": "Name of the extension."
}, },
"Description": { "Description": {
"message": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", "message": "Skip sponsorships, subscription begging and more on YouTube videos. Report sponsors on videos you watch to save others' time.",
"description": "Description of the extension." "description": "Description of the extension."
}, },
"400": { "400": {
@@ -218,7 +218,7 @@
"message": "Show Notice Again" "message": "Show Notice Again"
}, },
"longDescription": { "longDescription": {
"message": "SponsorBlock is an extension that will skip over sponsored segments of YouTube videos. SponsorBlock is a crowdsourced browser extension that lets anyone submit the start and end times of sponsored segments of YouTube videos. Once one person submits this information, everyone else with this extension will skip right over the sponsored segment. \n\n You can also skip intros, outros, reminders to subscribe and other categories.", "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." "description": "Full description of the extension on the store pages."
}, },
"website": { "website": {

View File

@@ -493,7 +493,8 @@ function startSponsorSchedule(includeIntersectingSegments: boolean = false, curr
} }
// Don't skip if this category should not be skipped // Don't skip if this category should not be skipped
if (utils.getCategorySelection(currentSkip.category).option === CategorySkipOption.ShowOverlay) return; if (utils.getCategorySelection(currentSkip.category)?.option === CategorySkipOption.ShowOverlay
&& skipInfo.array !== sponsorTimesSubmitting) return;
let skippingFunction = () => { let skippingFunction = () => {
let forcedSkipTime: number = null; let forcedSkipTime: number = null;
@@ -504,8 +505,7 @@ function startSponsorSchedule(includeIntersectingSegments: boolean = false, curr
if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) { if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) {
skipToTime(video, skipTime, skippingSegments, skipInfo.openNotice); skipToTime(video, skipTime, skippingSegments, skipInfo.openNotice);
// TODO: Know the autoSkip settings for ALL items being skipped if (utils.getCategorySelection(currentSkip.category)?.option === CategorySkipOption.ManualSkip) {
if (utils.getCategorySelection(currentSkip.category).option === CategorySkipOption.ManualSkip) {
forcedSkipTime = skipTime[0] + 0.001; forcedSkipTime = skipTime[0] + 0.001;
} else { } else {
forcedSkipTime = skipTime[1]; forcedSkipTime = skipTime[1];
@@ -618,7 +618,7 @@ function sponsorsLookup(id: string) {
videoID: id, videoID: id,
categories categories
}).then(async (response: FetchResponse) => { }).then(async (response: FetchResponse) => {
if (response.ok) { if (response?.ok) {
let recievedSegments: SponsorTime[] = JSON.parse(response.responseText); let recievedSegments: SponsorTime[] = JSON.parse(response.responseText);
if (!recievedSegments.length) { if (!recievedSegments.length) {
console.error("[SponsorBlock] Server returned malformed response: " + JSON.stringify(recievedSegments)); console.error("[SponsorBlock] Server returned malformed response: " + JSON.stringify(recievedSegments));
@@ -662,7 +662,7 @@ function sponsorsLookup(id: string) {
} }
sponsorLookupRetries = 0; sponsorLookupRetries = 0;
} else if (response.status === 404) { } else if (response?.status === 404) {
sponsorDataFound = false; sponsorDataFound = false;
//check if this video was uploaded recently //check if this video was uploaded recently
@@ -897,13 +897,13 @@ function getNextSkipIndex(currentTime: number, includeIntersectingSegments: bool
*/ */
function getLatestEndTimeIndex(sponsorTimes: SponsorTime[], index: number, hideHiddenSponsors: boolean = true): number { function getLatestEndTimeIndex(sponsorTimes: SponsorTime[], index: number, hideHiddenSponsors: boolean = true): number {
// Only combine segments for AutoSkip // Only combine segments for AutoSkip
if (index == -1 || if (index == -1 ||
utils.getCategorySelection(sponsorTimes[index].category).option !== CategorySkipOption.AutoSkip) return index; utils.getCategorySelection(sponsorTimes[index].category)?.option !== CategorySkipOption.AutoSkip) return index;
// Default to the normal endTime // Default to the normal endTime
let latestEndTimeIndex = index; let latestEndTimeIndex = index;
for (let i = 0; i < sponsorTimes.length; i++) { for (let i = 0; i < sponsorTimes?.length; i++) {
let currentSegment = sponsorTimes[i].segment; let currentSegment = sponsorTimes[i].segment;
let latestEndTime = sponsorTimes[latestEndTimeIndex].segment[1]; let latestEndTime = sponsorTimes[latestEndTimeIndex].segment[1];
@@ -939,7 +939,7 @@ function getStartTimes(sponsorTimes: SponsorTime[], includeIntersectingSegments:
let startTimes: number[] = []; let startTimes: number[] = [];
for (let i = 0; i < sponsorTimes.length; i++) { 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 || (sponsorTimes[i].segment[0] >= minimum || (includeIntersectingSegments && sponsorTimes[i].segment[1] > minimum)))
&& (!onlySkippableSponsors || utils.getCategorySelection(sponsorTimes[i].category).option !== CategorySkipOption.ShowOverlay) && (!onlySkippableSponsors || utils.getCategorySelection(sponsorTimes[i].category).option !== CategorySkipOption.ShowOverlay)
&& (!hideHiddenSponsors || sponsorTimes[i].hidden === SponsorHideType.Visible)) { && (!hideHiddenSponsors || sponsorTimes[i].hidden === SponsorHideType.Visible)) {
@@ -968,7 +968,7 @@ function previewTime(time: number) {
//skip from the start time to the end time for a certain index sponsor time //skip from the start time to the end time for a certain index sponsor time
function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: SponsorTime[], openNotice: boolean) { function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: SponsorTime[], openNotice: boolean) {
// There will only be one submission if it is manual skip // There will only be one submission if it is manual skip
let autoSkip: boolean = utils.getCategorySelection(skippingSegments[0].category).option === CategorySkipOption.AutoSkip; 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];