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