mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 14:37:23 +03:00
Fix localize function not working for title of direct children
This commit is contained in:
@@ -65,14 +65,12 @@ export function getHashParams(): Record<string, unknown> {
|
|||||||
|
|
||||||
export function localizeHtmlPage(): void {
|
export function localizeHtmlPage(): void {
|
||||||
//Localize by replacing __MSG_***__ meta tags
|
//Localize by replacing __MSG_***__ meta tags
|
||||||
const localizedMessage = getLocalizedMessage(document.title);
|
const localizedTitle = getLocalizedMessage(document.title);
|
||||||
if (localizedMessage) document.title = localizedMessage;
|
if (localizedTitle) document.title = localizedTitle;
|
||||||
const objects = document.getElementsByClassName("sponsorBlockPageBody")[0].children;
|
|
||||||
for (let j = 0; j < objects.length; j++) {
|
const body = document.querySelector(".sponsorBlockPageBody");
|
||||||
const obj = objects[j];
|
const localizedMessage = getLocalizedMessage(body.innerHTML.toString());
|
||||||
const localizedMessage = getLocalizedMessage(obj.innerHTML.toString());
|
if (localizedMessage) body.innerHTML = localizedMessage;
|
||||||
if (localizedMessage) obj.innerHTML = localizedMessage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLocalizedMessage(text: string): string | false {
|
export function getLocalizedMessage(text: string): string | false {
|
||||||
|
|||||||
Reference in New Issue
Block a user