Remove support for legacy extensions
This commit is contained in:
@@ -48,8 +48,8 @@
|
|||||||
class="icon"
|
class="icon"
|
||||||
v-tooltip="
|
v-tooltip="
|
||||||
(fb.currentUser.displayName || '<label><i>Name not found</i></label>') +
|
(fb.currentUser.displayName || '<label><i>Name not found</i></label>') +
|
||||||
'<br>' +
|
'<br>' +
|
||||||
(fb.currentUser.email || '<label><i>Email not found</i></label>')
|
(fb.currentUser.email || '<label><i>Email not found</i></label>')
|
||||||
"
|
"
|
||||||
aria-label="Account"
|
aria-label="Account"
|
||||||
>
|
>
|
||||||
@@ -287,7 +287,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import intializePwa from "../../assets/js/pwa"
|
import intializePwa from "../../assets/js/pwa"
|
||||||
import { hasExtensionInstalled } from "../../functions/strategies/ExtensionStrategy"
|
import { hasExtensionInstalled } from "../../functions/strategies/ExtensionStrategy"
|
||||||
import { hasChromeExtensionInstalled } from "../../functions/strategies/ChromeStrategy"
|
|
||||||
import { getPlatformSpecialKey } from "../../functions/platformutils"
|
import { getPlatformSpecialKey } from "../../functions/platformutils"
|
||||||
import firebase from "firebase/app"
|
import firebase from "firebase/app"
|
||||||
import { fb } from "../../functions/fb"
|
import { fb } from "../../functions/fb"
|
||||||
@@ -343,7 +342,7 @@ export default {
|
|||||||
if (!showExtensionsToast) return
|
if (!showExtensionsToast) return
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!(hasExtensionInstalled() || hasChromeExtensionInstalled())) {
|
if (!hasExtensionInstalled()) {
|
||||||
this.$toast.show(this.$t("extensions_info2"), {
|
this.$toast.show(this.$t("extensions_info2"), {
|
||||||
icon: "extension",
|
icon: "extension",
|
||||||
duration: 5000,
|
duration: 5000,
|
||||||
@@ -373,7 +372,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}, 15000)
|
}, 15000)
|
||||||
|
|
||||||
this._keyListener = function(e) {
|
this._keyListener = function (e) {
|
||||||
if (e.key === "Escape") {
|
if (e.key === "Escape") {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.showExtensions = this.showShortcuts = this.showSupport = false
|
this.showExtensions = this.showShortcuts = this.showSupport = false
|
||||||
@@ -404,7 +403,7 @@ export default {
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
availableLocales() {
|
availableLocales() {
|
||||||
return this.$i18n.locales.filter(i => i.code !== this.$i18n.locale)
|
return this.$i18n.locales.filter((i) => i.code !== this.$i18n.locale)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,13 @@
|
|||||||
import AxiosStrategy from "./strategies/AxiosStrategy"
|
import AxiosStrategy from "./strategies/AxiosStrategy"
|
||||||
import ExtensionStrategy, { hasExtensionInstalled } from "./strategies/ExtensionStrategy"
|
import ExtensionStrategy, { hasExtensionInstalled } from "./strategies/ExtensionStrategy"
|
||||||
import FirefoxStrategy from "./strategies/FirefoxStrategy"
|
|
||||||
import ChromeStrategy, { hasChromeExtensionInstalled } from "./strategies/ChromeStrategy"
|
|
||||||
|
|
||||||
const isExtensionsAllowed = ({ state }) =>
|
const isExtensionsAllowed = ({ state }) =>
|
||||||
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) && hasExtensionInstalled()) {
|
||||||
if (hasExtensionInstalled()) {
|
return ExtensionStrategy(req, store)
|
||||||
return ExtensionStrategy(req, store)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The following strategies are deprecated and kept to support older version of the extensions
|
|
||||||
|
|
||||||
// Chrome Provides a chrome object for scripts to access
|
|
||||||
// Check its availability to say whether you are in Google Chrome
|
|
||||||
if (window.chrome && hasChromeExtensionInstalled()) {
|
|
||||||
return ChromeStrategy(req, store)
|
|
||||||
}
|
|
||||||
// The firefox plugin injects a function to send requests through it
|
|
||||||
// If that is available, then we can use the FirefoxStrategy
|
|
||||||
if (window.firefoxExtSendRequest) {
|
|
||||||
return FirefoxStrategy(req, store)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return AxiosStrategy(req, store)
|
return AxiosStrategy(req, store)
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
const EXTENSION_ID = "amknoiejhlmhancpahfcfcfhllgkpbld"
|
|
||||||
|
|
||||||
// Check if the Chrome Extension is present
|
|
||||||
// The Chrome extension injects an empty span to help detection.
|
|
||||||
// Also check for the presence of window.chrome object to confirm smooth operations
|
|
||||||
export const hasChromeExtensionInstalled = () =>
|
|
||||||
document.getElementById("chromePWExtensionDetect") !== null
|
|
||||||
|
|
||||||
const chromeWithoutProxy = (req, _store) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
chrome.runtime.sendMessage(
|
|
||||||
EXTENSION_ID,
|
|
||||||
{
|
|
||||||
messageType: "send-req",
|
|
||||||
data: {
|
|
||||||
config: req,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
({ data }) => {
|
|
||||||
if (data.error) {
|
|
||||||
reject(data.error)
|
|
||||||
} else {
|
|
||||||
resolve(data.response)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
const chromeWithProxy = (req, { state }) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
chrome.runtime.sendMessage(
|
|
||||||
EXTENSION_ID,
|
|
||||||
{
|
|
||||||
messageType: "send-req",
|
|
||||||
data: {
|
|
||||||
config: {
|
|
||||||
method: "post",
|
|
||||||
url:
|
|
||||||
state.postwoman.settings.PROXY_URL ||
|
|
||||||
"https://postwoman.apollosoftware.xyz/",
|
|
||||||
data: req
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
({ data }) => {
|
|
||||||
if (data.error) {
|
|
||||||
reject(error)
|
|
||||||
} else {
|
|
||||||
resolve(data.response.data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
const chromeStrategy = (req, store) => {
|
|
||||||
if (store.state.postwoman.settings.PROXY_ENABLED) {
|
|
||||||
return chromeWithProxy(req, store)
|
|
||||||
} else {
|
|
||||||
return chromeWithoutProxy(req, store)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default chromeStrategy
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
const firefoxWithProxy = (req, { state }) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
const eventListener = event => {
|
|
||||||
window.removeEventListener("firefoxExtSendRequestComplete", event)
|
|
||||||
|
|
||||||
if (event.detail.error) {
|
|
||||||
reject(JSON.parse(event.detail.error))
|
|
||||||
} else {
|
|
||||||
resolve(JSON.parse(event.detail.response).data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener("firefoxExtSendRequestComplete", eventListener)
|
|
||||||
|
|
||||||
window.firefoxExtSendRequest({
|
|
||||||
method: "post",
|
|
||||||
url:
|
|
||||||
state.postwoman.settings.PROXY_URL || "https://postwoman.apollosoftware.xyz/",
|
|
||||||
data: req
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const firefoxWithoutProxy = (req, _store) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
const eventListener = ({ detail }) => {
|
|
||||||
window.removeEventListener("firefoxExtSendRequestComplete", eventListener)
|
|
||||||
|
|
||||||
if (detail.error) {
|
|
||||||
reject(JSON.parse(detail.error))
|
|
||||||
} else {
|
|
||||||
resolve(JSON.parse(detail.response))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener("firefoxExtSendRequestComplete", eventListener)
|
|
||||||
|
|
||||||
window.firefoxExtSendRequest(req)
|
|
||||||
})
|
|
||||||
|
|
||||||
const firefoxStrategy = (req, store) => {
|
|
||||||
if (store.state.postwoman.settings.PROXY_ENABLED) {
|
|
||||||
return firefoxWithProxy(req, store)
|
|
||||||
}
|
|
||||||
return firefoxWithoutProxy(req, store)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default firefoxStrategy
|
|
||||||
Reference in New Issue
Block a user