aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-10-04 00:52:42 +0200
committerVendicated <vendicated@riseup.net>2022-10-04 00:52:50 +0200
commitcc257533148419b1c94a1cd257e756d2688a403c (patch)
tree84affcf23ec84304efcb381626ac4d995db0ec95 /src
parenta9eae106c7cc6cccbb5c3f030130d3c7b6461c3e (diff)
downloadVencord-cc257533148419b1c94a1cd257e756d2688a403c.tar.gz
Vencord-cc257533148419b1c94a1cd257e756d2688a403c.tar.bz2
Vencord-cc257533148419b1c94a1cd257e756d2688a403c.zip
feat: Experimental browser support
Diffstat (limited to 'src')
-rw-r--r--src/components/Settings.tsx13
-rw-r--r--src/plugins/settings.ts12
-rw-r--r--src/utils/isWeb.ts1
-rw-r--r--src/utils/types.ts4
-rw-r--r--src/webpack/patchWebpack.ts1
5 files changed, 21 insertions, 10 deletions
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx
index d4a3dca..4dbb1b2 100644
--- a/src/components/Settings.tsx
+++ b/src/components/Settings.tsx
@@ -9,6 +9,7 @@ import { startPlugin } from "../plugins";
import { stopPlugin } from '../plugins/index';
import { Flex } from './Flex';
import { ChangeList } from '../utils/ChangeList';
+import { IS_WEB } from '../utils/isWeb';
function showErrorToast(message: string) {
Toasts.show({
@@ -72,7 +73,7 @@ export default ErrorBoundary.wrap(function Settings() {
SettingsDir: <code style={{ userSelect: 'text', cursor: 'text' }}>{settingsDir}</code>
</Forms.FormText>
- <Flex className={classes(Margins.marginBottom20)}>
+ {!IS_WEB && <Flex className={classes(Margins.marginBottom20)}>
<Button
onClick={() => window.DiscordNative.app.relaunch()}
size={Button.Sizes.SMALL}
@@ -94,7 +95,7 @@ export default ErrorBoundary.wrap(function Settings() {
>
Open QuickCSS File
</Button>
- </Flex>
+ </Flex>}
<Forms.FormDivider />
<Forms.FormTitle tag="h5">Settings</Forms.FormTitle>
<Switch
@@ -104,20 +105,20 @@ export default ErrorBoundary.wrap(function Settings() {
>
Use QuickCss
</Switch>
- <Switch
+ {!IS_WEB && <Switch
value={settings.notifyAboutUpdates}
onChange={(v: boolean) => settings.notifyAboutUpdates = v}
note="Shows a Toast on StartUp"
>
Get notified about new Updates
- </Switch>
- <Switch
+ </Switch>}
+ {!IS_WEB && <Switch
value={settings.unsafeRequire}
onChange={(v: boolean) => settings.unsafeRequire = v}
note="Enables VencordNative.require. Useful for testing, very bad for security. Leave this off unless you need it."
>
Enable Unsafe Require
- </Switch>
+ </Switch>}
<Forms.FormDivider />
diff --git a/src/plugins/settings.ts b/src/plugins/settings.ts
index 2ed85e6..6927f64 100644
--- a/src/plugins/settings.ts
+++ b/src/plugins/settings.ts
@@ -1,6 +1,7 @@
import definePlugin from "../utils/types";
import gitHash from "git-hash";
import { Devs } from '../utils/constants';
+import { IS_WEB } from "../utils/isWeb";
export default definePlugin({
name: "Settings",
@@ -15,9 +16,12 @@ export default definePlugin({
replace: m => {
const idx = m.indexOf("Host") - 1;
const template = m.slice(0, idx);
- return `${m}, ${template}"Vencord ", "${gitHash}"), " "), ` +
- `${template} "Electron ",VencordNative.getVersions().electron)," "), ` +
- `${template} "Chrome ",VencordNative.getVersions().chrome)," ")`;
+ let r = `${m}, ${template}"Vencord ", "${gitHash}${IS_WEB ? " (Web)" : ""}"), " ")`;
+ if (!IS_WEB) {
+ r += `,${template} "Electron ",VencordNative.getVersions().electron)," "),`;
+ r += `${template} "Chrome ",VencordNative.getVersions().chrome)," ")`;
+ }
+ return r;
}
}
]
@@ -28,7 +32,7 @@ export default definePlugin({
replace: (m, mod) =>
`{section:${mod}.ID.HEADER,label:"Vencord"},` +
`{section:"VencordSetting",label:"Vencord",element:Vencord.Components.Settings},` +
- `{section:"VencordUpdater",label:"Updater",element:Vencord.Components.Updater},` +
+ `{section:"VencordUpdater",label:"Updater",element:Vencord.Components.Updater,predicate:()=>!IS_WEB},` +
`{section:${mod}.ID.DIVIDER},${m}`
}
diff --git a/src/utils/isWeb.ts b/src/utils/isWeb.ts
new file mode 100644
index 0000000..4082164
--- /dev/null
+++ b/src/utils/isWeb.ts
@@ -0,0 +1 @@
+export const IS_WEB = window.IS_WEB = typeof window.DiscordNative === "undefined";
diff --git a/src/utils/types.ts b/src/utils/types.ts
index a6b79c5..1c63613 100644
--- a/src/utils/types.ts
+++ b/src/utils/types.ts
@@ -33,6 +33,10 @@ interface PluginDef {
patches?: Omit<Patch, "plugin">[];
dependencies?: string[],
required?: boolean;
+ /**
+ * Set this if your plugin only works on Browser or Desktop, not both
+ */
+ target?: "WEB" | "DESKTOP" | "BOTH";
}
export type IpcRes<V = any> = { ok: true; value: V; } | { ok: false, error: any; };
diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts
index 469b930..ffd81d5 100644
--- a/src/webpack/patchWebpack.ts
+++ b/src/webpack/patchWebpack.ts
@@ -6,6 +6,7 @@ let webpackChunk: any[];
const logger = new Logger("WebpackInterceptor", "#8caaee");
+console.log("prepatch is", window[WEBPACK_CHUNK]);
Object.defineProperty(window, WEBPACK_CHUNK, {
get: () => webpackChunk,
set: (v) => {