diff --git a/.eslintrc.js b/.eslintrc.js index ad68956e..3ea331c5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,8 +21,8 @@ module.exports = { rules: { // TODO: Remove warn rules when not needed anymore "@typescript-eslint/no-this-alias": "warn", - "no-self-assign": "warn", - "@typescript-eslint/no-empty-interface": "warn", + "no-self-assign": "off", + "@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/ban-types": "warn", }, settings: { diff --git a/src/background.ts b/src/background.ts index 2bab479f..5d7ad4c5 100644 --- a/src/background.ts +++ b/src/background.ts @@ -2,8 +2,10 @@ import * as CompileConfig from "../config.json"; import Config from "./config"; import { Registration } from "./types"; + // Make the config public for debugging purposes -( window).SB = Config; + +window.SB = Config; import Utils from "./utils"; const utils = new Utils({ @@ -70,7 +72,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) { }); //add help page on install -chrome.runtime.onInstalled.addListener(function (object) { +chrome.runtime.onInstalled.addListener(function () { // This let's the config sync to run fully before checking. // This is required on Firefox setTimeout(function() { diff --git a/src/components/CategoryChooserComponent.tsx b/src/components/CategoryChooserComponent.tsx index 19d9d589..bb86e10f 100644 --- a/src/components/CategoryChooserComponent.tsx +++ b/src/components/CategoryChooserComponent.tsx @@ -1,6 +1,5 @@ import * as React from "react"; -import Config from "../config" import * as CompileConfig from "../../config.json"; import CategorySkipOptionsComponent from "./CategorySkipOptionsComponent"; diff --git a/src/components/CategorySkipOptionsComponent.tsx b/src/components/CategorySkipOptionsComponent.tsx index b190223d..3cc03527 100644 --- a/src/components/CategorySkipOptionsComponent.tsx +++ b/src/components/CategorySkipOptionsComponent.tsx @@ -2,9 +2,6 @@ import * as React from "react"; import Config from "../config" import { CategorySkipOption } from "../types"; -import Utils from "../utils"; - -const utils = new Utils(); export interface CategorySkipOptionsProps { category: string; diff --git a/src/components/NoticeComponent.tsx b/src/components/NoticeComponent.tsx index 94b3fd56..9fff3be4 100644 --- a/src/components/NoticeComponent.tsx +++ b/src/components/NoticeComponent.tsx @@ -28,7 +28,7 @@ export interface NoticeState { class NoticeComponent extends React.Component { countdownInterval: NodeJS.Timeout; - idSuffix: any; + idSuffix: string; amountOfPreviousNotices: number; diff --git a/src/components/NoticeTextSectionComponent.tsx b/src/components/NoticeTextSectionComponent.tsx index cbcbb7b2..5e74a1d6 100644 --- a/src/components/NoticeTextSectionComponent.tsx +++ b/src/components/NoticeTextSectionComponent.tsx @@ -3,7 +3,7 @@ import * as React from "react"; export interface NoticeTextSelectionProps { text: string, idSuffix: string, - onClick?: (event: React.MouseEvent) => any + onClick?: (event: React.MouseEvent) => unknown } export interface NoticeTextSelectionState { diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index 5618c907..cd7b8205 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -2,10 +2,6 @@ import * as React from "react"; import * as CompileConfig from "../../config.json"; import Config from "../config" import { ContentContainer, SponsorHideType, SponsorTime } from "../types"; - -import Utils from "../utils"; -const utils = new Utils(); - import NoticeComponent from "./NoticeComponent"; import NoticeTextSelectionComponent from "./NoticeTextSectionComponent"; @@ -42,7 +38,7 @@ export interface SkipNoticeState { downvoting: boolean; choosingCategory: boolean; - thanksForVotingText: boolean; //null until the voting buttons should be hidden + thanksForVotingText: string; //null until the voting buttons should be hidden actionState: SkipNoticeAction; } @@ -447,7 +443,7 @@ class SkipNoticeComponent extends React.Component this.reskip(index), - - //change max duration to however much of the sponsor is left + // change max duration to however much of the sponsor is left maxCountdownTime: maxCountdownTime, - countdownTime: maxCountdownTime() - } + } as SkipNoticeState; } reskip(index: number): void { @@ -508,7 +501,7 @@ class SkipNoticeComponent extends React.Component any, ...messages: string[]): void { + setNoticeInfoMessageWithOnClick(onClick: (event: React.MouseEvent) => unknown, ...messages: string[]): void { this.setState({ messages, messageOnClick: (event) => onClick(event) @@ -521,7 +514,7 @@ class SkipNoticeComponent extends React.Component; defaults: SBConfig; localConfig: SBConfig; diff --git a/src/globals.d.ts b/src/globals.d.ts new file mode 100644 index 00000000..ed8547a0 --- /dev/null +++ b/src/globals.d.ts @@ -0,0 +1,19 @@ +import { SBObject } from "./config"; +declare global { + interface Window { SB: SBObject; } + // Remove this once the API becomes stable and types are shipped in @types/chrome + namespace chrome { + namespace declarativeContent { + export interface RequestContentScriptOptions { + allFrames?: boolean; + css?: string[]; + instanceType?: "declarativeContent.RequestContentScript"; + js?: string[]; + matchAboutBlanck?: boolean; + } + export class RequestContentScript { + constructor(options: RequestContentScriptOptions); + } + } + } +} diff --git a/src/utils.ts b/src/utils.ts index 149d99cf..65392ad2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -119,8 +119,7 @@ class Utils { const rule = { id: "invidious", conditions, - // This API is experimental and not visible by the TypeScript compiler - actions: [new ( chrome.declarativeContent).RequestContentScript({ + actions: [new chrome.declarativeContent.RequestContentScript({ allFrames: true, js: self.js, css: self.css