Chrome debuuger api for google docs and youtube

Skip to first unread message

lovish jain

Sep 9, 2021, 10:36:16 AM9/9/21
to Chromium Extensions
I am developing extension having manifest version "2.0".
Recently I need to use chrome.debugger.attach api on my google presentation(basically google docs) and, but whenever I try to attach debugger on google docs and youtube, it gives error in background console of "cannot attach to this target", basically debugger is not attaching to them, apart from this it is attaching and working good on all other domains. 
Note: Added debugger permission,
I used This part of code, here actually just for testing purpose I am printing browser version, but main aim is to get a mouse click.
-> here is the id of the active tab, "1.3" is stable debugger protocol version,

chrome.debugger.attach({ tabId: }, "1.3", function(){
      chrome.debugger.sendCommand({ tabId: } , 'Browser.getVersion' , function(data){
Can anyone please guide me through this.. it will be great help.


Simeon Vincent

Sep 9, 2021, 8:47:38 PM9/9/21
to Chromium Extensions,
Do you actually need to use Chrome DevTools Protocol (CDP)? Given what you've shared of your use case, this seems like it might be way more invasive and complicated than necessary. Content scripts also have access to a page's DOM and can observe click events. They also do this without displaying a warning bar saying the page is being remotely debugged.

Simeon - @dotproto
Chrome Extensions DevRel


Sep 10, 2021, 10:20:41 AM9/10/21
to Chromium Extensions,
Assuming you want to send a trusted click event, chrome.debugger is indeed the only solution. It's weird though because usually non-banking sites don't check the isTrusted property of an event.

As for the problem, it sounds like a known bug in Chrome caused by the presence of the built-in hosted apps for Google Drive, Docs, Sheets. These apps are completely useless on all desktop platforms, their only purpose IIRC is to provide a click button in the ChromeOS launcher. The solution/workaround is to open chrome://apps page and remove everything you didn't install yourself except for the non-removable Chrome Web Store app, specifically YouTube, Google Drive, Docs, Sheets.

Another problem may be yet another bug if you try to attach to a freshly created tab (chrome.tabs.create or It can be solved by creating an empty about:blank tab, attaching to it, then navigating to the real URL.

lovish jain

Sep 16, 2021, 6:58:03 AM9/16/21
to Chromium Extensions, wOxxOm, lovish jain
Thanks for sharing the valuable points regarding chrome debugger apis, I recently checked with attaching the debugger to a freshly created tab and redirecting the required url, and it worked for Youtube, and we were able to do our task using debugger api, but in case of google docs, as soon as the google presentation page loads completely, the debugger detaches itself automatically, It would be great if we also are able to get to this point.. please guide me through this..


Sep 16, 2021, 7:25:34 AM9/16/21
to Chromium Extensions,, wOxxOm
My post above already explains what you need to do so I don't understand what else I can add.

lovish jain

Sep 16, 2021, 8:42:51 AM9/16/21
to wOxxOm, Chromium Extensions
Actually, when we need to attach debugger on google docs (presentation page), we are attaching it to an empty tab and then redirecting it to google presentation url,and after that once the loading completes, the debugger detaches automatically, but i want to do some operations with the help of debugger, like click events, etc once the presentation page loads, and if i try to again attach debugger, on google docs, it throws error: "can't attach to this target" the previous one of my first post



Sep 16, 2021, 8:46:44 AM9/16/21
to Chromium Extensions,, Chromium Extensions, wOxxOm
I still don't see any reaction for the second paragraph of my first post...

lovish jain

Sep 16, 2021, 10:00:49 AM9/16/21
to Chromium Extensions, wOxxOm, lovish jain, Chromium Extensions
I went to chrome://apps and I found only google - Sheets, docs, slides . So nothing else is installed other than default ones. 
I am trying to attach the debugger to two different sites that require trusted events; YouTube and Google Presentations.
In the case of attaching the debugger to YouTube, I tried your suggestion where I attached to a random page (attaching to about:blank failed for some reason) and then I navigated to YouTube. That worked great (thank you). 
In the case of google presentations, I did the same, then navigated to the specific google presentation that I am trying to attach to. The debugger just detaches itself once the presentation URL loads. 
Would you happen to have any other ideas or tricks as to how I can get around this ?


Sep 16, 2021, 10:11:14 AM9/16/21
to Chromium Extensions,, wOxxOm, Chromium Extensions
As my first post says "remove everything you didn't install yourself except for the non-removable Chrome Web Store app, specifically YouTube, Google Drive, Docs, Sheets."

It means you need to remove YouTube, Google Drive, Docs, Sheets from chrome://apps.

English is not my native language so I guess the way I phrased it made you think that you should not delete the apps listed after "specifically".

Reply all
Reply to author
Message has been deleted
0 new messages