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
No known key found for this signature in database
GPG key ID: 82EEA14C1523D1BB
5 changed files with 18 additions and 18 deletions

View file

@ -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);
}

View file

@ -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 {

View file

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

View file

@ -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 {

View file

@ -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
}
}