prevent injecting frontend multiple times
This commit is contained in:
parent
9adbc80a70
commit
61a96e327a
@ -54,13 +54,16 @@ function injectSearchFrontend() {
|
|||||||
async function main() {
|
async function main() {
|
||||||
await yomichan.prepare();
|
await yomichan.prepare();
|
||||||
|
|
||||||
|
let optionsApplied = false;
|
||||||
|
|
||||||
const applyOptions = async () => {
|
const applyOptions = async () => {
|
||||||
const optionsContext = {
|
const optionsContext = {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
url: window.location.href
|
url: window.location.href
|
||||||
};
|
};
|
||||||
const options = await apiOptionsGet(optionsContext);
|
const options = await apiOptionsGet(optionsContext);
|
||||||
if (!options.scanning.enableOnSearchPage) { return; }
|
if (!options.scanning.enableOnSearchPage || optionsApplied) { return; }
|
||||||
|
optionsApplied = true;
|
||||||
|
|
||||||
window.frontendInitializationData = {depth: 1, proxy: false};
|
window.frontendInitializationData = {depth: 1, proxy: false};
|
||||||
injectSearchFrontend();
|
injectSearchFrontend();
|
||||||
|
@ -44,15 +44,24 @@ async function popupNestedInitialize(id, depth, parentFrameId, url) {
|
|||||||
}
|
}
|
||||||
popupNestedInitialized = true;
|
popupNestedInitialized = true;
|
||||||
|
|
||||||
|
let optionsApplied = false;
|
||||||
|
|
||||||
const applyOptions = async () => {
|
const applyOptions = async () => {
|
||||||
const optionsContext = {depth, url};
|
const optionsContext = {depth, url};
|
||||||
const options = await apiOptionsGet(optionsContext);
|
const options = await apiOptionsGet(optionsContext);
|
||||||
const popupNestingMaxDepth = options.scanning.popupNestingMaxDepth;
|
const popupNestingMaxDepth = options.scanning.popupNestingMaxDepth;
|
||||||
|
|
||||||
if (!(typeof popupNestingMaxDepth === 'number' && typeof depth === 'number' && depth < popupNestingMaxDepth)) {
|
const maxPopupDepthExceeded = !(
|
||||||
|
typeof popupNestingMaxDepth === 'number' &&
|
||||||
|
typeof depth === 'number' &&
|
||||||
|
depth < popupNestingMaxDepth
|
||||||
|
);
|
||||||
|
if (maxPopupDepthExceeded || optionsApplied) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
optionsApplied = true;
|
||||||
|
|
||||||
window.frontendInitializationData = {id, depth, parentFrameId, url, proxy: true};
|
window.frontendInitializationData = {id, depth, parentFrameId, url, proxy: true};
|
||||||
injectPopupNested();
|
injectPopupNested();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user