From de43b990f2c7e633080db67ac887515c67e703fc Mon Sep 17 00:00:00 2001 From: Shiba <44804845+DeepDoge@users.noreply.github.com> Date: Mon, 25 Jul 2022 23:25:33 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=A3=20button=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/ytContent.tsx | 51 ++++++++++++++++++++++++++------------- src/settings/index.ts | 6 ++--- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/scripts/ytContent.tsx b/src/scripts/ytContent.tsx index 65c2b5f..aad404f 100644 --- a/src/scripts/ytContent.tsx +++ b/src/scripts/ytContent.tsx @@ -38,31 +38,37 @@ import { getExtensionSettingsAsync, getSourcePlatfromSettingsFromHostname, getTa if (!target || !source) return null const url = getLbryUrlByTarget(target) - return
+ return
findVideoElementAwait(source).then((videoElement) => { videoElement.pause() })} > - + {target.type === 'channel' ? 'Channel on' : 'Watch on'} {target.platform.button.platformNameText}
@@ -72,17 +78,25 @@ import { getExtensionSettingsAsync, getSourcePlatfromSettingsFromHostname, getTa if (!target || !source) return null const url = getLbryUrlByTarget(target) - return
+ return
- + {target.type === 'channel' ? 'Channel on' : 'Watch on'} {target.platform.button.platformNameText}
@@ -110,16 +123,20 @@ import { getExtensionSettingsAsync, getSourcePlatfromSettingsFromHostname, getTa null if (!mountPlayerButtonBefore) render(, playerButtonMountPoint) else { - if (mountPlayerButtonBefore.previousSibling !== playerButtonMountPoint) + if (playerButtonMountPoint.getAttribute('data-id') !== params.source.id) { mountPlayerButtonBefore.parentElement?.insertBefore(playerButtonMountPoint, mountPlayerButtonBefore) + playerButtonMountPoint.setAttribute('data-id', params.source.id) + } render(, playerButtonMountPoint) } const mountButtonBefore = document.querySelector(params.source.platform.htmlQueries.mountPoints.mountButtonBefore[params.source.type]) if (!mountButtonBefore) render(, playerButtonMountPoint) else { - if (mountButtonBefore.previousSibling !== buttonMountPoint) + if (buttonMountPoint.getAttribute('data-id') !== params.source.id) { mountButtonBefore.parentElement?.insertBefore(buttonMountPoint, mountButtonBefore) + buttonMountPoint.setAttribute('data-id', params.source.id) + } render(, buttonMountPoint) } } diff --git a/src/settings/index.ts b/src/settings/index.ts index e71dd40..2ea575a 100644 --- a/src/settings/index.ts +++ b/src/settings/index.ts @@ -84,7 +84,7 @@ export const targetPlatformSettings = { icon: chrome.runtime.getURL('assets/icons/lbry/madiator-logo.svg'), style: { button: { flexDirection: 'row-reverse' }, - icon: { transform: 'scale(1.2)' } + icon: { } } } }), @@ -137,9 +137,9 @@ export const sourcePlatfromSettings = { mountPoints: { mountButtonBefore: { video: 'ytd-video-owner-renderer~#subscribe-button', - channel: '#channel-header-container #buttons' + channel: '#channel-header-container #buttons #subscribe-button' }, - mountPlayerButtonBefore: 'ytd-player .ytp-right-controls', + mountPlayerButtonBefore: 'ytd-watch-flexy ytd-player .ytp-right-controls', }, videoPlayer: '#ytd-player video', videoDescription: 'ytd-video-secondary-info-renderer #description',