Correção na chamada das APIs via iframe
This commit is contained in:
@@ -181,7 +181,7 @@ async function executeSpaFrameFetch({ senderTabId, url, options = {} }) {
|
|||||||
return executeSpaFrameScriptFetch(senderTabId, url, options);
|
return executeSpaFrameScriptFetch(senderTabId, url, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ensureSpaFrameElementInTab(tabId) {
|
async function ensureSpaFrameElementInTab(tabId, options = {}) {
|
||||||
await chrome.scripting.executeScript({
|
await chrome.scripting.executeScript({
|
||||||
target: { tabId, frameIds: [0] },
|
target: { tabId, frameIds: [0] },
|
||||||
world: "MAIN",
|
world: "MAIN",
|
||||||
@@ -189,8 +189,9 @@ async function ensureSpaFrameElementInTab(tabId) {
|
|||||||
SPA_WORKBENCH_FRAME_HOST_ID,
|
SPA_WORKBENCH_FRAME_HOST_ID,
|
||||||
SPA_WORKBENCH_FRAME_ID,
|
SPA_WORKBENCH_FRAME_ID,
|
||||||
SPA_WORKBENCH_FRAME_URL,
|
SPA_WORKBENCH_FRAME_URL,
|
||||||
|
Boolean(options.forceReload),
|
||||||
],
|
],
|
||||||
func: (hostId, frameId, frameUrl) => {
|
func: (hostId, frameId, frameUrl, forceReload) => {
|
||||||
const desiredParent = document.body || document.documentElement;
|
const desiredParent = document.body || document.documentElement;
|
||||||
|
|
||||||
if (!desiredParent) {
|
if (!desiredParent) {
|
||||||
@@ -250,7 +251,16 @@ async function ensureSpaFrameElementInTab(tabId) {
|
|||||||
host.appendChild(frame);
|
host.appendChild(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!frame.src || frame.src === "about:blank" || frame.src !== frameUrl) {
|
if (
|
||||||
|
forceReload ||
|
||||||
|
!frame.src ||
|
||||||
|
frame.src === "about:blank" ||
|
||||||
|
frame.src !== frameUrl
|
||||||
|
) {
|
||||||
|
if (forceReload) {
|
||||||
|
frame.src = "about:blank";
|
||||||
|
}
|
||||||
|
|
||||||
frame.src = frameUrl;
|
frame.src = frameUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,8 +272,23 @@ async function ensureSpaFrameElementInTab(tabId) {
|
|||||||
async function waitForSpaFramePresent(tabId) {
|
async function waitForSpaFramePresent(tabId) {
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
let lastFrames = "";
|
let lastFrames = "";
|
||||||
|
let lastEnsureAt = 0;
|
||||||
|
let forceReloaded = false;
|
||||||
|
|
||||||
while (Date.now() - startedAt < 45000) {
|
while (Date.now() - startedAt < 45000) {
|
||||||
|
const elapsed = Date.now() - startedAt;
|
||||||
|
|
||||||
|
if (Date.now() - lastEnsureAt > 2500) {
|
||||||
|
await ensureSpaFrameElementInTab(tabId, {
|
||||||
|
forceReload: elapsed > 7000 && !forceReloaded,
|
||||||
|
});
|
||||||
|
lastEnsureAt = Date.now();
|
||||||
|
|
||||||
|
if (elapsed > 7000) {
|
||||||
|
forceReloaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const frames = await getFrameHints(tabId).catch(() => []);
|
const frames = await getFrameHints(tabId).catch(() => []);
|
||||||
const spaFrame = frames.find((frame) => isSpaFrameHint(frame));
|
const spaFrame = frames.find((frame) => isSpaFrameHint(frame));
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Arch Panel Injector",
|
"name": "Arch Panel Injector",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"description": "Insere o botao Arch panel no header do Oracle Workload Workbench.",
|
"description": "Insere o botao Arch panel no header do Oracle Workload Workbench.",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"cookies",
|
"cookies",
|
||||||
@@ -174,5 +174,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user