mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
Make skip notice work on channel trailer
This commit is contained in:
parent
6930980a4d
commit
aca52abefc
2 changed files with 25 additions and 5 deletions
15
src/utils.ts
15
src/utils.ts
|
@ -2,6 +2,7 @@ import Config from "./config";
|
||||||
import { CategorySelection, SponsorTime, FetchResponse, BackgroundScriptContainer, Registration } from "./types";
|
import { CategorySelection, SponsorTime, FetchResponse, BackgroundScriptContainer, Registration } from "./types";
|
||||||
|
|
||||||
import * as CompileConfig from "../config.json";
|
import * as CompileConfig from "../config.json";
|
||||||
|
import { findValidElement } from "./utils/pageUtils";
|
||||||
|
|
||||||
export default class Utils {
|
export default class Utils {
|
||||||
|
|
||||||
|
@ -436,11 +437,15 @@ export default class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
findReferenceNode(): HTMLElement {
|
findReferenceNode(): HTMLElement {
|
||||||
let referenceNode = document.getElementById("player-container-id")
|
const selectors = [
|
||||||
?? document.getElementById("movie_player")
|
"#player-container-id",
|
||||||
?? document.querySelector("#main-panel.ytmusic-player-page") // YouTube music
|
"#movie_player",
|
||||||
?? document.querySelector("#player-container .video-js") // Invidious
|
"#c4-player", // Channel Trailer
|
||||||
?? document.querySelector(".main-video-section > .video-container"); // Cloudtube
|
"#main-panel.ytmusic-player-page", // YouTube music
|
||||||
|
"#player-container .video-js", // Invidious
|
||||||
|
".main-video-section > .video-container" // Cloudtube
|
||||||
|
]
|
||||||
|
let referenceNode = findValidElement(selectors)
|
||||||
if (referenceNode == null) {
|
if (referenceNode == null) {
|
||||||
//for embeds
|
//for embeds
|
||||||
const player = document.getElementById("player");
|
const player = document.getElementById("player");
|
||||||
|
|
|
@ -18,3 +18,18 @@ export function getControls(): HTMLElement | false {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isVisible(element: HTMLElement): boolean {
|
||||||
|
return element.offsetWidth > 0 && element.offsetHeight > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findValidElement(selectors: string[]): HTMLElement {
|
||||||
|
for (const selector of selectors) {
|
||||||
|
const element = document.querySelector(selector) as HTMLElement;
|
||||||
|
if (element && isVisible(element)) {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
Loading…
Reference in a new issue