feat(scripts): implement content state methods
This commit is contained in:
parent
f4d87d053b
commit
f0a4673ce8
@ -59,8 +59,7 @@ const fix = () => {
|
|||||||
if (body) body.style.setProperty("overflow-y", "unset", "important");
|
if (body) body.style.setProperty("overflow-y", "unset", "important");
|
||||||
if (facebook) facebook.style.setProperty("position", "unset", "important");
|
if (facebook) facebook.style.setProperty("position", "unset", "important");
|
||||||
if (html) html.style.setProperty("overflow-y", "unset", "important");
|
if (html) html.style.setProperty("overflow-y", "unset", "important");
|
||||||
if (body && !loading) body.style.setProperty("opacity", "1");
|
if (!loading) dispatch({ state: "ready", type: "UPDATE_STATE" });
|
||||||
if (html && !loading) html.style.setProperty("background-color", "initial");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -148,7 +147,7 @@ const runTasks = () => {
|
|||||||
fix();
|
fix();
|
||||||
removeFromCache();
|
removeFromCache();
|
||||||
if (attempts <= 5) removeFromNetwork();
|
if (attempts <= 5) removeFromNetwork();
|
||||||
if (document.readyState !== "loading") attempts += 1;
|
if (document.readyState === "complete") attempts += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attempts > 20) {
|
if (attempts > 20) {
|
||||||
@ -163,20 +162,17 @@ const runTasks = () => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
{ hostname: document.location.hostname, type: "GET_CACHE" },
|
{ hostname: document.location.hostname, type: "GET_CACHE" },
|
||||||
null,
|
null,
|
||||||
async ({ enabled, matches }) => {
|
({ enabled, matches }) => {
|
||||||
dispatch({ type: "ENABLE_POPUP" });
|
dispatch({ type: "ENABLE_POPUP" });
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
dispatch({ state: "loading", type: "UPDATE_STATE" });
|
||||||
selectorsFromCache = matches;
|
selectorsFromCache = matches;
|
||||||
dispatch({ type: "ENABLE_ICON" });
|
dispatch({ type: "ENABLE_ICON" });
|
||||||
dispatch({ type: "GET_LIST" }, null, async ({ selectors }) => {
|
dispatch({ type: "GET_LIST" }, null, ({ selectors }) => {
|
||||||
selectorsFromNetwork = selectors;
|
selectorsFromNetwork = selectors;
|
||||||
intervalId = setInterval(runTasks, 500);
|
intervalId = setInterval(runTasks, 500);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
document.body.style.setProperty("opacity", "1", "important");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user