-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copycat is not working in Chrome (especially the Hotkey) #44
Comments
Is there a way to: execute a Javascript command in the Chrome Dev Console -- in order to do the copy action? Or is there any hotkey to navigate through the context menu |
Btw,
I often times see these outputs in the Chrome Dev Console. Just saying, but I dont think this is the cause, |
(I just revert to v2.4.5, seems old version is working fine.) (Btw, the new version seems auto-format the Html; |
I have no clue how to fix these issues. |
As far as I know, there is such a Menu key, but I don't think it's what you want. |
HTML does get formatted, because unformatted HTML is hard to read, and I can't find a reason to disable this behavior. copycat/src/background/handlers/selection-as-html.ts Lines 23 to 28 in 4b8a820
|
--- in the context menu So, I can press (say,) --- |
--- The problem of auto-format (code prettify) is:
So, I rather there is an option. --- for ie:
becomes
--- (should I move this to another post) |
There are two things, access key and shortcut:
The access key is a Windows-specific feature that is better suited for standalone applications. The shortcut, Chromium doesn't support it, so it's impossible to implement. |
Done, now there is a new option called "Format HTML". |
For the fault mentioned in the OP, I noticed that in some cases the content script actually throws this error:
v2.4.5: copycat/src/content-script/index.ts Lines 1 to 8 in 7c7a865
v3.0.1: Lines 16 to 27 in 4b8a820
To be honest, they are the same. |
SW sometimes fails to send messages to tabs, I don't know why:
|
Just released v3.0.2, not sure if it fixes the problem. |
If it wouldnt work, thats fine;
Thanks, It works!
(Im not sure about these)
Its working, the problem seems fixed. |
Actually, the problem is not solved completely. Especially when using the The --- (Btw, Maybe you can consider to put an option to output some debug info. |
Unfortunately, I can't find any more parts that can be fixed. |
A bug was fixed in v3.0.4 that is likely related to this issue. |
No, it seems the problem is still there. -- Copycat hotkey only works sometimes. (Some points to mention again)
|
After some debugging, I think the problem is still due to #44 (comment) When using shortcuts, |
Update: Still investigating, the statement
may not hold. It works sometimes, but it needs to be refreshed some other time. the following content may no longer hold true @BlackGlory in shortTurned out, the detailsCuz the problem of the hotkey not working still exists. I downloaded your source code, tried to look through & debug it. >"
chrome.commands.onCommand.addListener(async (command, tab) => {
const result = await commandHandlers[command](
{}
, tab ?? await getActiveTab()
)
<>
G:\UsingTemp\copycat\src\background\index.ts
>"
export const commandSelectionAsMarkdown: CommandHandler = async (info, tab) => {
if (tab.id) {
const baseURL = info.frameUrl ?? info.pageUrl ?? tab.url
if (baseURL) {
<>
G:\UsingTemp\copycat\src\background\handlers\selection-as-markdown.ts So, I Turned out, the |
@BlackGlory in shortThis can be fixed if the detailsActually, with the (the context menu is still working fine, regardless) -- The problem is due to if (baseURL) {
const config = await getConfig()
const client = createTabClient<IFrameAPI>({
tabId: tab.id
, frameId: info.frameId
})
const html = await client.getSelectionHTML() This can be fixed if the |
Honestly, this is very unusual. |
For #44 (comment)
Still investigating, dont worry too much on this yet, I can be wrong. For #44 (comment) But you may look into the |
I cannot reproduce the problem at https://www.autohotkey.com/docs/v2/Variables.htm (use the shortcut to copy the selected content as Markdown). Reddit's problem may be related to #49, their new design uses Web Components. |
I think I will give up on this. --
If Otherwise, -- It seems like you used a complex Proxy for calling the method |
Lines 15 to 26 in 6f65227
|
Just updated the code 607ae4a, give it a try. |
It's worth noting that the current solution (607ae4a) is flawed because it just sends a message to each frame on the active tab. The background script (or the service worker) just chooses the first result that responds correctly as the final result. Also, the solution requires webNavigation permission. |
Alternative solution (8a018cb)This solution avoids the flaws of the existing solution, but it causes the service worker to be active all the time. content-script.tswindow.addEventListener('focus', () => {
chrome.runtime.sendMessage(null)
}) background/index.tslet frameId = 0
chrome.runtime.onMessage.addListener((message, sender) => {
if (sender.id === chrome.runtime.id && isNull(message)) {
if (isntUndefined(sender.frameId)) {
frameId = sender.frameId
}
}
}) |
ok (too complex for me for now)
I think that is the main problem.
I thought of this before.
(I tried this before. But I made a mistake and got the wrong
Does that slow down the PC a lot? I built another extension https://github.com/Norlandz/ChromeCopy
-- I may try your solution (it just building is slow on my computer, takes 7min). |
For #44 (comment)
I build the ext, load it. I guess the (Thanks for your time & effort!) |
Not sure, all I know is that the designers of MV3 certainly didn't like it. |
in_short
Copycat has been working fine before in Chrome.
But in the recent 2~3? weeks, Copycat starts to not working sometimes (especially the Hotkey).
I have not idea what is the cause.
details
I have set hotkey shortcuts for Copycat in Chrome,
and it has been working before.
Recently,
when I:
-> 70% of the time, the Copycat Hotkey fails to copy -- nothing is copied/updated to the Clipboard (-- Clipboard remains unchanged).
I tired to refresh the page / restart the browser / disable&enable the extension / disable all other extension.
Still, cant solve the problem -- it still only works sometimes
(--ie: if you refresh multiple times, you may eventually get a page that have Copycat working...)
I tried to reinstall the extension, not helping.
If the page was opened & copycat works, then it remains to work, as long as I dont refresh the page.
If the page was opened & copycat doesnt work, then it remains to doesnt work, as long as I dont refresh the page.
(page-open action based)
So, it may be:
working in one web page (one tab),
while failing to work in another web page (another tab).
Its not for a specific website -- it can happen to any website.
If I right click and use the context menu (not hotkey) to select Copycat to copy,
-> still.... 60% of the time, the Copycat (Context Menu) fails to copy,
There could be a case where: Hotkey is not working & Context menu is not working either. (most of the time)
There could be a case where: Hotkey is not working, but Context menu works. (sometimes)
I tried to assign the same Hotkey to other extensions -- the Hotkey is working fine for others, but not for Copycat.
The text was updated successfully, but these errors were encountered: