mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +03:00
Move some options page funcs to shared lib
This commit is contained in:
@@ -93,27 +93,4 @@ export function getExistingChapters(currentVideoID: VideoID, duration: number):
|
||||
}
|
||||
|
||||
return chapters;
|
||||
}
|
||||
|
||||
export function localizeHtmlPage(): void {
|
||||
//Localize by replacing __MSG_***__ meta tags
|
||||
const localizedTitle = getLocalizedMessage(document.title);
|
||||
if (localizedTitle) document.title = localizedTitle;
|
||||
|
||||
const body = document.querySelector(".sponsorBlockPageBody");
|
||||
const localizedMessage = getLocalizedMessage(body.innerHTML.toString());
|
||||
if (localizedMessage) body.innerHTML = localizedMessage;
|
||||
}
|
||||
|
||||
export function getLocalizedMessage(text: string): string | false {
|
||||
const valNewH = text.replace(/__MSG_(\w+)__/g, function(match, v1) {
|
||||
return v1 ? chrome.i18n.getMessage(v1).replace(/</g, "<")
|
||||
.replace(/"/g, """).replace(/\n/g, "<br/>") : "";
|
||||
});
|
||||
|
||||
if (valNewH != text) {
|
||||
return valNewH;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user