handle open dev tool showing a warning

This commit is contained in:
SrGooglo 2022-12-08 11:15:28 +00:00
parent 2ef7bd9778
commit 7768832f72
3 changed files with 36 additions and 4 deletions

View File

@ -271,6 +271,18 @@ class App extends React.Component {
{(t) => t("You have been disconnected from the server, trying to reconnect.")}
</Translation>
})
},
"devtool-opened": () => {
// show warning
antd.notification.open({
message: <Translation>
{(t) => t("Devtool opened")}
</Translation>,
description: <Translation>
{(t) => t("You have opened the devtool for the first time, please be aware that this is a security risk and you should close it as soon as possible.")}
</Translation>,
icon: <Icons.MdOutlineWarning />,
})
}
}
@ -452,12 +464,14 @@ class App extends React.Component {
}, () => {
App.publicMethods.openCreator()
})
app.eventBus.emit("app.initialization.start")
await this.initialization()
app.eventBus.emit("app.initialization.finish")
Utils.handleOpenDevTools()
}
initialization = async () => {

View File

@ -0,0 +1,17 @@
export default () => {
var devtools = function () { }
devtools.toString = function () {
console.log(
"%cStop!\n",
"color: red; font-size: 40px; font-weight: bold;",
)
console.log(
`%cYou have opened the devtools. This is a browser feature intended for developers. If someone told you to copy and paste something here to enable a feature or "hack" someone's account, it is a scam and will give them access to your account and data.`,
"color: black; font-size: 20px; font-weight: bold;"
)
}
console.log('%c', devtools)
}

View File

@ -4,4 +4,5 @@ export { default as cursorPosition } from "./cursorPosition"
export { default as getBase64 } from "./getBase64"
export { default as Haptics } from "./haptics"
export { default as processString } from "./processString"
export { default as deleteInternalStorage } from "./deleteInternalStorage"
export { default as deleteInternalStorage } from "./deleteInternalStorage"
export { default as handleOpenDevTools } from "./handleOpenDevTools"