diff --git a/src/plugin/syringe/index.ts b/src/plugin/syringe/index.ts index ff73fba9f..da50df0e1 100644 --- a/src/plugin/syringe/index.ts +++ b/src/plugin/syringe/index.ts @@ -37,6 +37,7 @@ function childNodes(node: Node): Node[] { const skipNodeName = new Set(['TITLE', 'LINK', 'META', 'HEAD', 'SCRIPT', 'BR', 'HR', 'STYLE', 'MARK']); const ignoreClassName = `eh-syringe-ignore`; const skipElementMatcher = `.${ignoreClassName}, .${ignoreClassName} *, [translate=no], [translate=no] :not([translate=yes])`; +const hAthFontStyleId = 'ehs-hath-font-style'; declare global { interface Window { @@ -259,6 +260,7 @@ export class Syringe { this.config = config; this.storage.set('config', config); this.setRootAttrs(); + this.setPageStyles(); this.translateTags(); } @@ -304,6 +306,7 @@ export class Syringe { this.documentEnd = true; }); this.setRootAttrs(); + this.setPageStyles(); const { body } = document; if (body) { const nodes = childNodes(body); @@ -363,6 +366,8 @@ export class Syringe { readonly isEh = isEh(location.hostname); readonly isRepo = isRepo(location.hostname); readonly isWiki = isWiki(location.hostname); + readonly isHentaiAtHome = location.pathname === '/hentaiathome.php'; + setRootAttrs(): void { const node = document.documentElement; if (!node) return; @@ -399,6 +404,19 @@ export class Syringe { node.classList.add(`ehs-image-level-${this.config.introduceImageLevel}`); } + private setPageStyles(): void { + const style = document.getElementById(hAthFontStyleId); + if (!this.isHentaiAtHome || !this.config.translateUi) { + style?.remove(); + return; + } + if (style) return; + const nextStyle = document.createElement('style'); + nextStyle.id = hAthFontStyleId; + nextStyle.textContent = '#hct { font-family: sans-serif; }'; + (document.head ?? document.documentElement)?.append(nextStyle); + } + translateNode(node: Node): void { const { nodeName } = node; if (!nodeName || skipNodeName.has(nodeName)) return;