linting + audio override

This commit is contained in:
Michael C 2022-01-26 17:54:58 -05:00
parent 193374db30
commit 9457aff44f
No known key found for this signature in database
GPG key ID: FFB04FB3B878B7B4
4 changed files with 35 additions and 18 deletions

17
package-lock.json generated
View file

@ -21,10 +21,11 @@
"react-dom": "^17.0.2"
},
"devDependencies": {
"@types/chrome": "0.0.91",
"@types/chrome": "^0.0.91",
"@types/firefox-webext-browser": "70.0.1",
"@types/jest": "^24.0.23",
"@types/jquery": "^3.3.31",
"@types/wicg-mediasession": "^1.1.3",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"chromedriver": "^92.0.0",
@ -1890,6 +1891,7 @@
},
"node_modules/@types/chrome": {
"version": "0.0.91",
"resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.91.tgz",
"integrity": "sha512-vNvo9lJkp1AvViWrUwe1bxhoMwr5dRZWlgr1DTuaNkz97LsG56lDX1sceWeZir2gRACJ5vdHtoRdVAvm8C75Ug==",
"dev": true,
"dependencies": {
@ -2043,6 +2045,12 @@
"integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==",
"dev": true
},
"node_modules/@types/wicg-mediasession": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@types/wicg-mediasession/-/wicg-mediasession-1.1.3.tgz",
"integrity": "sha512-lzoszzJJfW9vcaIxf6tDx3lCJq/4oaD+mplA7sCV7W21PGdR6yUPwErN047ziIcwFx61w8WMURIwUyj1V7KJIQ==",
"dev": true
},
"node_modules/@types/yargs": {
"version": "13.0.7",
"integrity": "sha512-Sg9kNeJz+V+W+0fugcVhHC+mNHnydDR1RJrW5Qn2jVrDQARF8wfPVqIqwEzZp+bneuEBIm2ClsJ1/je42ZBzSg==",
@ -20389,6 +20397,7 @@
},
"@types/chrome": {
"version": "0.0.91",
"resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.91.tgz",
"integrity": "sha512-vNvo9lJkp1AvViWrUwe1bxhoMwr5dRZWlgr1DTuaNkz97LsG56lDX1sceWeZir2gRACJ5vdHtoRdVAvm8C75Ug==",
"dev": true,
"requires": {
@ -20542,6 +20551,12 @@
"integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==",
"dev": true
},
"@types/wicg-mediasession": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@types/wicg-mediasession/-/wicg-mediasession-1.1.3.tgz",
"integrity": "sha512-lzoszzJJfW9vcaIxf6tDx3lCJq/4oaD+mplA7sCV7W21PGdR6yUPwErN047ziIcwFx61w8WMURIwUyj1V7KJIQ==",
"dev": true
},
"@types/yargs": {
"version": "13.0.7",
"integrity": "sha512-Sg9kNeJz+V+W+0fugcVhHC+mNHnydDR1RJrW5Qn2jVrDQARF8wfPVqIqwEzZp+bneuEBIm2ClsJ1/je42ZBzSg==",

View file

@ -16,10 +16,11 @@
"react-dom": "^17.0.2"
},
"devDependencies": {
"@types/chrome": "0.0.91",
"@types/chrome": "^0.0.91",
"@types/firefox-webext-browser": "70.0.1",
"@types/jest": "^24.0.23",
"@types/jquery": "^3.3.31",
"@types/wicg-mediasession": "^1.1.3",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"chromedriver": "^92.0.0",

View file

@ -682,17 +682,14 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
setupVideoMutationListener();
// Create categories list
const categories: string[] = [];
for (const categorySelection of Config.config.categorySelections) {
categories.push(categorySelection.name);
}
const categories: string[] = Config.config.categorySelections.map((category) => category.name);
const extraRequestData: Record<string, unknown> = {};
const hashParams = getHashParams();
if (hashParams.requiredSegment) extraRequestData.requiredSegment = hashParams.requiredSegment;
// Check for hashPrefix setting
const hashPrefix = (await utils.getHash(id, 1)).substr(0, 4);
const hashPrefix = (await utils.getHash(id, 1)).slice(0, 4);
const response = await utils.asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, {
categories,
actionTypes: getEnabledActionTypes(),
@ -727,11 +724,10 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
// Hide all submissions smaller than the minimum duration
if (Config.config.minDuration !== 0) {
for (let i = 0; i < sponsorTimes.length; i++) {
if (sponsorTimes[i].segment[1] - sponsorTimes[i].segment[0] < Config.config.minDuration
&& sponsorTimes[i].actionType !== ActionType.Poi) {
sponsorTimes[i].hidden = SponsorHideType.MinimumDuration;
}
for (const segment of sponsorTimes) {
if (segment.segment[1] - segment.segment[0] < Config.config.minDuration
&& segment.actionType !== ActionType.Poi)
segment.hidden = SponsorHideType.MinimumDuration;
}
}
@ -808,7 +804,7 @@ async function updateVipInfo(): Promise<boolean> {
}
async function lockedCategoriesLookup(id: string): Promise<void> {
const hashPrefix = (await utils.getHash(id, 1)).substr(0, 4);
const hashPrefix = (await utils.getHash(id, 1)).slice(0, 4);
const response = await utils.asyncRequestToServer("GET", "/api/lockCategories/" + hashPrefix);
if (response.ok) {
@ -971,8 +967,7 @@ function getYouTubeVideoIDFromURL(url: string): string | boolean {
return id.length == 11 ? id : false;
} else if (urlObject.pathname.startsWith("/embed/") || urlObject.pathname.startsWith("/shorts/")) {
try {
const id = urlObject.pathname.split("/")[2];
if (id && id.length >= 11) return id.substr(0, 11);
return urlObject.pathname.split("/")[2].slice(0, 11);
} catch (e) {
console.error("[SB] Video ID not valid for " + url);
return false;
@ -1044,7 +1039,8 @@ async function whitelistCheck() {
const getChannelID = () => videoInfo?.videoDetails?.channelId
?? document.querySelector(".ytd-channel-name a")?.getAttribute("href")?.replace(/\/.+\//, "") // YouTube
?? document.querySelector(".ytp-title-channel-logo")?.getAttribute("href")?.replace(/https:\/.+\//, "") // YouTube Embed
?? document.querySelector("a > .channel-profile")?.parentElement?.getAttribute("href")?.replace(/\/.+\//, ""); // Invidious
?? document.querySelector("a > .channel-profile")?.parentElement?.getAttribute("href")?.replace(/\/.+\//, "") // Invidious
?? document.querySelector("a.slim-owner-icon-and-title")?.getAttribute("href")?.replace(/\/.+\//, ""); // Mobile YouTube
try {
await utils.wait(() => !!getChannelID(), 6000, 20);
@ -1277,6 +1273,10 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u
const beep = new Audio(chrome.runtime.getURL("icons/beep.ogg"));
beep.volume = video.volume * 0.1;
beep.play();
beep.controls = false;
// hijack media function
navigator.mediaSession.setActionHandler('play', () => video.play())
navigator.mediaSession.setActionHandler("pause", () => video.pause())
}
if (!autoSkip

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const webpack = require("webpack");
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
@ -84,12 +85,12 @@ module.exports = env => ({
if (env.browser.toLowerCase() === "safari") {
parsed.fullName.message = parsed.fullName.message.match(/^.+(?= -)/)?.[0] || parsed.fullName.message;
if (parsed.fullName.message.length > 50) {
parsed.fullName.message = parsed.fullName.message.substr(0, 47) + "...";
parsed.fullName.message = parsed.fullName.message.slice(0, 47) + "...";
}
parsed.Description.message = parsed.Description.message.match(/^.+(?=\. )/)?.[0] || parsed.Description.message;
if (parsed.Description.message.length > 80) {
parsed.Description.message = parsed.Description.message.substr(0, 77) + "...";
parsed.Description.message = parsed.Description.message.slice(0, 77) + "...";
}
}