fix: run webfix before translate

This commit is contained in:
Gabe Yuan
2023-12-27 15:44:02 +08:00
parent d2d18a2384
commit 748f2002ab
3 changed files with 34 additions and 16 deletions

View File

@@ -13,6 +13,7 @@ import {
import Content from "../views/Content";
import { updateFetchPool, clearFetchPool } from "./fetch";
import { debounce, genEventName } from "./utils";
import { runFixer } from "./webfix";
/**
* 翻译类
@@ -20,6 +21,7 @@ import { debounce, genEventName } from "./utils";
export class Translator {
_rule = {};
_setting = {};
_fixerSetting = null;
_rootNodes = new Set();
_tranNodes = new Map();
_skipNodeNames = [
@@ -91,13 +93,14 @@ export class Translator {
};
};
constructor(rule, setting) {
constructor(rule, setting, fixerSetting) {
const { fetchInterval, fetchLimit } = setting;
updateFetchPool(fetchInterval, fetchLimit);
this._overrideAttachShadow();
this._setting = setting;
this._rule = rule;
this._fixerSetting = fixerSetting;
if (rule.transOpen === "true") {
this._register();
@@ -235,6 +238,11 @@ export class Translator {
return;
}
// webfix
if (this._fixerSetting) {
runFixer(this._fixerSetting);
}
// 搜索节点
this._queryNodes();