diff options
author | Max Baumann <[email protected]> | 2020-12-15 19:54:33 +0100 |
---|---|---|
committer | Max Baumann <[email protected]> | 2020-12-15 19:54:33 +0100 |
commit | c0d910decd4c088989d42a6473ba84721babbf36 (patch) | |
tree | c80a391a4f9bc4bde11429f9d7f368b71664177e | |
parent | 09c527417def476887de7d8344686d857e5ad87c (diff) | |
download | SponsorBlock-c0d910decd4c088989d42a6473ba84721babbf36.tar.gz SponsorBlock-c0d910decd4c088989d42a6473ba84721babbf36.zip |
refactor: more types and dead code removal
-rw-r--r-- | src/content.ts | 10 | ||||
-rw-r--r-- | src/js-components/previewBar.ts | 14 | ||||
-rw-r--r-- | src/options.ts | 4 | ||||
-rw-r--r-- | src/popup.ts | 2 | ||||
-rw-r--r-- | src/types.ts | 6 |
5 files changed, 18 insertions, 18 deletions
diff --git a/src/content.ts b/src/content.ts index 1e5743b1..8f895cd5 100644 --- a/src/content.ts +++ b/src/content.ts @@ -27,7 +27,7 @@ let sponsorVideoID: VideoID = null; // JSON video info let videoInfo: VideoInfo = null; //the channel this video is about -let channelID; +let channelID: string; // Skips are scheduled to ensure precision. // Skips are rescheduled every seeking event. @@ -112,7 +112,7 @@ const skipNoticeContentContainer: ContentContainer = () => ({ //get messages from the background script and the popup chrome.runtime.onMessage.addListener(messageListener); -function messageListener(request: any, sender: any, sendResponse: (response: any) => void): void { +function messageListener(request: any, sender: unknown, sendResponse: (response: any) => void): void { //messages from popup script switch(request.message){ case "update": @@ -363,7 +363,7 @@ function handleMobileControlsMutations(): void { if (previewBar !== null) { if (document.body.contains(previewBar.container)) { - updatePreviewBarPositionMobile(document.getElementsByClassName(mobileYouTubeSelector)[0]); + updatePreviewBarPositionMobile(document.getElementsByClassName(mobileYouTubeSelector)[0] as HTMLElement); return; } else { @@ -397,7 +397,7 @@ function createPreviewBar(): void { const el = document.querySelectorAll(selector); if (el && el.length && el[0]) { - previewBar = new PreviewBar(el[0], onMobileYouTube, onInvidious); + previewBar = new PreviewBar(el[0] as HTMLElement, onMobileYouTube, onInvidious); updatePreviewBar(); @@ -798,7 +798,7 @@ function getYouTubeVideoID(url: string) { /** * This function is required on mobile YouTube and will keep getting called whenever the preview bar disapears */ -function updatePreviewBarPositionMobile(parent: Element) { +function updatePreviewBarPositionMobile(parent: HTMLElement) { if (document.getElementById("previewbar") === null) { previewBar.updatePosition(parent); } diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index f5ab07fa..a1f4e2c3 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -11,14 +11,14 @@ const utils = new Utils(); class PreviewBar { container: HTMLUListElement; - parent: any; + parent: HTMLElement; onMobileYouTube: boolean; onInvidious: boolean; timestamps: number[][]; types: string[]; - constructor(parent: any, onMobileYouTube: boolean, onInvidious: boolean) { + constructor(parent: HTMLElement, onMobileYouTube: boolean, onInvidious: boolean) { this.container = document.createElement('ul'); this.container.id = 'previewbar'; this.parent = parent; @@ -47,16 +47,16 @@ class PreviewBar { let mouseOnSeekBar = false; - seekBar.addEventListener("mouseenter", (event) => { + seekBar.addEventListener("mouseenter", () => { mouseOnSeekBar = true; }); - seekBar.addEventListener("mouseleave", (event) => { + seekBar.addEventListener("mouseleave", () => { mouseOnSeekBar = false; categoryTooltip.classList.add("sbHidden"); }); - const observer = new MutationObserver((mutations, observer) => { + const observer = new MutationObserver((mutations) => { if (!mouseOnSeekBar) return; // See if mutation observed is only this ID (if so, ignore) @@ -112,7 +112,7 @@ class PreviewBar { }); } - updatePosition(parent: any): void { + updatePosition(parent: HTMLElement): void { //below the seek bar // this.parent.insertAdjacentElement("afterEnd", this.container); @@ -126,7 +126,7 @@ class PreviewBar { } //on the seek bar - this.parent.insertAdjacentElement("afterBegin", this.container); + this.parent.insertAdjacentElement("afterbegin", this.container); } updateColor(segment: string, color: string, opacity: string): void { diff --git a/src/options.ts b/src/options.ts index c5631f7b..186e442a 100644 --- a/src/options.ts +++ b/src/options.ts @@ -536,7 +536,7 @@ function copyDebugOutputToClipboard() { .then(() => { alert(chrome.i18n.getMessage("copyDebugInformationComplete")); }) - .catch((err) => { + .catch(() => { alert(chrome.i18n.getMessage("copyDebugInformationFailed")); }); -}
\ No newline at end of file +} diff --git a/src/popup.ts b/src/popup.ts index 1ccc7cae..5fb87bcf 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -5,7 +5,7 @@ import { SponsorTime, SponsorHideType } from "./types"; const utils = new Utils(); interface MessageListener { - (request: any, sender: any, callback: (response: any) => void): void; + (request: any, sender: unknown, callback: (response: any) => void): void; } class MessageHandler { diff --git a/src/types.ts b/src/types.ts index 1d282cbe..64afe352 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,7 +3,7 @@ import SkipNoticeComponent from "./components/SkipNoticeComponent"; interface ContentContainer { (): { - vote: (type: any, UUID: any, category?: string, skipNotice?: SkipNoticeComponent) => void, + vote: (type: number, UUID: string, category?: string, skipNotice?: SkipNoticeComponent) => void, dontShowNoticeAgain: () => void, unskipSponsorTime: (segment: SponsorTime) => void, sponsorTimes: SponsorTime[], @@ -15,9 +15,9 @@ interface ContentContainer { onMobileYouTube: boolean, sponsorSubmissionNotice: SubmissionNotice, resetSponsorSubmissionNotice: () => void, - changeStartSponsorButton: (showStartSponsor: any, uploadButtonVisible: any) => Promise<boolean>, + changeStartSponsorButton: (showStartSponsor: boolean, uploadButtonVisible: boolean) => Promise<boolean>, previewTime: (time: number, unpause?: boolean) => void, - videoInfo: any, + videoInfo: VideoInfo, getRealCurrentTime: () => number } } |