This commit is contained in:
Ajay
2022-05-24 14:04:54 -04:00
11 changed files with 80 additions and 77 deletions

View File

@@ -21,6 +21,7 @@ module.exports = {
}, },
plugins: ["react", "@typescript-eslint"], plugins: ["react", "@typescript-eslint"],
rules: { rules: {
'@typescript-eslint/no-unused-vars': 'error',
// TODO: Remove warn rules when not needed anymore // TODO: Remove warn rules when not needed anymore
"no-self-assign": "off", "no-self-assign": "off",
"@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-empty-interface": "off",

View File

@@ -1,7 +1,7 @@
{ {
"name": "__MSG_fullName__", "name": "__MSG_fullName__",
"short_name": "SponsorBlock", "short_name": "SponsorBlock",
"version": "4.4.2", "version": "4.4.3",
"default_locale": "en", "default_locale": "en",
"description": "__MSG_Description__", "description": "__MSG_Description__",
"homepage_url": "https://sponsor.ajay.app", "homepage_url": "https://sponsor.ajay.app",

View File

@@ -101,7 +101,7 @@
"message": "It seems the server is down. Contact the dev immediately." "message": "It seems the server is down. Contact the dev immediately."
}, },
"connectionError": { "connectionError": {
"message": "A connection error has occured. Error code: " "message": "A connection error has occurred. Error code: "
}, },
"clearTimes": { "clearTimes": {
"message": "Clear Segments" "message": "Clear Segments"
@@ -356,7 +356,7 @@
"message": "Show Time With Skips Removed" "message": "Show Time With Skips Removed"
}, },
"showTimeWithSkipsDescription": { "showTimeWithSkipsDescription": {
"message": "This time appears in brackets next to the current time on below the seekbar. This shows the total video duration minus any segments. This includes segments marked as only \"Show In Seekbar\"." "message": "This time appears in brackets next to the current time on below the Seek Bar. This shows the total video duration minus any segments. This includes segments marked as only \"Show In Seek Bar\"."
}, },
"youHaveSkipped": { "youHaveSkipped": {
"message": "You've skipped " "message": "You've skipped "
@@ -410,7 +410,7 @@
"message": "Supported Sites: " "message": "Supported Sites: "
}, },
"optionsInfo": { "optionsInfo": {
"message": "Enable Invidious support, disable autoskip, hide buttons and more." "message": "Enable Invidious support, disable auto skip, hide buttons and more."
}, },
"addInvidiousInstance": { "addInvidiousInstance": {
"message": "Add 3rd-Party Client Instance" "message": "Add 3rd-Party Client Instance"
@@ -499,7 +499,7 @@
"incorrectlyFormattedOptions": { "incorrectlyFormattedOptions": {
"message": "This JSON is not formatted correctly. Your options have not been changed." "message": "This JSON is not formatted correctly. Your options have not been changed."
}, },
"confirmNoticeTitle" : { "confirmNoticeTitle": {
"message": "Submit Segment" "message": "Submit Segment"
}, },
"submit": { "submit": {
@@ -947,5 +947,11 @@
}, },
"openOptionsPage": { "openOptionsPage": {
"message": "Open options page" "message": "Open options page"
},
"resetToDefault": {
"message": "Reset settings to default"
},
"confirmResetToDefault": {
"message": "Are you sure you want to reset all settings to their default values? This cannot be undone."
} }
} }

View File

@@ -186,7 +186,7 @@
"message": "Detta döljer knapparna på YouTube-spelaren som du kan skicka in segment med som ska hoppas över." "message": "Detta döljer knapparna på YouTube-spelaren som du kan skicka in segment med som ska hoppas över."
}, },
"showSkipButton": { "showSkipButton": {
"message": "Behåll knappen hoppa till markerat på spelaren" "message": "Behåll knappen hoppa till höjdpunkt på spelaren"
}, },
"showInfoButton": { "showInfoButton": {
"message": "Visa Infoknapp På YouTube-spelaren" "message": "Visa Infoknapp På YouTube-spelaren"
@@ -613,7 +613,7 @@
"message": "Icke-musik" "message": "Icke-musik"
}, },
"category_poi_highlight": { "category_poi_highlight": {
"message": "Markera" "message": "Höjdpunkt"
}, },
"category_poi_highlight_description": { "category_poi_highlight_description": {
"message": "Den del av videon som de flesta letar efter. Liknande kommentarer \"Video börjar på x\"." "message": "Den del av videon som de flesta letar efter. Liknande kommentarer \"Video börjar på x\"."

View File

@@ -368,6 +368,12 @@
</div> </div>
</div> </div>
<div data-type="button-press" data-sync="resetToDefault" data-confirm-message="confirmResetToDefault">
<div class="option-button trigger-button">
__MSG_resetToDefault__
</div>
</div>
</div> </div>
<div id="advanced" class="option-group hidden"> <div id="advanced" class="option-group hidden">

View File

@@ -1,7 +1,7 @@
import * as React from "react"; import * as React from "react";
import * as CompileConfig from "../../config.json"; import * as CompileConfig from "../../config.json";
import Config from "../config" import Config from "../config"
import { Category, ContentContainer, SponsorHideType, SponsorTime, NoticeVisbilityMode, ActionType, SponsorSourceType, SegmentUUID } from "../types"; import { Category, ContentContainer, SponsorTime, NoticeVisbilityMode, ActionType, SponsorSourceType, SegmentUUID } from "../types";
import NoticeComponent from "./NoticeComponent"; import NoticeComponent from "./NoticeComponent";
import NoticeTextSelectionComponent from "./NoticeTextSectionComponent"; import NoticeTextSelectionComponent from "./NoticeTextSectionComponent";
import Utils from "../utils"; import Utils from "../utils";

View File

@@ -1,6 +1,4 @@
import * as React from "react"; import * as React from "react";
import Config from "../config";
import { Category, SegmentUUID, SponsorTime } from "../types";
export interface TooltipProps { export interface TooltipProps {
text: string; text: string;

View File

@@ -1,6 +1,6 @@
import * as CompileConfig from "../config.json"; import * as CompileConfig from "../config.json";
import * as invidiousList from "../ci/invidiouslist.json"; import * as invidiousList from "../ci/invidiouslist.json";
import { Category, CategorySelection, CategorySkipOption, NoticeVisbilityMode, PreviewBarOption, SponsorTime, StorageChangesObject, UnEncodedSegmentTimes as UnencodedSegmentTimes, Keybind, HashedValue, VideoID, SponsorHideType } from "./types"; import { Category, CategorySelection, CategorySkipOption, NoticeVisbilityMode, PreviewBarOption, SponsorTime, StorageChangesObject, Keybind, HashedValue, VideoID, SponsorHideType } from "./types";
import { keybindEquals } from "./utils/configUtils"; import { keybindEquals } from "./utils/configUtils";
interface SBConfig { interface SBConfig {
@@ -113,6 +113,7 @@ export interface SBObject {
local: SBStorage; local: SBStorage;
forceSyncUpdate(prop: string): void; forceSyncUpdate(prop: string): void;
forceLocalUpdate(prop: string): void; forceLocalUpdate(prop: string): void;
resetToDefault(): void;
} }
const Config: SBObject = { const Config: SBObject = {
@@ -289,7 +290,8 @@ const Config: SBObject = {
config: null, config: null,
local: null, local: null,
forceSyncUpdate, forceSyncUpdate,
forceLocalUpdate forceLocalUpdate,
resetToDefault
}; };
// Function setup // Function setup
@@ -522,6 +524,16 @@ function addDefaults() {
} }
} }
function resetToDefault() {
chrome.storage.sync.set({
...Config.syncDefaults,
userID: Config.config.userID,
minutesSaved: Config.config.minutesSaved,
skipCount: Config.config.skipCount,
sponsorTimesContributed: Config.config.sponsorTimesContributed
});
}
// Sync config // Sync config
setupConfig(); setupConfig();

View File

@@ -321,9 +321,6 @@ async function videoIDChange(id) {
} }
} }
// Get new video info
// getVideoInfo(); // Seems to have been replaced
// Update whitelist data when the video data is loaded // Update whitelist data when the video data is loaded
whitelistCheck(); whitelistCheck();
@@ -942,12 +939,10 @@ function startSkipScheduleCheckingForStartSponsors() {
// See if there are any starting sponsors // See if there are any starting sponsors
let startingSegmentTime = getStartTimeFromUrl(document.URL) || -1; let startingSegmentTime = getStartTimeFromUrl(document.URL) || -1;
let found = false; let found = false;
let startingSegment: SponsorTime = null;
for (const time of sponsorTimes) { for (const time of sponsorTimes) {
if (time.segment[0] <= video.currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > video.currentTime if (time.segment[0] <= video.currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > video.currentTime
&& time.actionType !== ActionType.Poi) { && time.actionType !== ActionType.Poi) {
startingSegmentTime = time.segment[0]; startingSegmentTime = time.segment[0];
startingSegment = time;
found = true; found = true;
break; break;
} }
@@ -957,7 +952,6 @@ function startSkipScheduleCheckingForStartSponsors() {
if (time.segment[0] <= video.currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > video.currentTime if (time.segment[0] <= video.currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > video.currentTime
&& time.actionType !== ActionType.Poi) { && time.actionType !== ActionType.Poi) {
startingSegmentTime = time.segment[0]; startingSegmentTime = time.segment[0];
startingSegment = time;
found = true; found = true;
break; break;
} }
@@ -995,26 +989,6 @@ function startSkipScheduleCheckingForStartSponsors() {
} }
} }
/**
* Get the video info for the current tab from YouTube
*
* TODO: Replace
*/
async function getVideoInfo(): Promise<void> {
const result = await utils.asyncRequestToCustomServer("GET", "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID + "&html5=1&c=TVHTML5&cver=7.20190319");
if (result.ok) {
const decodedData = decodeURIComponent(result.responseText).match(/player_response=([^&]*)/)[1];
if (!decodedData) {
console.error("[SB] Failed at getting video info from YouTube.");
console.error("[SB] Data returned from YouTube: " + result.responseText);
return;
}
videoInfo = JSON.parse(decodedData);
}
}
function getYouTubeVideoID(document: Document): string | boolean { function getYouTubeVideoID(document: Document): string | boolean {
const url = document.URL; const url = document.URL;
// clips should never skip, going from clip to full video has no indications. // clips should never skip, going from clip to full video has no indications.

View File

@@ -2,10 +2,7 @@ import Config from "../config";
import { SponsorTime } from "../types"; import { SponsorTime } from "../types";
import { getSkippingText } from "../utils/categoryUtils"; import { getSkippingText } from "../utils/categoryUtils";
import { keybindToString } from "../utils/configUtils"; import { keybindToString } from "../utils/configUtils";
import Utils from "../utils";
import { AnimationUtils } from "../utils/animationUtils"; import { AnimationUtils } from "../utils/animationUtils";
const utils = new Utils();
export interface SkipButtonControlBarProps { export interface SkipButtonControlBarProps {
skip: (segment: SponsorTime) => void; skip: (segment: SponsorTime) => void;
@@ -220,4 +217,3 @@ export class SkipButtonControlBar {
this.container.style.left = this.left + "px"; this.container.style.left = this.left + "px";
} }
} }

View File

@@ -232,12 +232,22 @@ async function init() {
} }
case "button-press": { case "button-press": {
const actionButton = optionsElements[i].querySelector(".trigger-button"); const actionButton = optionsElements[i].querySelector(".trigger-button");
const confirmMessage = optionsElements[i].getAttribute("data-confirm-message");
switch(optionsElements[i].getAttribute("data-sync")) { actionButton.addEventListener("click", () => {
if (confirmMessage !== null && !confirm(chrome.i18n.getMessage(confirmMessage))) {
return;
}
switch (optionsElements[i].getAttribute("data-sync")) {
case "copyDebugInformation": case "copyDebugInformation":
actionButton.addEventListener("click", copyDebugOutputToClipboard); copyDebugOutputToClipboard();
break;
case "resetToDefault":
Config.resetToDefault();
window.location.reload();
break; break;
} }
});
break; break;
} }