🚨 Lint
This commit is contained in:
@@ -1,16 +1,17 @@
|
|||||||
import AxiosStrategy from "./strategies/AxiosStrategy";
|
import AxiosStrategy from "./strategies/AxiosStrategy";
|
||||||
import ExtensionStrategy from "./strategies/ExtensionStrategy";
|
import ExtensionStrategy from "./strategies/ExtensionStrategy";
|
||||||
import FirefoxStrategy from "./strategies/FirefoxStrategy";
|
import FirefoxStrategy from "./strategies/FirefoxStrategy";
|
||||||
import ChromeStrategy, { hasChromeExtensionInstalled } from "./strategies/ChromeStrategy";
|
import ChromeStrategy, {
|
||||||
|
hasChromeExtensionInstalled
|
||||||
|
} from "./strategies/ChromeStrategy";
|
||||||
|
|
||||||
const isExtensionsAllowed = ({ state }) => {
|
const isExtensionsAllowed = ({ state }) =>
|
||||||
return typeof state.postwoman.settings.EXTENSIONS_ENABLED === 'undefined'
|
typeof state.postwoman.settings.EXTENSIONS_ENABLED === "undefined" ||
|
||||||
|| state.postwoman.settings.EXTENSIONS_ENABLED;
|
state.postwoman.settings.EXTENSIONS_ENABLED;
|
||||||
}
|
|
||||||
|
|
||||||
const runAppropriateStrategy = (req, store) => {
|
const runAppropriateStrategy = (req, store) => {
|
||||||
if (isExtensionsAllowed(store)) {
|
if (isExtensionsAllowed(store)) {
|
||||||
if (typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== 'undefined') {
|
if (typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined") {
|
||||||
return ExtensionStrategy(req, store);
|
return ExtensionStrategy(req, store);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ const runAppropriateStrategy = (req, store) => {
|
|||||||
// Chrome Provides a chrome object for scripts to access
|
// Chrome Provides a chrome object for scripts to access
|
||||||
// Check its availability to say whether you are in Google Chrome
|
// Check its availability to say whether you are in Google Chrome
|
||||||
if (window.chrome && hasChromeExtensionInstalled()) {
|
if (window.chrome && hasChromeExtensionInstalled()) {
|
||||||
return ChromeStrategy(req, store);
|
return ChromeStrategy(req, store);
|
||||||
}
|
}
|
||||||
// The firefox plugin injects a function to send requests through it
|
// The firefox plugin injects a function to send requests through it
|
||||||
// If that is available, then we can use the FirefoxStrategy
|
// If that is available, then we can use the FirefoxStrategy
|
||||||
@@ -29,10 +30,11 @@ const runAppropriateStrategy = (req, store) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return AxiosStrategy(req, store);
|
return AxiosStrategy(req, store);
|
||||||
}
|
};
|
||||||
|
|
||||||
const sendNetworkRequest = (req, store) =>
|
const sendNetworkRequest = (req, store) =>
|
||||||
runAppropriateStrategy(req, store)
|
runAppropriateStrategy(req, store).finally(() =>
|
||||||
.finally(() => window.$nuxt.$loading.finish());
|
window.$nuxt.$loading.finish()
|
||||||
|
);
|
||||||
|
|
||||||
export { sendNetworkRequest };
|
export { sendNetworkRequest };
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ const EXTENSION_ID = "amknoiejhlmhancpahfcfcfhllgkpbld";
|
|||||||
// Check if the Chrome Extension is present
|
// Check if the Chrome Extension is present
|
||||||
// The Chrome extension injects an empty span to help detection.
|
// The Chrome extension injects an empty span to help detection.
|
||||||
// Also check for the presence of window.chrome object to confirm smooth operations
|
// Also check for the presence of window.chrome object to confirm smooth operations
|
||||||
export const hasChromeExtensionInstalled = () => {
|
export const hasChromeExtensionInstalled = () =>
|
||||||
return document.getElementById("chromePWExtensionDetect") !== null;
|
document.getElementById("chromePWExtensionDetect") !== null;
|
||||||
};
|
|
||||||
|
|
||||||
const chromeWithoutProxy = (req, _store) =>
|
const chromeWithoutProxy = (req, _store) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
@@ -17,11 +16,11 @@ const chromeWithoutProxy = (req, _store) =>
|
|||||||
config: req
|
config: req
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
message => {
|
({ data }) => {
|
||||||
if (message.data.error) {
|
if (data.error) {
|
||||||
reject(message.data.error);
|
reject(data.error);
|
||||||
} else {
|
} else {
|
||||||
resolve(message.data.response);
|
resolve(data.response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -43,11 +42,11 @@ const chromeWithProxy = (req, { state }) =>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
message => {
|
({ data }) => {
|
||||||
if (message.data.error) {
|
if (data.error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
} else {
|
} else {
|
||||||
resolve(message.data.response.data);
|
resolve(data.response.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const extensionWithProxy = async (req, { state }) => {
|
const extensionWithProxy = async (req, { state }) => {
|
||||||
const { data } = await window.__POSTWOMAN_EXTENSION_HOOK__.sendRequest({
|
const { data } = await window.__POSTWOMAN_EXTENSION_HOOK__.sendRequest({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
|
url:
|
||||||
|
state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
|
||||||
data: req
|
data: req
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
Reference in New Issue
Block a user