fix: some js syntax

This commit is contained in:
Gabe Yuan
2024-02-02 15:44:44 +08:00
parent de5f61126d
commit 0973a0b60e
3 changed files with 9 additions and 9 deletions

View File

@@ -42,7 +42,7 @@ export const syncSubRules = async (url) => {
* @returns * @returns
*/ */
export const syncAllSubRules = async (subrulesList) => { export const syncAllSubRules = async (subrulesList) => {
for (let subrules of subrulesList) { for (const subrules of subrulesList) {
try { try {
await syncSubRules(subrules.url); await syncSubRules(subrules.url);
await updateSyncDataCache(subrules.url); await updateSyncDataCache(subrules.url);

View File

@@ -473,7 +473,7 @@ export class Translator {
// 专业术语 // 专业术语
if (this._terms.length > 0) { if (this._terms.length > 0) {
for (let term of this._terms) { for (const term of this._terms) {
const re = new RegExp(term[0], "g"); const re = new RegExp(term[0], "g");
q = q.replace(re, (t) => { q = q.replace(re, (t) => {
const text = `[${keeps.length}]`; const text = `[${keeps.length}]`;

View File

@@ -69,8 +69,8 @@ function brFixer(node, tag = "p") {
} }
node.setAttribute(fixedSign, "true"); node.setAttribute(fixedSign, "true");
var gapTags = ["BR", "WBR"]; const gapTags = ["BR", "WBR"];
var newlineTags = [ const newlineTags = [
"DIV", "DIV",
"UL", "UL",
"OL", "OL",
@@ -87,7 +87,7 @@ function brFixer(node, tag = "p") {
"TABLE", "TABLE",
]; ];
var html = ""; let html = "";
node.childNodes.forEach(function (child, index) { node.childNodes.forEach(function (child, index) {
if (index === 0) { if (index === 0) {
html += `<${tag} class="kiss-p">`; html += `<${tag} class="kiss-p">`;
@@ -160,7 +160,7 @@ const fixerMap = {
* @param {*} rootSelector * @param {*} rootSelector
*/ */
function run(selector, fixer, rootSelector) { function run(selector, fixer, rootSelector) {
var mutaObserver = new MutationObserver(function (mutations) { const mutaObserver = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) { mutations.forEach(function (mutation) {
mutation.addedNodes.forEach(function (addNode) { mutation.addedNodes.forEach(function (addNode) {
if (addNode && addNode.querySelectorAll) { if (addNode && addNode.querySelectorAll) {
@@ -172,7 +172,7 @@ function run(selector, fixer, rootSelector) {
}); });
}); });
var rootNodes = [document]; let rootNodes = [document];
if (rootSelector) { if (rootSelector) {
rootNodes = document.querySelectorAll(rootSelector); rootNodes = document.querySelectorAll(rootSelector);
} }
@@ -241,8 +241,8 @@ export async function matchFixer(href, { injectWebfix }) {
const userSites = await getWebfixRulesWithDefault(); const userSites = await getWebfixRulesWithDefault();
const subSites = await loadOrFetchWebfix(process.env.REACT_APP_WEBFIXURL); const subSites = await loadOrFetchWebfix(process.env.REACT_APP_WEBFIXURL);
const sites = [...userSites, ...subSites]; const sites = [...userSites, ...subSites];
for (var i = 0; i < sites.length; i++) { for (let i = 0; i < sites.length; i++) {
var site = sites[i]; const site = sites[i];
if (isMatch(href, site.pattern) && fixerMap[site.fixer]) { if (isMatch(href, site.pattern) && fixerMap[site.fixer]) {
return site; return site;
} }