mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-13 23:17:05 +03:00
Move some options page funcs to shared lib
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { localizeHtmlPage } from "@ajayyy/maze-utils/lib/setup";
|
||||
import Config from "./config";
|
||||
import { showDonationLink } from "./utils/configUtils";
|
||||
|
||||
import { localizeHtmlPage } from "./utils/pageUtils";
|
||||
import { waitFor } from "@ajayyy/maze-utils";
|
||||
|
||||
window.addEventListener('DOMContentLoaded', init);
|
||||
|
||||
@@ -13,7 +13,7 @@ import CategoryChooser from "./render/CategoryChooser";
|
||||
import UnsubmittedVideos from "./render/UnsubmittedVideos";
|
||||
import KeybindComponent from "./components/options/KeybindComponent";
|
||||
import { showDonationLink } from "./utils/configUtils";
|
||||
import { localizeHtmlPage } from "./utils/pageUtils";
|
||||
import { localizeHtmlPage } from "@ajayyy/maze-utils/lib/setup";
|
||||
import { StorageChangesObject } from "@ajayyy/maze-utils/lib/config";
|
||||
import { getHash } from "@ajayyy/maze-utils/lib/hash";
|
||||
import { isFirefoxOrSafari } from "@ajayyy/maze-utils";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Config from "./config";
|
||||
import Utils from "./utils";
|
||||
import { localizeHtmlPage } from "./utils/pageUtils";
|
||||
import { localizeHtmlPage } from "@ajayyy/maze-utils/lib/setup";
|
||||
const utils = new Utils();
|
||||
|
||||
// This is needed, if Config is not imported before Utils, things break.
|
||||
|
||||
@@ -22,7 +22,7 @@ import { showDonationLink } from "./utils/configUtils";
|
||||
import { AnimationUtils } from "./utils/animationUtils";
|
||||
import { GenericUtils } from "./utils/genericUtils";
|
||||
import { shortCategoryName } from "./utils/categoryUtils";
|
||||
import { localizeHtmlPage } from "./utils/pageUtils";
|
||||
import { localizeHtmlPage } from "@ajayyy/maze-utils/lib/setup";
|
||||
import { exportTimes } from "./utils/exporter";
|
||||
import GenericNotice from "./render/GenericNotice";
|
||||
import { getFormattedTime } from "@ajayyy/maze-utils/lib/formating";
|
||||
|
||||
@@ -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