mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 21:17:20 +03:00
Merge pull request #578 from FoseFx/fosefx-eslint-fix
Fix eslint warnings
This commit is contained in:
@@ -21,8 +21,8 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
// TODO: Remove warn rules when not needed anymore
|
// TODO: Remove warn rules when not needed anymore
|
||||||
"@typescript-eslint/no-this-alias": "warn",
|
"@typescript-eslint/no-this-alias": "warn",
|
||||||
"no-self-assign": "warn",
|
"no-self-assign": "off",
|
||||||
"@typescript-eslint/no-empty-interface": "warn",
|
"@typescript-eslint/no-empty-interface": "off",
|
||||||
"@typescript-eslint/ban-types": "warn",
|
"@typescript-eslint/ban-types": "warn",
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import * as CompileConfig from "../config.json";
|
|||||||
|
|
||||||
import Config from "./config";
|
import Config from "./config";
|
||||||
import { Registration } from "./types";
|
import { Registration } from "./types";
|
||||||
|
|
||||||
// Make the config public for debugging purposes
|
// Make the config public for debugging purposes
|
||||||
(<any> window).SB = Config;
|
|
||||||
|
window.SB = Config;
|
||||||
|
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
const utils = new Utils({
|
const utils = new Utils({
|
||||||
@@ -70,7 +72,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//add help page on install
|
//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 let's the config sync to run fully before checking.
|
||||||
// This is required on Firefox
|
// This is required on Firefox
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
|
||||||
import Config from "../config"
|
|
||||||
import * as CompileConfig from "../../config.json";
|
import * as CompileConfig from "../../config.json";
|
||||||
import CategorySkipOptionsComponent from "./CategorySkipOptionsComponent";
|
import CategorySkipOptionsComponent from "./CategorySkipOptionsComponent";
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ import * as React from "react";
|
|||||||
|
|
||||||
import Config from "../config"
|
import Config from "../config"
|
||||||
import { CategorySkipOption } from "../types";
|
import { CategorySkipOption } from "../types";
|
||||||
import Utils from "../utils";
|
|
||||||
|
|
||||||
const utils = new Utils();
|
|
||||||
|
|
||||||
export interface CategorySkipOptionsProps {
|
export interface CategorySkipOptionsProps {
|
||||||
category: string;
|
category: string;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export interface NoticeState {
|
|||||||
|
|
||||||
class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
|
class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
|
||||||
countdownInterval: NodeJS.Timeout;
|
countdownInterval: NodeJS.Timeout;
|
||||||
idSuffix: any;
|
idSuffix: string;
|
||||||
|
|
||||||
amountOfPreviousNotices: number;
|
amountOfPreviousNotices: number;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as React from "react";
|
|||||||
export interface NoticeTextSelectionProps {
|
export interface NoticeTextSelectionProps {
|
||||||
text: string,
|
text: string,
|
||||||
idSuffix: string,
|
idSuffix: string,
|
||||||
onClick?: (event: React.MouseEvent) => any
|
onClick?: (event: React.MouseEvent) => unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NoticeTextSelectionState {
|
export interface NoticeTextSelectionState {
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ 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 { ContentContainer, SponsorHideType, SponsorTime } from "../types";
|
import { ContentContainer, SponsorHideType, SponsorTime } from "../types";
|
||||||
|
|
||||||
import Utils from "../utils";
|
|
||||||
const utils = new Utils();
|
|
||||||
|
|
||||||
import NoticeComponent from "./NoticeComponent";
|
import NoticeComponent from "./NoticeComponent";
|
||||||
import NoticeTextSelectionComponent from "./NoticeTextSectionComponent";
|
import NoticeTextSelectionComponent from "./NoticeTextSectionComponent";
|
||||||
|
|
||||||
@@ -42,7 +38,7 @@ export interface SkipNoticeState {
|
|||||||
|
|
||||||
downvoting: boolean;
|
downvoting: boolean;
|
||||||
choosingCategory: 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;
|
actionState: SkipNoticeAction;
|
||||||
}
|
}
|
||||||
@@ -447,7 +443,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getUnskippedModeInfo(index: number, buttonText: string) {
|
getUnskippedModeInfo(index: number, buttonText: string): SkipNoticeState {
|
||||||
const self = this;
|
const self = this;
|
||||||
const maxCountdownTime = function() {
|
const maxCountdownTime = function() {
|
||||||
const sponsorTime = self.segments[index];
|
const sponsorTime = self.segments[index];
|
||||||
@@ -458,14 +454,11 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
unskipText: buttonText,
|
unskipText: buttonText,
|
||||||
|
|
||||||
unskipCallback: (index) => this.reskip(index),
|
unskipCallback: (index) => 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,
|
maxCountdownTime: maxCountdownTime,
|
||||||
|
|
||||||
countdownTime: maxCountdownTime()
|
countdownTime: maxCountdownTime()
|
||||||
}
|
} as SkipNoticeState;
|
||||||
}
|
}
|
||||||
|
|
||||||
reskip(index: number): void {
|
reskip(index: number): void {
|
||||||
@@ -508,7 +501,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setNoticeInfoMessageWithOnClick(onClick: (event: React.MouseEvent) => any, ...messages: string[]): void {
|
setNoticeInfoMessageWithOnClick(onClick: (event: React.MouseEvent) => unknown, ...messages: string[]): void {
|
||||||
this.setState({
|
this.setState({
|
||||||
messages,
|
messages,
|
||||||
messageOnClick: (event) => onClick(event)
|
messageOnClick: (event) => onClick(event)
|
||||||
@@ -521,7 +514,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addVoteButtonInfo(message): void {
|
addVoteButtonInfo(message: string): void {
|
||||||
this.setState({
|
this.setState({
|
||||||
thanksForVotingText: message
|
thanksForVotingText: message
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as CompileConfig from "../config.json";
|
import * as CompileConfig from "../config.json";
|
||||||
import { CategorySelection, CategorySkipOption, PreviewBarOption, SponsorTime } from "./types";
|
import { CategorySelection, CategorySkipOption, PreviewBarOption, SponsorTime, StorageChangesObject } from "./types";
|
||||||
|
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
const utils = new Utils();
|
const utils = new Utils();
|
||||||
@@ -58,8 +58,8 @@ interface SBConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SBObject {
|
export interface SBObject {
|
||||||
configListeners: Array<Function>;
|
configListeners: Array<(changes: StorageChangesObject) => unknown>;
|
||||||
defaults: SBConfig;
|
defaults: SBConfig;
|
||||||
localConfig: SBConfig;
|
localConfig: SBConfig;
|
||||||
config: SBConfig;
|
config: SBConfig;
|
||||||
@@ -275,8 +275,8 @@ function decodeStoredItem<T>(id: string, data: T): T | SBMap<string, SponsorTime
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function configProxy(): any {
|
function configProxy(): SBConfig {
|
||||||
chrome.storage.onChanged.addListener((changes, namespace) => {
|
chrome.storage.onChanged.addListener((changes: {[key: string]: chrome.storage.StorageChange}) => {
|
||||||
for (const key in changes) {
|
for (const key in changes) {
|
||||||
Config.localConfig[key] = decodeStoredItem(key, changes[key].newValue);
|
Config.localConfig[key] = decodeStoredItem(key, changes[key].newValue);
|
||||||
}
|
}
|
||||||
@@ -286,8 +286,8 @@ function configProxy(): any {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const handler: ProxyHandler<any> = {
|
const handler: ProxyHandler<SBConfig> = {
|
||||||
set(obj, prop, value) {
|
set<K extends keyof SBConfig>(obj: SBConfig, prop: K, value: SBConfig[K]) {
|
||||||
Config.localConfig[prop] = value;
|
Config.localConfig[prop] = value;
|
||||||
|
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
@@ -297,13 +297,13 @@ function configProxy(): any {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
get(obj, prop): any {
|
get<K extends keyof SBConfig>(obj: SBConfig, prop: K): SBConfig[K] {
|
||||||
const data = Config.localConfig[prop];
|
const data = Config.localConfig[prop];
|
||||||
|
|
||||||
return obj[prop] || data;
|
return obj[prop] || data;
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteProperty(obj, prop) {
|
deleteProperty(obj: SBConfig, prop: keyof SBConfig) {
|
||||||
chrome.storage.sync.remove(<string> prop);
|
chrome.storage.sync.remove(<string> prop);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -311,11 +311,11 @@ function configProxy(): any {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Proxy({handler}, handler);
|
return new Proxy<SBConfig>({handler} as unknown as SBConfig, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchConfig(): Promise<void> {
|
function fetchConfig(): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
chrome.storage.sync.get(null, function(items) {
|
chrome.storage.sync.get(null, function(items) {
|
||||||
Config.localConfig = <SBConfig> <unknown> items; // Data is ready
|
Config.localConfig = <SBConfig> <unknown> items; // Data is ready
|
||||||
resolve();
|
resolve();
|
||||||
@@ -439,11 +439,6 @@ async function setupConfig() {
|
|||||||
Config.config = config;
|
Config.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset config
|
|
||||||
function resetConfig() {
|
|
||||||
Config.config = Config.defaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
function convertJSON(): void {
|
function convertJSON(): void {
|
||||||
Object.keys(Config.localConfig).forEach(key => {
|
Object.keys(Config.localConfig).forEach(key => {
|
||||||
Config.localConfig[key] = decodeStoredItem(key, Config.localConfig[key]);
|
Config.localConfig[key] = decodeStoredItem(key, Config.localConfig[key]);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Config from "./config";
|
import Config from "./config";
|
||||||
|
|
||||||
import { SponsorTime, CategorySkipOption, CategorySelection, VideoID, SponsorHideType, FetchResponse } from "./types";
|
import { SponsorTime, CategorySkipOption, VideoID, SponsorHideType, FetchResponse, VideoInfo, StorageChangesObject } from "./types";
|
||||||
|
|
||||||
import { ContentContainer } from "./types";
|
import { ContentContainer } from "./types";
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
@@ -25,9 +25,9 @@ let sponsorTimes: SponsorTime[] = null;
|
|||||||
let sponsorVideoID: VideoID = null;
|
let sponsorVideoID: VideoID = null;
|
||||||
|
|
||||||
// JSON video info
|
// JSON video info
|
||||||
let videoInfo: any = 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.
|
||||||
@@ -115,7 +115,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":
|
||||||
@@ -182,7 +182,7 @@ function messageListener(request: any, sender: any, sendResponse: (response: any
|
|||||||
*
|
*
|
||||||
* @param {String} changes
|
* @param {String} changes
|
||||||
*/
|
*/
|
||||||
function contentConfigUpdateListener(changes) {
|
function contentConfigUpdateListener(changes: StorageChangesObject) {
|
||||||
for (const key in changes) {
|
for (const key in changes) {
|
||||||
switch(key) {
|
switch(key) {
|
||||||
case "hideVideoPlayerControls":
|
case "hideVideoPlayerControls":
|
||||||
@@ -368,7 +368,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 {
|
||||||
@@ -402,7 +402,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();
|
||||||
|
|
||||||
@@ -753,7 +753,7 @@ function startSkipScheduleCheckingForStartSponsors() {
|
|||||||
* Get the video info for the current tab from YouTube
|
* Get the video info for the current tab from YouTube
|
||||||
*/
|
*/
|
||||||
function getVideoInfo() {
|
function getVideoInfo() {
|
||||||
sendRequestToCustomServer('GET', "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID, function(xmlhttp, error) {
|
sendRequestToCustomServer('GET', "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID, function(xmlhttp) {
|
||||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||||
const decodedData = decodeURIComponent(xmlhttp.responseText).match(/player_response=([^&]*)/)[1];
|
const decodedData = decodeURIComponent(xmlhttp.responseText).match(/player_response=([^&]*)/)[1];
|
||||||
if (!decodedData) {
|
if (!decodedData) {
|
||||||
@@ -811,7 +811,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);
|
||||||
}
|
}
|
||||||
@@ -1064,7 +1064,7 @@ function createButton(baseID, title, callback, imageName, isDraggable=false): bo
|
|||||||
newButton.classList.add("playerButton");
|
newButton.classList.add("playerButton");
|
||||||
newButton.classList.add("ytp-button");
|
newButton.classList.add("ytp-button");
|
||||||
newButton.setAttribute("title", chrome.i18n.getMessage(title));
|
newButton.setAttribute("title", chrome.i18n.getMessage(title));
|
||||||
newButton.addEventListener("click", (event: Event) => {
|
newButton.addEventListener("click", () => {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1448,8 +1448,6 @@ function submitSponsorTimes() {
|
|||||||
//it can't update to this info yet
|
//it can't update to this info yet
|
||||||
closeInfoMenu();
|
closeInfoMenu();
|
||||||
|
|
||||||
const currentVideoID = sponsorVideoID;
|
|
||||||
|
|
||||||
if (sponsorTimesSubmitting !== undefined && sponsorTimesSubmitting.length > 0) {
|
if (sponsorTimesSubmitting !== undefined && sponsorTimesSubmitting.length > 0) {
|
||||||
submissionNotice = new SubmissionNotice(skipNoticeContentContainer, sendSubmitMessage);
|
submissionNotice = new SubmissionNotice(skipNoticeContentContainer, sendSubmitMessage);
|
||||||
}
|
}
|
||||||
@@ -1596,7 +1594,7 @@ function sendRequestToCustomServer(type, fullAddress, callback) {
|
|||||||
callback(xmlhttp, false);
|
callback(xmlhttp, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
xmlhttp.onerror = function(ev) {
|
xmlhttp.onerror = function() {
|
||||||
callback(xmlhttp, true);
|
callback(xmlhttp, true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/globals.d.ts
vendored
Normal file
19
src/globals.d.ts
vendored
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Config from "./config";
|
|||||||
import * as CompileConfig from "../config.json";
|
import * as CompileConfig from "../config.json";
|
||||||
|
|
||||||
// Make the config public for debugging purposes
|
// Make the config public for debugging purposes
|
||||||
(<any> window).SB = Config;
|
window.SB = Config;
|
||||||
|
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
import CategoryChooser from "./render/CategoryChooser";
|
import CategoryChooser from "./render/CategoryChooser";
|
||||||
@@ -107,7 +107,7 @@ async function init() {
|
|||||||
|
|
||||||
// Permission needed on Firefox
|
// Permission needed on Firefox
|
||||||
if (utils.isFirefox()) {
|
if (utils.isFirefox()) {
|
||||||
const permissionSuccess = await new Promise((resolve, reject) => {
|
const permissionSuccess = await new Promise((resolve) => {
|
||||||
chrome.permissions.request({
|
chrome.permissions.request({
|
||||||
origins: [textChangeInput.value + "/"],
|
origins: [textChangeInput.value + "/"],
|
||||||
permissions: []
|
permissions: []
|
||||||
@@ -202,7 +202,7 @@ async function init() {
|
|||||||
*
|
*
|
||||||
* @param {String} element
|
* @param {String} element
|
||||||
*/
|
*/
|
||||||
function optionsConfigUpdateListener(changes) {
|
function optionsConfigUpdateListener() {
|
||||||
const optionsContainer = document.getElementById("options");
|
const optionsContainer = document.getElementById("options");
|
||||||
const optionsElements = optionsContainer.querySelectorAll("*");
|
const optionsElements = optionsContainer.querySelectorAll("*");
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ function invidiousInstanceAddInit(element: HTMLElement, option: string) {
|
|||||||
const button = element.querySelector(".trigger-button");
|
const button = element.querySelector(".trigger-button");
|
||||||
|
|
||||||
const setButton = element.querySelector(".text-change-set");
|
const setButton = element.querySelector(".text-change-set");
|
||||||
setButton.addEventListener("click", async function(e) {
|
setButton.addEventListener("click", async function() {
|
||||||
if (textBox.value == "" || textBox.value.includes("/") || textBox.value.includes("http")) {
|
if (textBox.value == "" || textBox.value.includes("/") || textBox.value.includes("http")) {
|
||||||
alert(chrome.i18n.getMessage("addInvidiousInstanceError"));
|
alert(chrome.i18n.getMessage("addInvidiousInstanceError"));
|
||||||
} else {
|
} else {
|
||||||
@@ -269,7 +269,7 @@ function invidiousInstanceAddInit(element: HTMLElement, option: string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const resetButton = element.querySelector(".invidious-instance-reset");
|
const resetButton = element.querySelector(".invidious-instance-reset");
|
||||||
resetButton.addEventListener("click", function(e) {
|
resetButton.addEventListener("click", function() {
|
||||||
if (confirm(chrome.i18n.getMessage("resetInvidiousInstanceAlert"))) {
|
if (confirm(chrome.i18n.getMessage("resetInvidiousInstanceAlert"))) {
|
||||||
// Set to a clone of the default
|
// Set to a clone of the default
|
||||||
Config.config[option] = Config.defaults[option].slice(0);
|
Config.config[option] = Config.defaults[option].slice(0);
|
||||||
@@ -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"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
13
src/popup.ts
13
src/popup.ts
@@ -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 {
|
||||||
@@ -37,6 +37,8 @@ class MessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//make this a function to allow this to run on the content page
|
//make this a function to allow this to run on the content page
|
||||||
async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
||||||
const messageHandler = new MessageHandler(messageListener);
|
const messageHandler = new MessageHandler(messageListener);
|
||||||
@@ -45,7 +47,14 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
|
|
||||||
await utils.wait(() => Config.config !== null);
|
await utils.wait(() => Config.config !== null);
|
||||||
|
|
||||||
const PageElements: any = {};
|
type InputPageElements = {
|
||||||
|
whitelistToggle?: HTMLInputElement,
|
||||||
|
toggleSwitch?: HTMLInputElement,
|
||||||
|
usernameInput?: HTMLInputElement,
|
||||||
|
};
|
||||||
|
type PageElements = { [key: string]: HTMLElement } & InputPageElements
|
||||||
|
|
||||||
|
const PageElements: PageElements = {};
|
||||||
|
|
||||||
[
|
[
|
||||||
"sponsorblockPopup",
|
"sponsorblockPopup",
|
||||||
|
|||||||
88
src/types.ts
88
src/types.ts
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,8 +78,86 @@ interface BackgroundScriptContainer {
|
|||||||
unregisterFirefoxContentScript: (id: string) => void
|
unregisterFirefoxContentScript: (id: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface VideoInfo {
|
||||||
|
responseContext: {
|
||||||
|
serviceTrackingParams: Array<{service: string, params: Array<{key: string, value: string}>}>,
|
||||||
|
webResponseContextExtensionData: {
|
||||||
|
hasDecorated: boolean
|
||||||
|
}
|
||||||
|
},
|
||||||
|
playabilityStatus: {
|
||||||
|
status: string,
|
||||||
|
playableInEmbed: boolean,
|
||||||
|
miniplayer: {
|
||||||
|
miniplayerRenderer: {
|
||||||
|
playbackMode: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
streamingData: unknown;
|
||||||
|
playbackTracking: unknown;
|
||||||
|
videoDetails: {
|
||||||
|
videoId: string,
|
||||||
|
title: string,
|
||||||
|
lengthSeconds: string,
|
||||||
|
keywords: string[],
|
||||||
|
channelId: string,
|
||||||
|
isOwnerViewing: boolean,
|
||||||
|
shortDescription: string,
|
||||||
|
isCrawlable: boolean,
|
||||||
|
thumbnail: {
|
||||||
|
thumbnails: Array<{url: string, width: number, height: number}>
|
||||||
|
},
|
||||||
|
averageRating: number,
|
||||||
|
allowRatings: boolean,
|
||||||
|
viewCount: string,
|
||||||
|
author: string,
|
||||||
|
isPrivate: boolean,
|
||||||
|
isUnpluggedCorpus: boolean,
|
||||||
|
isLiveContent: boolean,
|
||||||
|
};
|
||||||
|
playerConfig: unknown;
|
||||||
|
storyboards: unknown;
|
||||||
|
microformat: {
|
||||||
|
playerMicroformatRenderer: {
|
||||||
|
thumbnail: {
|
||||||
|
thumbnails: Array<{url: string, width: number, height: number}>
|
||||||
|
},
|
||||||
|
embed: {
|
||||||
|
iframeUrl: string,
|
||||||
|
flashUrl: string,
|
||||||
|
width: number,
|
||||||
|
height: number,
|
||||||
|
flashSecureUrl: string,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
simpleText: string,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
simpleText: string,
|
||||||
|
},
|
||||||
|
lengthSeconds: string,
|
||||||
|
ownerProfileUrl: string,
|
||||||
|
externalChannelId: string,
|
||||||
|
availableCountries: string[],
|
||||||
|
isUnlisted: boolean,
|
||||||
|
hasYpcMetadata: boolean,
|
||||||
|
viewCount: string,
|
||||||
|
category: string,
|
||||||
|
publishDate: string,
|
||||||
|
ownerChannelName: string,
|
||||||
|
uploadDate: string,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
trackingParams: string;
|
||||||
|
attestation: unknown;
|
||||||
|
messages: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
type VideoID = string;
|
type VideoID = string;
|
||||||
|
|
||||||
|
type StorageChangesObject = { [key: string]: chrome.storage.StorageChange };
|
||||||
|
|
||||||
export {
|
export {
|
||||||
FetchResponse,
|
FetchResponse,
|
||||||
VideoDurationResponse,
|
VideoDurationResponse,
|
||||||
@@ -91,5 +169,7 @@ export {
|
|||||||
SponsorHideType,
|
SponsorHideType,
|
||||||
PreviewBarOption,
|
PreviewBarOption,
|
||||||
Registration,
|
Registration,
|
||||||
BackgroundScriptContainer
|
BackgroundScriptContainer,
|
||||||
|
VideoInfo,
|
||||||
|
StorageChangesObject,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -119,8 +119,7 @@ class Utils {
|
|||||||
const rule = {
|
const rule = {
|
||||||
id: "invidious",
|
id: "invidious",
|
||||||
conditions,
|
conditions,
|
||||||
// This API is experimental and not visible by the TypeScript compiler
|
actions: [new chrome.declarativeContent.RequestContentScript({
|
||||||
actions: [new (<any> chrome.declarativeContent).RequestContentScript({
|
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
js: self.js,
|
js: self.js,
|
||||||
css: self.css
|
css: self.css
|
||||||
|
|||||||
Reference in New Issue
Block a user