about call Chrome API or Chrome Extensions with Javascript in Chrome - javascript

I write a HTML page and I want call a Chrome API(eg tts) with a Javascript function which in my HTML page.
BTW: I don't want to create a Chrome Extensions, just want run as a web app.
Is that possible ? If can be possible, how do I do ?

With very few exceptions, chrome.* APIs can only be used within the context of a chrome extension. There are a few exceptions, but probably none that you want. To see them, press F12, type chrome into the prompt, and click to expand the returned opject.

Related

Chrome browser console javascript contexts. Firefox cd() function in chrome

I need to fill some data on my page. But there is a iframe, so i need to get contents from it firstly.
I was told here - How do I cd into an iframe in chrome developer tools or firebug lite in chrome?
that i can cd between the iframes.
So, i tried to do it in the firefox, like this - cd(document.getElementsByTagName('iframe')[0]);
And it works! But how can i do the same thing in the chrome browser? Or maybe you can advice me other things, how to fill fields in the frame. I've got the problem with cross-origin domain.
Is there a way to change programmatically the javascript context like the cd() function do?

Record current tab in chrome using chrome extension and getUserMedia()

I am trying to make a Chrome extension to record user activity in the current tab.
I found out that I can use getUserMedia() on the front, and chrome.desktopCapture in my background script.
However, when I try to use chrome.desktopCapture.chooseDesktopMedia(['tab'], onApproved), I get prompted for the tab I want to share. However, I would like to skip this step and share my current tab without the prompt.
I know that this can be done, because in the Screencastify Chrome extension, you can do that. The first option is to record the current tab and no popups are displayed.
Have you taken a look at chrome.tabCapture API? It can be used inside of an extension, and unlike the chrome.desktopCapture API can be called programmatically without a prompt. The limitation is that the chrome.tabCapture API can only be used within an extension, and cannot be used within a Chrome packaged app (tested and verified in my own attempts at using the "tabCapture" permission in a custom packaged app). So, if you are just writing an extension, the chrome.tabCapture API might be your best option.

Chrome extension that changes values in the Preferences file

I'm trying to write a chrome extension that auto-hides the bookmark bar and shows it when you hover over that area. I was able to do this through c++ by listening to the cursor location and using the ctrl-shift-b shortcut. Unfortunately this is not feasible using the extensions API so I'll have to find another solution.
Would it be possible to do this by changing the value of show_on_all_tabs to true in Preferences?
"bookmark_bar":{"show_apps_shortcut":false,"show_on_all_tabs":false}
If so, then how would I go about implementing that in my extension?
Thanks
There's no API available to Google Chrome extensions to change/hook/control the browser UI.
Other Chromium-based browsers may have something of the kind like Opera's sidebar API.
Changing any of the internal files like the Preferences is also not allowed. It's hard to change even externally as you'd need to change Secure Preferences too, properly updating its hashsum.
Sending Ctrl+Shift+B hotkey from inside an extension/webpage is fruitless as well as it will never escape the content sandbox, and won't reach the browser's internal event listener.

Command line chrome extension loading and testing

I'm currently using the "Developer mode" on the chrome://extensions page of the chromium browser, loading it by clicking on "Reload (Ctrl+R)".
I'd like to be able to make a change to my unpacked chrome extension and load it into the browser in an automated way, especially since I'm testing the extension on a virtual machine so doing all this completely headlessly would be ideal. However, I would at least like to avoid having to click every time I want to load my extension, and I'd like to be able to collect any errors produced into a file/tty.
What is the best way of doing this? Does chrome provide tools for automating extension building and testing?
Regarding the other question linked below:
It doesn't really address my problem, since I am looking for a way to get console output, stack traces and any output generated by the extension reload to be accessible via a file/stream in my OS, as opposed to being displayed in a chromium browser window. The linked answers provide a way to reload the extension programmatically, but not much else.
There are a few avenues for you to research.
You could look into enabling logging with a high verbosity. In principle, I would think there is a level that echoes console output; I'm no expert though.
You could use Native Messaging to speak to a daemon that will log things for you; the downside is that you probably can't catch errors this way.
You could take this one step further and create an extension that attaches to your target extension with Remote Debugging protocol (which provides the same info as DevTools) using the chrome.debugger API, and then log stuff with Native Messaging.
Or, you could eschew using an extension as a supervisor and just use/write an external Remote Debugging client.

Detect from inside of the JavaScript that the Chrome browsers Debugger has attached to my code

I have a web application that consists mostly of JavaScript and I know the only browser thats ever going to open that web page is going to be Chrome.
Is there a way for my JavaScript to realize that the developer console of Chrome has been opened i.e. the Chrome JavaScript debugger has attached?

Categories

Resources