From 52f2735e5f40081610227ea54c4fa286bb003abd Mon Sep 17 00:00:00 2001 From: Kazumi Inada Date: Thu, 12 Dec 2024 13:37:55 +0900 Subject: [PATCH] fix: Focus to document before copying URL and title Fixes #58 --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/nandenjin/tsukimi/issues/58?shareId=XXXX-XXXX-XXXX-XXXX). --- src/background/features/copyUrlAndTitle.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/background/features/copyUrlAndTitle.ts b/src/background/features/copyUrlAndTitle.ts index 5b0d119..0050dc0 100644 --- a/src/background/features/copyUrlAndTitle.ts +++ b/src/background/features/copyUrlAndTitle.ts @@ -77,6 +77,13 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => { const url = getPageURL() const title = getPageTitle() + // Check if the document has focus + if (!document.hasFocus()) { + // Attempt to focus the document + window.focus() + document.body.focus() + } + // Copy URL and Title navigator.clipboard.writeText(`[${title} ${url}]`) console.log('Copied URL and Title')