Add a warning to the console to discourage attacks and encourage contributing (#7673)
This commit is contained in:
parent
9b0da552e7
commit
bb03298e6d
2 changed files with 37 additions and 0 deletions
|
@ -23,6 +23,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
import { Screen as ScreenEvent } from "matrix-analytics-events/types/typescript/Screen";
|
import { Screen as ScreenEvent } from "matrix-analytics-events/types/typescript/Screen";
|
||||||
import { defer, IDeferred, QueryDict } from "matrix-js-sdk/src/utils";
|
import { defer, IDeferred, QueryDict } from "matrix-js-sdk/src/utils";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
import { throttle } from "lodash";
|
||||||
|
|
||||||
// focus-visible is a Polyfill for the :focus-visible CSS pseudo-attribute used by _AccessibleButton.scss
|
// focus-visible is a Polyfill for the :focus-visible CSS pseudo-attribute used by _AccessibleButton.scss
|
||||||
import 'focus-visible';
|
import 'focus-visible';
|
||||||
|
@ -447,6 +448,10 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public componentDidMount(): void {
|
||||||
|
window.addEventListener("resize", this.onWindowResized);
|
||||||
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
if (this.shouldTrackPageChange(prevState, this.state)) {
|
if (this.shouldTrackPageChange(prevState, this.state)) {
|
||||||
const durationMs = this.stopPageChangeTimer();
|
const durationMs = this.stopPageChangeTimer();
|
||||||
|
@ -467,6 +472,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
this.fontWatcher.stop();
|
this.fontWatcher.stop();
|
||||||
UIStore.destroy();
|
UIStore.destroy();
|
||||||
this.state.resizeNotifier.removeListener("middlePanelResized", this.dispatchTimelineResize);
|
this.state.resizeNotifier.removeListener("middlePanelResized", this.dispatchTimelineResize);
|
||||||
|
window.removeEventListener("resize", this.onWindowResized);
|
||||||
|
|
||||||
if (this.accountPasswordTimer !== null) clearTimeout(this.accountPasswordTimer);
|
if (this.accountPasswordTimer !== null) clearTimeout(this.accountPasswordTimer);
|
||||||
}
|
}
|
||||||
|
@ -501,6 +507,34 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private onWindowResized = (): void => {
|
||||||
|
// XXX: This is a very unreliable way to detect whether or not the the devtools are open
|
||||||
|
this.warnInConsole();
|
||||||
|
};
|
||||||
|
|
||||||
|
private warnInConsole = throttle((): void => {
|
||||||
|
const largeFontSize = "50px";
|
||||||
|
const normalFontSize = "15px";
|
||||||
|
|
||||||
|
const waitText = _t("Wait!");
|
||||||
|
const scamText = _t(
|
||||||
|
"If someone told you to copy/paste something here, " +
|
||||||
|
"there is a high likelihood you're being scammed!",
|
||||||
|
);
|
||||||
|
const devText = _t(
|
||||||
|
"If you know what you're doing, Element is open-source, " +
|
||||||
|
"be sure to check out our GitHub (https://github.com/vector-im/element-web/) " +
|
||||||
|
"and contribute!",
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`%c${waitText}\n%c${scamText}\n%c${devText}`,
|
||||||
|
`font-size:${largeFontSize}; color:blue;`,
|
||||||
|
`font-size:${normalFontSize}; color:red;`,
|
||||||
|
`font-size:${normalFontSize};`,
|
||||||
|
);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
private getFallbackHsUrl(): string {
|
private getFallbackHsUrl(): string {
|
||||||
if (this.props.serverConfig?.isDefault) {
|
if (this.props.serverConfig?.isDefault) {
|
||||||
return this.props.config.fallback_hs_url;
|
return this.props.config.fallback_hs_url;
|
||||||
|
|
|
@ -3024,6 +3024,9 @@
|
||||||
"Private community": "Private community",
|
"Private community": "Private community",
|
||||||
"To view %(communityName)s, swap to communities in your <a>preferences</a>": "To view %(communityName)s, swap to communities in your <a>preferences</a>",
|
"To view %(communityName)s, swap to communities in your <a>preferences</a>": "To view %(communityName)s, swap to communities in your <a>preferences</a>",
|
||||||
"To join %(communityName)s, swap to communities in your <a>preferences</a>": "To join %(communityName)s, swap to communities in your <a>preferences</a>",
|
"To join %(communityName)s, swap to communities in your <a>preferences</a>": "To join %(communityName)s, swap to communities in your <a>preferences</a>",
|
||||||
|
"Wait!": "Wait!",
|
||||||
|
"If someone told you to copy/paste something here, there is a high likelihood you're being scammed!": "If someone told you to copy/paste something here, there is a high likelihood you're being scammed!",
|
||||||
|
"If you know what you're doing, Element is open-source, be sure to check out our GitHub (https://github.com/vector-im/element-web/) and contribute!": "If you know what you're doing, Element is open-source, be sure to check out our GitHub (https://github.com/vector-im/element-web/) and contribute!",
|
||||||
"Failed to reject invitation": "Failed to reject invitation",
|
"Failed to reject invitation": "Failed to reject invitation",
|
||||||
"Cannot create rooms in this community": "Cannot create rooms in this community",
|
"Cannot create rooms in this community": "Cannot create rooms in this community",
|
||||||
"You do not have permission to create rooms in this community.": "You do not have permission to create rooms in this community.",
|
"You do not have permission to create rooms in this community.": "You do not have permission to create rooms in this community.",
|
||||||
|
|
Loading…
Reference in a new issue