user webfix rules
This commit is contained in:
@@ -375,11 +375,11 @@ export const I18N = {
|
||||
zh: `选择器`,
|
||||
en: `Selector`,
|
||||
},
|
||||
rootSelector: {
|
||||
root_selector: {
|
||||
zh: `根选择器`,
|
||||
en: `Root Selector`,
|
||||
},
|
||||
fixerFunction: {
|
||||
fixer_function: {
|
||||
zh: `修复函数`,
|
||||
en: `Fixer Function`,
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isMatch } from "./utils";
|
||||
import { getWebfix, setWebfix } from "./storage";
|
||||
import { getWebfix, setWebfix, getWebfixRulesWithDefault } from "./storage";
|
||||
import { apiFetch } from "../apis";
|
||||
|
||||
/**
|
||||
@@ -202,12 +202,12 @@ export const loadOrFetchWebfix = async (url) => {
|
||||
*/
|
||||
export async function runWebfix({ injectWebfix }) {
|
||||
try {
|
||||
if (!injectWebfix) {
|
||||
return;
|
||||
}
|
||||
|
||||
const href = document.location.href;
|
||||
const sites = await loadOrFetchWebfix(process.env.REACT_APP_WEBFIXURL);
|
||||
let sites = await getWebfixRulesWithDefault();
|
||||
if (injectWebfix) {
|
||||
const subSites = await loadOrFetchWebfix(process.env.REACT_APP_WEBFIXURL);
|
||||
sites = [...sites, ...subSites];
|
||||
}
|
||||
for (var i = 0; i < sites.length; i++) {
|
||||
var site = sites[i];
|
||||
if (isMatch(href, site.pattern)) {
|
||||
|
||||
@@ -119,7 +119,7 @@ function WebfixFields({ rule, webfix, setShow }) {
|
||||
/>
|
||||
<TextField
|
||||
size="small"
|
||||
label={i18n("rootSelector")}
|
||||
label={i18n("root_selector")}
|
||||
error={!!errors.rootSelector}
|
||||
helperText={errors.rootSelector}
|
||||
name="rootSelector"
|
||||
@@ -146,7 +146,7 @@ function WebfixFields({ rule, webfix, setShow }) {
|
||||
size="small"
|
||||
name="fixer"
|
||||
value={fixer}
|
||||
label={i18n("fixerFunction")}
|
||||
label={i18n("fixer_function")}
|
||||
disabled={disabled}
|
||||
onChange={handleChange}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user