Skip to content

Commit

Permalink
Use crowdsourced title even if formatter is disabled
Browse files Browse the repository at this point in the history
- If the auto-formatter is disabled in the options and a custom title for a video is only changing capitalisation, the addon would previously show the original title instead.
  • Loading branch information
mschae23 committed May 16, 2024
1 parent bd4c8ec commit 4d5b657
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/titles/titleRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ export async function replaceTitle(element: HTMLElement, videoID: VideoID, showC

const title = titleData?.title;
const originalTitle = originalTitleElement?.textContent?.trim?.() ?? "";

Check failure on line 73 in src/titles/titleRenderer.ts

View workflow job for this annotation

GitHub Actions / Create artifacts

'originalTitle' is assigned a value but never used
if (title && await shouldUseCrowdsourcedTitles(videoID)
// If there are just formatting changes, and the user doesn't want those, don't replace
&& (await getTitleFormatting(videoID) !== TitleFormatting.Disable || originalTitle.toLowerCase() !== title.toLowerCase())
&& (await getTitleFormatting(videoID) !== TitleFormatting.Disable
|| await shouldCleanEmojis(videoID) || cleanEmojis(originalTitle.toLowerCase()) !== cleanEmojis(title.toLowerCase()))) {
if (title && await shouldUseCrowdsourcedTitles(videoID)) {
const formattedTitle = await formatTitle(title, true, videoID);
if (!await isOnCorrectVideo(element, brandingLocation, videoID)) return false;

Expand Down
3 changes: 1 addition & 2 deletions src/videoBranding/videoBranding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ export async function handleShowOriginalButton(element: HTMLElement, videoID: Vi
if (result || (await Promise.all(promises)).some((r) => r)) {
const title = await getVideoTitleIncludingUnsubmitted(videoID, brandingLocation);
const originalTitle = getOriginalTitleElement(element, brandingLocation)?.textContent;

Check failure on line 292 in src/videoBranding/videoBranding.ts

View workflow job for this annotation

GitHub Actions / Create artifacts

'originalTitle' is assigned a value but never used
const customTitle = title && !title.original
&& (!originalTitle || (cleanResultingTitle(cleanEmojis(title.title))).toLowerCase() !== (cleanResultingTitle(cleanEmojis(originalTitle))).toLowerCase())
const customTitle = title && !title.original
&& await shouldUseCrowdsourcedTitles(videoID);

if (!customTitle && !Config.config!.showIconForFormattedTitles && !await promises[1]) {
Expand Down

0 comments on commit 4d5b657

Please sign in to comment.