|
@@ -17,7 +17,7 @@
|
|
// @license AGPL-3.0-only
|
|
// @license AGPL-3.0-only
|
|
// @author Sv443
|
|
// @author Sv443
|
|
// @copyright Sv443 (https://github.com/Sv443)
|
|
// @copyright Sv443 (https://github.com/Sv443)
|
|
-// @icon https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/images/logo/logo_dev_48.png
|
|
|
|
|
|
+// @icon https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/images/logo/logo_dev_48.png
|
|
// @match https://music.youtube.com/*
|
|
// @match https://music.youtube.com/*
|
|
// @match https://www.youtube.com/*
|
|
// @match https://www.youtube.com/*
|
|
// @run-at document-start
|
|
// @run-at document-start
|
|
@@ -33,51 +33,51 @@
|
|
// @grant GM.openInTab
|
|
// @grant GM.openInTab
|
|
// @grant unsafeWindow
|
|
// @grant unsafeWindow
|
|
// @noframes
|
|
// @noframes
|
|
-// @resource css-bundle https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/dist/BetterYTM.css
|
|
|
|
-// @resource css-above_queue_btns https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/style/aboveQueueBtns.css
|
|
|
|
-// @resource css-anchor_improvements https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/style/anchorImprovements.css
|
|
|
|
-// @resource css-fix_hdr https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/style/fixHDR.css
|
|
|
|
-// @resource css-fix_spacing https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/style/fixSpacing.css
|
|
|
|
-// @resource css-show_votes https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/style/showVotes.css
|
|
|
|
-// @resource css-vol_slider_size https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/style/volSliderSize.css
|
|
|
|
-// @resource doc-changelog https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/changelog.md
|
|
|
|
-// @resource icon-advanced_mode https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/plus_circle_small.svg
|
|
|
|
-// @resource icon-arrow_down https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/arrow_down.svg
|
|
|
|
-// @resource icon-auto_like_enabled https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/auto_like_enabled.svg
|
|
|
|
-// @resource icon-auto_like https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/auto_like.svg
|
|
|
|
-// @resource icon-clear_list https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/clear_list.svg
|
|
|
|
-// @resource icon-copy https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/copy.svg
|
|
|
|
-// @resource icon-delete https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/delete.svg
|
|
|
|
-// @resource icon-edit https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/edit.svg
|
|
|
|
-// @resource icon-error https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/error.svg
|
|
|
|
-// @resource icon-experimental https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/beaker_small.svg
|
|
|
|
-// @resource icon-globe_small https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/globe_small.svg
|
|
|
|
-// @resource icon-globe https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/globe.svg
|
|
|
|
-// @resource icon-help https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/help.svg
|
|
|
|
-// @resource icon-image_filled https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/image_filled.svg
|
|
|
|
-// @resource icon-image https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/image.svg
|
|
|
|
-// @resource icon-link https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/link.svg
|
|
|
|
-// @resource icon-lyrics https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/lyrics.svg
|
|
|
|
-// @resource icon-reload https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/refresh.svg
|
|
|
|
-// @resource icon-skip_to https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/skip_to.svg
|
|
|
|
-// @resource icon-spinner https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/spinner.svg
|
|
|
|
-// @resource icon-upload https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/icons/upload.svg
|
|
|
|
-// @resource img-close https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/images/close.png
|
|
|
|
-// @resource img-discord https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/images/external/discord.png
|
|
|
|
-// @resource img-github https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/images/external/github.png
|
|
|
|
-// @resource img-greasyfork https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/images/external/greasyfork.png
|
|
|
|
-// @resource img-logo_dev https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/images/logo/logo_dev_48.png
|
|
|
|
-// @resource img-logo https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/images/logo/logo_48.png
|
|
|
|
-// @resource img-openuserjs https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/images/external/openuserjs.png
|
|
|
|
-// @resource trans-de_DE https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/translations/de_DE.json
|
|
|
|
-// @resource trans-en_US https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/translations/en_US.json
|
|
|
|
-// @resource trans-en_UK https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/translations/en_UK.json
|
|
|
|
-// @resource trans-es_ES https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/translations/es_ES.json
|
|
|
|
-// @resource trans-fr_FR https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/translations/fr_FR.json
|
|
|
|
-// @resource trans-hi_IN https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/translations/hi_IN.json
|
|
|
|
-// @resource trans-ja_JA https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/translations/ja_JA.json
|
|
|
|
-// @resource trans-pt_BR https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/translations/pt_BR.json
|
|
|
|
-// @resource trans-zh_CN https://raw.githubusercontent.com/Sv443/BetterYTM/a77aec56/assets/translations/zh_CN.json
|
|
|
|
|
|
+// @resource css-bundle https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/dist/BetterYTM.css
|
|
|
|
+// @resource css-above_queue_btns https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/style/aboveQueueBtns.css
|
|
|
|
+// @resource css-anchor_improvements https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/style/anchorImprovements.css
|
|
|
|
+// @resource css-fix_hdr https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/style/fixHDR.css
|
|
|
|
+// @resource css-fix_spacing https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/style/fixSpacing.css
|
|
|
|
+// @resource css-show_votes https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/style/showVotes.css
|
|
|
|
+// @resource css-vol_slider_size https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/style/volSliderSize.css
|
|
|
|
+// @resource doc-changelog https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/changelog.md
|
|
|
|
+// @resource icon-advanced_mode https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/plus_circle_small.svg
|
|
|
|
+// @resource icon-arrow_down https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/arrow_down.svg
|
|
|
|
+// @resource icon-auto_like_enabled https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/auto_like_enabled.svg
|
|
|
|
+// @resource icon-auto_like https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/auto_like.svg
|
|
|
|
+// @resource icon-clear_list https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/clear_list.svg
|
|
|
|
+// @resource icon-copy https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/copy.svg
|
|
|
|
+// @resource icon-delete https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/delete.svg
|
|
|
|
+// @resource icon-edit https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/edit.svg
|
|
|
|
+// @resource icon-error https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/error.svg
|
|
|
|
+// @resource icon-experimental https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/beaker_small.svg
|
|
|
|
+// @resource icon-globe_small https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/globe_small.svg
|
|
|
|
+// @resource icon-globe https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/globe.svg
|
|
|
|
+// @resource icon-help https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/help.svg
|
|
|
|
+// @resource icon-image_filled https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/image_filled.svg
|
|
|
|
+// @resource icon-image https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/image.svg
|
|
|
|
+// @resource icon-link https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/link.svg
|
|
|
|
+// @resource icon-lyrics https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/lyrics.svg
|
|
|
|
+// @resource icon-reload https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/refresh.svg
|
|
|
|
+// @resource icon-skip_to https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/skip_to.svg
|
|
|
|
+// @resource icon-spinner https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/spinner.svg
|
|
|
|
+// @resource icon-upload https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/icons/upload.svg
|
|
|
|
+// @resource img-close https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/images/close.png
|
|
|
|
+// @resource img-discord https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/images/external/discord.png
|
|
|
|
+// @resource img-github https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/images/external/github.png
|
|
|
|
+// @resource img-greasyfork https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/images/external/greasyfork.png
|
|
|
|
+// @resource img-logo_dev https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/images/logo/logo_dev_48.png
|
|
|
|
+// @resource img-logo https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/images/logo/logo_48.png
|
|
|
|
+// @resource img-openuserjs https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/images/external/openuserjs.png
|
|
|
|
+// @resource trans-de_DE https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/translations/de_DE.json
|
|
|
|
+// @resource trans-en_US https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/translations/en_US.json
|
|
|
|
+// @resource trans-en_UK https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/translations/en_UK.json
|
|
|
|
+// @resource trans-es_ES https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/translations/es_ES.json
|
|
|
|
+// @resource trans-fr_FR https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/translations/fr_FR.json
|
|
|
|
+// @resource trans-hi_IN https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/translations/hi_IN.json
|
|
|
|
+// @resource trans-ja_JA https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/translations/ja_JA.json
|
|
|
|
+// @resource trans-pt_BR https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/translations/pt_BR.json
|
|
|
|
+// @resource trans-zh_CN https://raw.githubusercontent.com/Sv443/BetterYTM/f1f4750/assets/translations/zh_CN.json
|
|
// @require https://cdn.jsdelivr.net/npm/@sv443-network/[email protected]/dist/index.global.js
|
|
// @require https://cdn.jsdelivr.net/npm/@sv443-network/[email protected]/dist/index.global.js
|
|
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/fuse.basic.js
|
|
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/fuse.basic.js
|
|
// @require https://cdn.jsdelivr.net/npm/[email protected]/lib/marked.umd.js
|
|
// @require https://cdn.jsdelivr.net/npm/[email protected]/lib/marked.umd.js
|
|
@@ -191,7 +191,7 @@ var PluginIntent;
|
|
const modeRaw = "development";
|
|
const modeRaw = "development";
|
|
const branchRaw = "develop";
|
|
const branchRaw = "develop";
|
|
const hostRaw = "github";
|
|
const hostRaw = "github";
|
|
-const buildNumberRaw = "a77aec56";
|
|
|
|
|
|
+const buildNumberRaw = "f1f4750";
|
|
/** The mode in which the script was built (production or development) */
|
|
/** The mode in which the script was built (production or development) */
|
|
const mode = (modeRaw.match(/^#{{.+}}$/) ? "production" : modeRaw);
|
|
const mode = (modeRaw.match(/^#{{.+}}$/) ? "production" : modeRaw);
|
|
/** The branch to use in various URLs that point to the GitHub repo */
|
|
/** The branch to use in various URLs that point to the GitHub repo */
|
|
@@ -1042,6 +1042,20 @@ function initSiteEvents() {
|
|
window.addEventListener("bytm:ready", () => {
|
|
window.addEventListener("bytm:ready", () => {
|
|
runIntervalChecks();
|
|
runIntervalChecks();
|
|
setInterval(runIntervalChecks, 100);
|
|
setInterval(runIntervalChecks, 100);
|
|
|
|
+ addSelectorListener("mainPanel", "ytmusic-player #song-video #movie_player .ytp-title-text > a", {
|
|
|
|
+ listener(el) {
|
|
|
|
+ const urlRefObs = new MutationObserver(([{ target }]) => {
|
|
|
|
+ var _a;
|
|
|
|
+ if (!target || !((_a = target === null || target === void 0 ? void 0 : target.href) === null || _a === void 0 ? void 0 : _a.includes("/watch")))
|
|
|
|
+ return;
|
|
|
|
+ const watchId = new URL(target.href).searchParams.get("v");
|
|
|
|
+ checkWatchIdChange(watchId);
|
|
|
|
+ });
|
|
|
|
+ urlRefObs.observe(el, {
|
|
|
|
+ attributeFilter: ["href"],
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}, {
|
|
}, {
|
|
once: true,
|
|
once: true,
|
|
});
|
|
});
|
|
@@ -1066,16 +1080,19 @@ function emitSiteEvent(key, ...args) {
|
|
emitInterface(`bytm:siteEvent:${key}`, args);
|
|
emitInterface(`bytm:siteEvent:${key}`, args);
|
|
}
|
|
}
|
|
//#region other
|
|
//#region other
|
|
|
|
+/** Checks if the watch ID has changed and emits a `watchIdChanged` siteEvent if it has */
|
|
|
|
+function checkWatchIdChange(watchId) {
|
|
|
|
+ const newWatchId = watchId !== null && watchId !== void 0 ? watchId : new URL(location.href).searchParams.get("v");
|
|
|
|
+ if (newWatchId && newWatchId !== lastWatchId) {
|
|
|
|
+ info(`Detected watch ID change - old ID: "${lastWatchId}" - new ID: "${newWatchId}"`);
|
|
|
|
+ emitSiteEvent("watchIdChanged", newWatchId, lastWatchId);
|
|
|
|
+ lastWatchId = newWatchId;
|
|
|
|
+ }
|
|
|
|
+}
|
|
/** Periodically called to check for changes in the URL and emit associated siteEvents */
|
|
/** Periodically called to check for changes in the URL and emit associated siteEvents */
|
|
function runIntervalChecks() {
|
|
function runIntervalChecks() {
|
|
- if (location.pathname.startsWith("/watch")) {
|
|
|
|
- const newWatchId = new URL(location.href).searchParams.get("v");
|
|
|
|
- if (newWatchId && newWatchId !== lastWatchId) {
|
|
|
|
- info(`Detected watch ID change - old ID: "${lastWatchId}" - new ID: "${newWatchId}"`);
|
|
|
|
- emitSiteEvent("watchIdChanged", newWatchId, lastWatchId);
|
|
|
|
- lastWatchId = newWatchId;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (!lastWatchId)
|
|
|
|
+ checkWatchIdChange();
|
|
if (location.pathname !== lastPathname) {
|
|
if (location.pathname !== lastPathname) {
|
|
emitSiteEvent("pathChanged", String(location.pathname), lastPathname);
|
|
emitSiteEvent("pathChanged", String(location.pathname), lastPathname);
|
|
lastPathname = String(location.pathname);
|
|
lastPathname = String(location.pathname);
|
|
@@ -3551,6 +3568,7 @@ function initThumbnailOverlay() {
|
|
toggleBtnElem.href = thumbUrl;
|
|
toggleBtnElem.href = thumbUrl;
|
|
if (thumbImgElem)
|
|
if (thumbImgElem)
|
|
thumbImgElem.src = thumbUrl;
|
|
thumbImgElem.src = thumbUrl;
|
|
|
|
+ log("Applied thumbnail URL to overlay:", thumbUrl);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
error("Couldn't get thumbnail URL for watch ID", watchId);
|
|
error("Couldn't get thumbnail URL for watch ID", watchId);
|
|
@@ -6093,10 +6111,8 @@ function validatePluginDef(pluginDef) {
|
|
function registerPlugin(def) {
|
|
function registerPlugin(def) {
|
|
var _a, _b;
|
|
var _a, _b;
|
|
const validationErrors = validatePluginDef(def);
|
|
const validationErrors = validatePluginDef(def);
|
|
- if (validationErrors) {
|
|
|
|
- error(`Failed to register plugin${((_a = def === null || def === void 0 ? void 0 : def.plugin) === null || _a === void 0 ? void 0 : _a.name) ? ` '${(_b = def === null || def === void 0 ? void 0 : def.plugin) === null || _b === void 0 ? void 0 : _b.name}'` : ""} with invalid definition:\n- ${validationErrors.join("\n- ")}`, LogLevel.Info);
|
|
|
|
- throw new Error(`Invalid plugin definition:\n- ${validationErrors.join("\n- ")}`);
|
|
|
|
- }
|
|
|
|
|
|
+ if (validationErrors)
|
|
|
|
+ throw new Error(`Failed to register plugin${((_a = def === null || def === void 0 ? void 0 : def.plugin) === null || _a === void 0 ? void 0 : _a.name) ? ` '${(_b = def === null || def === void 0 ? void 0 : def.plugin) === null || _b === void 0 ? void 0 : _b.name}'` : ""} with invalid definition:\n- ${validationErrors.join("\n- ")}`);
|
|
const events = new NanoEmitter({ publicEmit: true });
|
|
const events = new NanoEmitter({ publicEmit: true });
|
|
const token = randomId(32, 36);
|
|
const token = randomId(32, 36);
|
|
const { plugin: { name } } = def;
|
|
const { plugin: { name } } = def;
|