refactor: more types and dead code removal

This commit is contained in:
Max Baumann
2020-12-15 19:54:33 +01:00
parent 09c527417d
commit c0d910decd
5 changed files with 18 additions and 18 deletions

View File

@@ -27,7 +27,7 @@ let sponsorVideoID: VideoID = null;
// JSON video info // JSON video info
let videoInfo: VideoInfo = null; let videoInfo: VideoInfo = null;
//the channel this video is about //the channel this video is about
let channelID; let channelID: string;
// Skips are scheduled to ensure precision. // Skips are scheduled to ensure precision.
// Skips are rescheduled every seeking event. // Skips are rescheduled every seeking event.
@@ -112,7 +112,7 @@ const skipNoticeContentContainer: ContentContainer = () => ({
//get messages from the background script and the popup //get messages from the background script and the popup
chrome.runtime.onMessage.addListener(messageListener); 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 //messages from popup script
switch(request.message){ switch(request.message){
case "update": case "update":
@@ -363,7 +363,7 @@ function handleMobileControlsMutations(): void {
if (previewBar !== null) { if (previewBar !== null) {
if (document.body.contains(previewBar.container)) { if (document.body.contains(previewBar.container)) {
updatePreviewBarPositionMobile(document.getElementsByClassName(mobileYouTubeSelector)[0]); updatePreviewBarPositionMobile(document.getElementsByClassName(mobileYouTubeSelector)[0] as HTMLElement);
return; return;
} else { } else {
@@ -397,7 +397,7 @@ function createPreviewBar(): void {
const el = document.querySelectorAll(selector); const el = document.querySelectorAll(selector);
if (el && el.length && el[0]) { if (el && el.length && el[0]) {
previewBar = new PreviewBar(el[0], onMobileYouTube, onInvidious); previewBar = new PreviewBar(el[0] as HTMLElement, onMobileYouTube, onInvidious);
updatePreviewBar(); 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 * 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) { if (document.getElementById("previewbar") === null) {
previewBar.updatePosition(parent); previewBar.updatePosition(parent);
} }

View File

@@ -11,14 +11,14 @@ const utils = new Utils();
class PreviewBar { class PreviewBar {
container: HTMLUListElement; container: HTMLUListElement;
parent: any; parent: HTMLElement;
onMobileYouTube: boolean; onMobileYouTube: boolean;
onInvidious: boolean; onInvidious: boolean;
timestamps: number[][]; timestamps: number[][];
types: string[]; types: string[];
constructor(parent: any, onMobileYouTube: boolean, onInvidious: boolean) { constructor(parent: HTMLElement, onMobileYouTube: boolean, onInvidious: boolean) {
this.container = document.createElement('ul'); this.container = document.createElement('ul');
this.container.id = 'previewbar'; this.container.id = 'previewbar';
this.parent = parent; this.parent = parent;
@@ -47,16 +47,16 @@ class PreviewBar {
let mouseOnSeekBar = false; let mouseOnSeekBar = false;
seekBar.addEventListener("mouseenter", (event) => { seekBar.addEventListener("mouseenter", () => {
mouseOnSeekBar = true; mouseOnSeekBar = true;
}); });
seekBar.addEventListener("mouseleave", (event) => { seekBar.addEventListener("mouseleave", () => {
mouseOnSeekBar = false; mouseOnSeekBar = false;
categoryTooltip.classList.add("sbHidden"); categoryTooltip.classList.add("sbHidden");
}); });
const observer = new MutationObserver((mutations, observer) => { const observer = new MutationObserver((mutations) => {
if (!mouseOnSeekBar) return; if (!mouseOnSeekBar) return;
// See if mutation observed is only this ID (if so, ignore) // 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 //below the seek bar
// this.parent.insertAdjacentElement("afterEnd", this.container); // this.parent.insertAdjacentElement("afterEnd", this.container);
@@ -126,7 +126,7 @@ class PreviewBar {
} }
//on the seek bar //on the seek bar
this.parent.insertAdjacentElement("afterBegin", this.container); this.parent.insertAdjacentElement("afterbegin", this.container);
} }
updateColor(segment: string, color: string, opacity: string): void { updateColor(segment: string, color: string, opacity: string): void {

View File

@@ -536,7 +536,7 @@ function copyDebugOutputToClipboard() {
.then(() => { .then(() => {
alert(chrome.i18n.getMessage("copyDebugInformationComplete")); alert(chrome.i18n.getMessage("copyDebugInformationComplete"));
}) })
.catch((err) => { .catch(() => {
alert(chrome.i18n.getMessage("copyDebugInformationFailed")); alert(chrome.i18n.getMessage("copyDebugInformationFailed"));
}); });
} }

View File

@@ -5,7 +5,7 @@ import { SponsorTime, SponsorHideType } from "./types";
const utils = new Utils(); const utils = new Utils();
interface MessageListener { interface MessageListener {
(request: any, sender: any, callback: (response: any) => void): void; (request: any, sender: unknown, callback: (response: any) => void): void;
} }
class MessageHandler { class MessageHandler {

View File

@@ -3,7 +3,7 @@ import SkipNoticeComponent from "./components/SkipNoticeComponent";
interface ContentContainer { interface ContentContainer {
(): { (): {
vote: (type: any, UUID: any, category?: string, skipNotice?: SkipNoticeComponent) => void, vote: (type: number, UUID: string, category?: string, skipNotice?: SkipNoticeComponent) => void,
dontShowNoticeAgain: () => void, dontShowNoticeAgain: () => void,
unskipSponsorTime: (segment: SponsorTime) => void, unskipSponsorTime: (segment: SponsorTime) => void,
sponsorTimes: SponsorTime[], sponsorTimes: SponsorTime[],
@@ -15,9 +15,9 @@ interface ContentContainer {
onMobileYouTube: boolean, onMobileYouTube: boolean,
sponsorSubmissionNotice: SubmissionNotice, sponsorSubmissionNotice: SubmissionNotice,
resetSponsorSubmissionNotice: () => void, resetSponsorSubmissionNotice: () => void,
changeStartSponsorButton: (showStartSponsor: any, uploadButtonVisible: any) => Promise<boolean>, changeStartSponsorButton: (showStartSponsor: boolean, uploadButtonVisible: boolean) => Promise<boolean>,
previewTime: (time: number, unpause?: boolean) => void, previewTime: (time: number, unpause?: boolean) => void,
videoInfo: any, videoInfo: VideoInfo,
getRealCurrentTime: () => number getRealCurrentTime: () => number
} }
} }