diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 18fccc33c75c..a8b70ccee6a7 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -247,8 +247,8 @@ "settings_post_replace_all_posts": "All Posts", "settings_post_replace_enhanced_posts": "Enhanced Posts", "settings_post_replace_encrypted_posts": "Encrypted Posts", - "settings_post_replacement_scope": "Post Replacement Scope", - "settings_post_replacement_scope_desc": "Maskbook will render a new post to replace the original one to provide some enhancement.", + "settings_post_replacement": "Substitute Post", + "settings_post_replacement_desc": "All posts on the webpages will be rendered by Maskbook, including those not created by Maskbook.", "skip": "Skip", "share": "Share", "share_to": "Share to…", diff --git a/src/_locales/ja/messages.json b/src/_locales/ja/messages.json index c15576bcf94f..19d7c432f109 100644 --- a/src/_locales/ja/messages.json +++ b/src/_locales/ja/messages.json @@ -247,8 +247,8 @@ "settings_post_replace_all_posts": "すべての投稿", "settings_post_replace_enhanced_posts": "強化された投稿", "settings_post_replace_encrypted_posts": "暗号化された投稿", - "settings_post_replacement_scope": "ポスト交換範囲", - "settings_post_replacement_scope_desc": "Maskbook は、新しい投稿をレンダリングして元の投稿を置き換え、いくつかの拡張機能を提供します。", + "settings_post_replacement": "代替ポスト", + "settings_post_replacement_desc": "Web ページ上のすべての投稿は、Maskbook で作成されていない投稿を含め、Maskbook によってレンダリングされます。", "skip": "スキップ", "share": "共有", "share_to": "共有先", diff --git a/src/_locales/zh/messages.json b/src/_locales/zh/messages.json index 06b39f537e41..5bf73611b669 100644 --- a/src/_locales/zh/messages.json +++ b/src/_locales/zh/messages.json @@ -247,8 +247,8 @@ "settings_post_replace_all_posts": "所有帖子", "settings_post_replace_enhanced_posts": "僅增強的帖子", "settings_post_replace_encrypted_posts": "僅加密的帖子", - "settings_post_replacement_scope": "帖子替換範圍", - "settings_post_replacement_scope_desc": "Maskbook 將呈現一個新帖子以替換原始帖子,以提供一些增強功能。", + "settings_post_replacement": "替身帖子", + "settings_post_replacement_desc": "網頁上每個 Post 都由 Maskbook 渲染,包括並非由 Maskbook 創建的。", "skip": "跳過", "share": "分享", "share_to": "分享给…", diff --git a/src/components/InjectedComponents/PostReplacer.tsx b/src/components/InjectedComponents/PostReplacer.tsx index 0699df06c366..3ca445ec41aa 100644 --- a/src/components/InjectedComponents/PostReplacer.tsx +++ b/src/components/InjectedComponents/PostReplacer.tsx @@ -4,7 +4,7 @@ import { DefaultTypedMessageRenderer } from './TypedMessageRenderer' import { PluginUI } from '../../plugins/plugin' import { makeTypedMessageCompound, isTypedMessageSuspended, isTypedMessageKnown } from '../../protocols/typed-message' import { useValueRef } from '../../utils/hooks/useValueRef' -import { currentPostReplacementScopeSettings, PostReplacementScope } from '../../settings/settings' +import { allPostReplacementSettings } from '../../settings/settings' import { makeStyles, Theme } from '@material-ui/core' const useStlyes = makeStyles((theme: Theme) => ({ @@ -23,7 +23,7 @@ export function PostReplacer(props: PostReplacerProps) { const postContent = usePostInfoDetails('postContent') const postMessage = usePostInfoDetails('postMessage') const postPayload = usePostInfoDetails('postPayload') - const postRepalcementScope = useValueRef(currentPostReplacementScopeSettings) + const allPostReplacement = useValueRef(allPostReplacementSettings) const plugins = [...PluginUI.values()] const processedPostMessage = useMemo( @@ -32,12 +32,11 @@ export function PostReplacer(props: PostReplacerProps) { ) const shouldReplacePost = // replace all posts - postRepalcementScope === PostReplacementScope.all || + allPostReplacement || // replace posts which enhanced by plugins - (postRepalcementScope === PostReplacementScope.enhancedOnly && - processedPostMessage.items.some((x) => !isTypedMessageKnown(x))) || + (!allPostReplacement && processedPostMessage.items.some((x) => !isTypedMessageKnown(x))) || // replace posts which encrypted by maskbook - (postRepalcementScope === PostReplacementScope.encryptedOnly && postPayload.ok) + (!allPostReplacement && postPayload.ok) // zip/unzip original post useEffect(() => { diff --git a/src/extension/options-page/DashboardRouters/Settings.tsx b/src/extension/options-page/DashboardRouters/Settings.tsx index 54b1f3d671d2..e15cbc615bef 100644 --- a/src/extension/options-page/DashboardRouters/Settings.tsx +++ b/src/extension/options-page/DashboardRouters/Settings.tsx @@ -9,11 +9,10 @@ import { languageSettings, Language, renderInShadowRootSettings, - currentPostReplacementScopeSettings, + allPostReplacementSettings, currentLocalWalletEthereumNetworkSettings, appearanceSettings, Appearance, - PostReplacementScope, } from '../../../settings/settings' import { useValueRef } from '../../../utils/hooks/useValueRef' @@ -118,7 +117,6 @@ export default function DashboardSettingsRouter() { const { t } = useI18N() const currentLang = useValueRef(languageSettings) const currentApperance = useValueRef(appearanceSettings) - const currentPostReplacementScope = useValueRef(currentPostReplacementScopeSettings) const langMapper = React.useRef((x: Language) => { if (x === Language.en) return t('language_en') if (x === Language.zh) return t('language_zh') @@ -130,11 +128,6 @@ export default function DashboardSettingsRouter() { if (x === Appearance.light) return t('settings_appearance_light') return t('settings_appearance_default') }).current - const postReplacerMapper = React.useRef((x: PostReplacementScope) => { - if (x === PostReplacementScope.all) return t('settings_post_replace_all_posts') - if (x === PostReplacementScope.encryptedOnly) return t('settings_post_replace_encrypted_posts') - return t('settings_post_replace_enhanced_posts') - }).current const classes = useStyles() const shadowRoot = useValueRef(renderInShadowRootSettings) const theme = useTheme() @@ -182,13 +175,6 @@ export default function DashboardSettingsRouter() { value={currentLocalWalletEthereumNetworkSettings} /> ) : null} - } - value={currentPostReplacementScopeSettings} - /> @@ -215,6 +201,11 @@ export default function DashboardSettingsRouter() { icon={} value={debugModeSetting} /> + } + value={allPostReplacementSettings} + /> diff --git a/src/settings/settings.ts b/src/settings/settings.ts index 6284a6d5ff7e..75cdad6eb5bc 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -34,6 +34,14 @@ export const renderInShadowRootSettings = createGlobalSettings( }, ) +/** + * Whether if create substitute post for all posts + */ +export const allPostReplacementSettings = createGlobalSettings('post replacement all', false, { + primary: () => i18n.t('settings_post_replacement'), + secondary: () => i18n.t('settings_post_replacement_desc'), +}) + export enum Appearance { default = 'default', light = 'light', @@ -44,21 +52,6 @@ export const appearanceSettings = createGlobalSettings('apperance', primary: () => i18n.t('settings_appearance'), }) -export enum PostReplacementScope { - all = 'all', - enhancedOnly = 'enhancedOnly', - encryptedOnly = 'encryptedOnly', -} - -export const currentPostReplacementScopeSettings = createGlobalSettings( - 'post replacement scope', - PostReplacementScope.enhancedOnly, - { - primary: () => i18n.t('settings_post_replacement_scope'), - secondary: () => i18n.t('settings_post_replacement_scope_desc'), - }, -) - export const currentLocalWalletEthereumNetworkSettings = createGlobalSettings( 'eth network', EthereumNetwork.Mainnet,