feat: add right-click restorer for current site
- Add RightClickRestorer page with active unlock trigger - Content script with dual-world strategy (isolated + main world) - Monkey patch preventDefault/stopPropagation via background executeScript - Overlay penetration for pointer-events blocking layers - Delegated main-world injection to avoid CSP restrictions - Async message handling for reliable state updates - i18n translations (zh/en) and unit tests
This commit is contained in:
@@ -4,6 +4,9 @@ export enum MessageAction {
|
||||
RELOAD_TAB = 'reloadTab',
|
||||
SIDE_PANEL_STATE_CHANGED = 'sidePanelStateChanged',
|
||||
CONTEXT_MENU_CLICKED = 'contextMenuClicked',
|
||||
RESTORE_RIGHT_CLICK = 'restoreRightClick',
|
||||
QUERY_RIGHT_CLICK_STATUS = 'queryRightClickStatus',
|
||||
INJECT_MAIN_WORLD_SCRIPT = 'injectMainWorldScript',
|
||||
}
|
||||
|
||||
export interface MessageResponse {
|
||||
@@ -21,6 +24,11 @@ export interface ProtocolMap {
|
||||
[MessageAction.RELOAD_TAB](data: { tabId: number; delay?: number }): MessageResponse;
|
||||
[MessageAction.SIDE_PANEL_STATE_CHANGED](data: { isOpen: boolean }): void;
|
||||
[MessageAction.CONTEXT_MENU_CLICKED](data: ContextMenuClickedPayload): void;
|
||||
[MessageAction.RESTORE_RIGHT_CLICK](data: undefined): MessageResponse & { restored: boolean };
|
||||
[MessageAction.QUERY_RIGHT_CLICK_STATUS](
|
||||
data: undefined,
|
||||
): MessageResponse & { restored: boolean };
|
||||
[MessageAction.INJECT_MAIN_WORLD_SCRIPT](data: undefined): MessageResponse;
|
||||
}
|
||||
|
||||
export const { sendMessage, onMessage } = defineExtensionMessaging<ProtocolMap>();
|
||||
|
||||
@@ -18,6 +18,7 @@ const localeModules: Record<
|
||||
base64Converter: () => import('@/i18n/locales/zh/base64Converter.json'),
|
||||
markdownToHtml: () => import('@/i18n/locales/zh/markdownToHtml.json'),
|
||||
htmlToMarkdown: () => import('@/i18n/locales/zh/htmlToMarkdown.json'),
|
||||
rightClickRestorer: () => import('@/i18n/locales/zh/rightClickRestorer.json'),
|
||||
},
|
||||
en: {
|
||||
timestamp: () => import('@/i18n/locales/en/timestamp.json'),
|
||||
@@ -30,6 +31,7 @@ const localeModules: Record<
|
||||
base64Converter: () => import('@/i18n/locales/en/base64Converter.json'),
|
||||
markdownToHtml: () => import('@/i18n/locales/en/markdownToHtml.json'),
|
||||
htmlToMarkdown: () => import('@/i18n/locales/en/htmlToMarkdown.json'),
|
||||
rightClickRestorer: () => import('@/i18n/locales/en/rightClickRestorer.json'),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user