Merge pull request #1155 from mchangrh/misc-fix

Misc fixes
This commit is contained in:
Ajay Ramachandran
2022-02-06 13:45:28 -05:00
committed by GitHub
8 changed files with 180 additions and 21 deletions

158
package-lock.json generated
View File

@@ -37,6 +37,7 @@
"@types/react": "^17.0.39", "@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11", "@types/react-dom": "^17.0.11",
"@types/selenium-webdriver": "^4.0.17", "@types/selenium-webdriver": "^4.0.17",
"@types/wicg-mediasession": "^1.1.3",
"@typescript-eslint/eslint-plugin": "^5.10.2", "@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2", "@typescript-eslint/parser": "^5.10.2",
"chromedriver": "^97.0.4", "chromedriver": "^97.0.4",
@@ -1560,6 +1561,7 @@
}, },
"node_modules/@types/chrome": { "node_modules/@types/chrome": {
"version": "0.0.178", "version": "0.0.178",
"resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.178.tgz",
"integrity": "sha512-U+G5YG2pH0qvLrYVJ9aT5VbPXYR3fAFyCuRBRAA14Pv7GrkFzDJuXPspgdeLYaKzGEp4rymUkuqUOuFz18LI1g==", "integrity": "sha512-U+G5YG2pH0qvLrYVJ9aT5VbPXYR3fAFyCuRBRAA14Pv7GrkFzDJuXPspgdeLYaKzGEp4rymUkuqUOuFz18LI1g==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
@@ -1749,6 +1751,12 @@
"integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==",
"dev": true "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": { "node_modules/@types/yargs": {
"version": "16.0.4", "version": "16.0.4",
"integrity": "sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw==", "integrity": "sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw==",
@@ -4248,6 +4256,24 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/copy-webpack-plugin/node_modules/schema-utils": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz",
"integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.8",
"ajv": "^6.12.5",
"ajv-keywords": "^3.5.2"
},
"engines": {
"node": ">= 10.13.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
}
},
"node_modules/copy-webpack-plugin/node_modules/slash": { "node_modules/copy-webpack-plugin/node_modules/slash": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
@@ -13327,7 +13353,63 @@
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"glob-to-regexp": "^0.4.1", "glob-to-regexp": "^0.4.1",
"graceful-fs": "^4.1.2" "graceful-fs": "^4.1.2",
"neo-async": "^2.5.0"
},
"optionalDependencies": {
"chokidar": "^3.4.1",
"watchpack-chokidar2": "^2.0.1"
}
},
"node_modules/watchpack-chokidar2": {
"version": "2.0.1",
"integrity": "sha512-nCFfBIPKr5Sh61s4LPpy1Wtfi0HE8isJ3d2Yb5/Ppw2P2B/3eVSEBjKfN0fmHJSK14+31KwMKmcrzs2GM4P0Ww==",
"dev": true,
"optional": true,
"dependencies": {
"chokidar": "^2.1.8"
}
},
"node_modules/watchpack-chokidar2/node_modules/chokidar": {
"version": "2.1.8",
"integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==",
"deprecated": "Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies",
"dev": true,
"optional": true,
"dependencies": {
"anymatch": "^2.0.0",
"async-each": "^1.0.1",
"braces": "^2.3.2",
"glob-parent": "^3.1.0",
"inherits": "^2.0.3",
"is-binary-path": "^1.0.0",
"is-glob": "^4.0.0",
"normalize-path": "^3.0.0",
"path-is-absolute": "^1.0.0",
"readdirp": "^2.2.1",
"upath": "^1.1.1"
},
"optionalDependencies": {
"fsevents": "^1.2.7"
}
},
"node_modules/watchpack-chokidar2/node_modules/glob-parent": {
"version": "3.1.0",
"integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=",
"dev": true,
"optional": true,
"dependencies": {
"is-glob": "^3.1.0",
"path-dirname": "^1.0.0"
}
},
"node_modules/watchpack-chokidar2/node_modules/glob-parent/node_modules/is-glob": {
"version": "3.1.0",
"integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=",
"dev": true,
"optional": true,
"dependencies": {
"is-extglob": "^2.1.0"
}, },
"engines": { "engines": {
"node": ">=10.13.0" "node": ">=10.13.0"
@@ -15131,6 +15213,7 @@
}, },
"@types/chrome": { "@types/chrome": {
"version": "0.0.178", "version": "0.0.178",
"resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.178.tgz",
"integrity": "sha512-U+G5YG2pH0qvLrYVJ9aT5VbPXYR3fAFyCuRBRAA14Pv7GrkFzDJuXPspgdeLYaKzGEp4rymUkuqUOuFz18LI1g==", "integrity": "sha512-U+G5YG2pH0qvLrYVJ9aT5VbPXYR3fAFyCuRBRAA14Pv7GrkFzDJuXPspgdeLYaKzGEp4rymUkuqUOuFz18LI1g==",
"dev": true, "dev": true,
"requires": { "requires": {
@@ -15320,6 +15403,12 @@
"integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==",
"dev": true "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": { "@types/yargs": {
"version": "16.0.4", "version": "16.0.4",
"integrity": "sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw==", "integrity": "sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw==",
@@ -17190,6 +17279,16 @@
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true "dev": true
}, },
"schema-utils": {
"version": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz",
"integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.8",
"ajv": "^6.12.5",
"ajv-keywords": "^3.5.2"
}
},
"slash": { "slash": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
@@ -24027,8 +24126,63 @@
"integrity": "sha512-x0t0JuydIo8qCNctdDrn1OzH/qDzk2+rdCOC3YzumZ42fiMqmQ7T3xQurykYMhYfHaPHTp4ZxAx2NfUo1K6QaA==", "integrity": "sha512-x0t0JuydIo8qCNctdDrn1OzH/qDzk2+rdCOC3YzumZ42fiMqmQ7T3xQurykYMhYfHaPHTp4ZxAx2NfUo1K6QaA==",
"dev": true, "dev": true,
"requires": { "requires": {
"chokidar": "^3.4.1",
"glob-to-regexp": "^0.4.1", "glob-to-regexp": "^0.4.1",
"graceful-fs": "^4.1.2" "graceful-fs": "^4.1.2",
"neo-async": "^2.5.0",
"watchpack-chokidar2": "^2.0.1"
}
},
"watchpack-chokidar2": {
"version": "2.0.1",
"integrity": "sha512-nCFfBIPKr5Sh61s4LPpy1Wtfi0HE8isJ3d2Yb5/Ppw2P2B/3eVSEBjKfN0fmHJSK14+31KwMKmcrzs2GM4P0Ww==",
"dev": true,
"optional": true,
"requires": {
"chokidar": "^2.1.8"
},
"dependencies": {
"chokidar": {
"version": "2.1.8",
"integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==",
"dev": true,
"optional": true,
"requires": {
"anymatch": "^2.0.0",
"async-each": "^1.0.1",
"braces": "^2.3.2",
"fsevents": "^1.2.7",
"glob-parent": "^3.1.0",
"inherits": "^2.0.3",
"is-binary-path": "^1.0.0",
"is-glob": "^4.0.0",
"normalize-path": "^3.0.0",
"path-is-absolute": "^1.0.0",
"readdirp": "^2.2.1",
"upath": "^1.1.1"
}
},
"glob-parent": {
"version": "3.1.0",
"integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=",
"dev": true,
"optional": true,
"requires": {
"is-glob": "^3.1.0",
"path-dirname": "^1.0.0"
},
"dependencies": {
"is-glob": {
"version": "3.1.0",
"integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=",
"dev": true,
"optional": true,
"requires": {
"is-extglob": "^2.1.0"
}
}
}
}
} }
}, },
"wcwidth": { "wcwidth": {

View File

@@ -11,6 +11,7 @@
"@types/chrome": "^0.0.178", "@types/chrome": "^0.0.178",
"@types/firefox-webext-browser": "^94.0.1", "@types/firefox-webext-browser": "^94.0.1",
"@types/jest": "^27.4.0", "@types/jest": "^27.4.0",
"@types/wicg-mediasession": "^1.1.3",
"@types/react": "^17.0.39", "@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11", "@types/react-dom": "^17.0.11",
"@types/selenium-webdriver": "^4.0.17", "@types/selenium-webdriver": "^4.0.17",

View File

@@ -263,7 +263,7 @@
<div class="small-description">__MSG_audioNotificationDescription__</div> <div class="small-description">__MSG_audioNotificationDescription__</div>
</div> </div>
<div data-type="toggle" data-sync="showTimeWithSkips"> <div data-type="toggle" data-sync="showTimeWithSkips">
<div class="switch-container"> <div class="switch-container">
<label class="switch"> <label class="switch">

View File

@@ -36,7 +36,7 @@ interface SBConfig {
serverAddress: string, serverAddress: string,
minDuration: number, minDuration: number,
skipNoticeDuration: number, skipNoticeDuration: number,
audioNotificationOnSkip, audioNotificationOnSkip: boolean,
checkForUnlistedVideos: boolean, checkForUnlistedVideos: boolean,
testingServer: boolean, testingServer: boolean,
refetchWhenNotFound: boolean, refetchWhenNotFound: boolean,

View File

@@ -683,17 +683,14 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
setupVideoMutationListener(); setupVideoMutationListener();
// Create categories list // Create categories list
const categories: string[] = []; const categories: string[] = Config.config.categorySelections.map((category) => category.name);
for (const categorySelection of Config.config.categorySelections) {
categories.push(categorySelection.name);
}
const extraRequestData: Record<string, unknown> = {}; const extraRequestData: Record<string, unknown> = {};
const hashParams = getHashParams(); const hashParams = getHashParams();
if (hashParams.requiredSegment) extraRequestData.requiredSegment = hashParams.requiredSegment; if (hashParams.requiredSegment) extraRequestData.requiredSegment = hashParams.requiredSegment;
// Check for hashPrefix setting // 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, { const response = await utils.asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, {
categories, categories,
actionTypes: getEnabledActionTypes(), actionTypes: getEnabledActionTypes(),
@@ -728,10 +725,10 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
// Hide all submissions smaller than the minimum duration // Hide all submissions smaller than the minimum duration
if (Config.config.minDuration !== 0) { if (Config.config.minDuration !== 0) {
for (let i = 0; i < sponsorTimes.length; i++) { for (const segment of sponsorTimes) {
const duration = sponsorTimes[i].segment[1] - sponsorTimes[i].segment[0] ; const duration = segment[1] - segment[0];
if (duration > 0 && duration < Config.config.minDuration) { if (duration > 0 && duration < Config.config.minDuration) {
sponsorTimes[i].hidden = SponsorHideType.MinimumDuration; segment.hidden = SponsorHideType.MinimumDuration;
} }
} }
} }
@@ -809,7 +806,7 @@ async function updateVipInfo(): Promise<boolean> {
} }
async function lockedCategoriesLookup(id: string): Promise<void> { 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); const response = await utils.asyncRequestToServer("GET", "/api/lockCategories/" + hashPrefix);
if (response.ok) { if (response.ok) {
@@ -974,8 +971,8 @@ function getYouTubeVideoIDFromURL(url: string): string | boolean {
return id.length == 11 ? id : false; return id.length == 11 ? id : false;
} else if (urlObject.pathname.startsWith("/embed/") || urlObject.pathname.startsWith("/shorts/")) { } else if (urlObject.pathname.startsWith("/embed/") || urlObject.pathname.startsWith("/shorts/")) {
try { try {
const id = urlObject.pathname.split("/")[2]; const id = urlObject.pathname.split("/")[2]
if (id && id.length >= 11) return id.substr(0, 11); if (id?.length >=11 ) return id.slice(0, 11);
} catch (e) { } catch (e) {
console.error("[SB] Video ID not valid for " + url); console.error("[SB] Video ID not valid for " + url);
return false; return false;
@@ -1047,7 +1044,8 @@ async function whitelistCheck() {
const getChannelID = () => videoInfo?.videoDetails?.channelId const getChannelID = () => videoInfo?.videoDetails?.channelId
?? document.querySelector(".ytd-channel-name a")?.getAttribute("href")?.replace(/\/.+\//, "") // YouTube ?? document.querySelector(".ytd-channel-name a")?.getAttribute("href")?.replace(/\/.+\//, "") // YouTube
?? document.querySelector(".ytp-title-channel-logo")?.getAttribute("href")?.replace(/https:\/.+\//, "") // YouTube Embed ?? 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 { try {
await utils.wait(() => !!getChannelID(), 6000, 20); await utils.wait(() => !!getChannelID(), 6000, 20);
@@ -1279,7 +1277,14 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u
if (autoSkip && Config.config.audioNotificationOnSkip) { if (autoSkip && Config.config.audioNotificationOnSkip) {
const beep = new Audio(chrome.runtime.getURL("icons/beep.ogg")); const beep = new Audio(chrome.runtime.getURL("icons/beep.ogg"));
beep.volume = video.volume * 0.1; beep.volume = video.volume * 0.1;
const oldMetadata = navigator.mediaSession.metadata
beep.play(); beep.play();
beep.addEventListener("ended", () => {
navigator.mediaSession.metadata = null;
setTimeout(() =>
navigator.mediaSession.metadata = oldMetadata
);
})
} }
if (!autoSkip if (!autoSkip
@@ -1990,7 +1995,6 @@ function sendRequestToCustomServer(type, fullAddress, callback) {
function updateAdFlag(): void { function updateAdFlag(): void {
const wasAdPlaying = isAdPlaying; const wasAdPlaying = isAdPlaying;
isAdPlaying = document.getElementsByClassName('ad-showing').length > 0; isAdPlaying = document.getElementsByClassName('ad-showing').length > 0;
if(wasAdPlaying != isAdPlaying) { if(wasAdPlaying != isAdPlaying) {
updatePreviewBar(); updatePreviewBar();
updateVisibilityOfPlayerControlsButton(); updateVisibilityOfPlayerControlsButton();

View File

@@ -22,7 +22,7 @@ async function init() {
// selected tab // selected tab
if (location.hash != "") { if (location.hash != "") {
const substr = location.hash.substring(1); const substr = location.hash.slice(1);
let menuItem = document.querySelector(`[data-for='${substr}']`); let menuItem = document.querySelector(`[data-for='${substr}']`);
if (menuItem == null) if (menuItem == null)
menuItem = document.querySelector(`[data-for='behavior']`); menuItem = document.querySelector(`[data-for='behavior']`);

View File

@@ -43,7 +43,7 @@ function findValidElementFromGenerator<T>(objects: T[] | NodeListOf<HTMLElement>
} }
export function getHashParams(): Record<string, unknown> { export function getHashParams(): Record<string, unknown> {
const windowHash = window.location.hash.substr(1); const windowHash = window.location.hash.slice(1);
if (windowHash) { if (windowHash) {
const params: Record<string, unknown> = windowHash.split('&').reduce((acc, param) => { const params: Record<string, unknown> = windowHash.split('&').reduce((acc, param) => {
const [key, value] = param.split('='); const [key, value] = param.split('=');

View File

@@ -85,12 +85,12 @@ module.exports = env => ({
if (env.browser.toLowerCase() === "safari") { if (env.browser.toLowerCase() === "safari") {
parsed.fullName.message = parsed.fullName.message.match(/^.+(?= -)/)?.[0] || parsed.fullName.message; parsed.fullName.message = parsed.fullName.message.match(/^.+(?= -)/)?.[0] || parsed.fullName.message;
if (parsed.fullName.message.length > 50) { 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; parsed.Description.message = parsed.Description.message.match(/^.+(?=\. )/)?.[0] || parsed.Description.message;
if (parsed.Description.message.length > 80) { if (parsed.Description.message.length > 80) {
parsed.Description.message = parsed.Description.message.substr(0, 77) + "..."; parsed.Description.message = parsed.Description.message.slice(0, 77) + "...";
} }
} }