chore: improve readability 2

This commit is contained in:
Su-Yong
2025-10-12 14:34:36 +09:00
parent ffa61687bf
commit b8e0d53ef3
6 changed files with 48 additions and 47 deletions

View File

@ -411,12 +411,12 @@ async function onApiLoaded() {
/**
* Original still using ES5, so we need to define custom elements using ES5 style
*/
const defineYTMDTransElements = () => {
const YTMDTrans = function () {};
const definePearTransElements = () => {
const PearTrans = function () {};
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
YTMDTrans.prototype = Object.create(HTMLElement.prototype);
PearTrans.prototype = Object.create(HTMLElement.prototype);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
YTMDTrans.prototype.connectedCallback = function () {
PearTrans.prototype.connectedCallback = function () {
const that = this as HTMLElement;
const key = that.getAttribute('key');
if (key) {
@ -427,8 +427,8 @@ const defineYTMDTransElements = () => {
}
};
customElements.define(
'ytmd-trans',
YTMDTrans as unknown as CustomElementConstructor,
'pear-trans',
PearTrans as unknown as CustomElementConstructor,
);
};
@ -438,7 +438,7 @@ const preload = async () => {
window.i18n = {
t: i18t.bind(i18next),
};
defineYTMDTransElements();
definePearTransElements();
if (document.body?.dataset?.os) {
document.body.dataset.os = navigator.userAgent;
}