Append string to UserAgent on Chrome? - google-chrome

I want to append a string to the UserAgent of a PC running Chrome, and not change the UserAgent altogether because I still want the browser to be recognized as the correct Chrome version. I could just use a UserAgent switcher and enter in the current UserAgent but then it wouldn't be correct after a few updates. The website contains some WebRTC elements so it's imperative that the correct version of Chrome is detected.
The reason is this, we have developed a website for an apartment complex of elderly people. They can use it at home, but the owner of the complex has also put two all-in-one PCs in the lobby for people without PCs to use.
Those PCs run Chrome in kiosk mode, and I need to be able to detect visits coming from those PCs. Outgoing links have to be opened in an iframe (since they can't open/close tabs) and I run some javascript that automatically logs people out after 5 min. But all that only has to run on those 2 specific PCs, I don't want people to get logged out at home.
I tried detecting it simply by checking the screen height like so:
if (screen.availHeight || screen.height-30) <= window.innerHeight) {
// code
}
But that breaks when people use Ctrl-+ to zoom in. The window.innerHeight will change and the if statement won't work. Any other methods of detecting a fullscreen website didn't work, or only detect if the browser supports fullscreen.
Is there a plugin/method of appending a string to the UserAgent so I can check for it using Javascript? Or any other way of detecting Chrome in kiosk mode? I don't want to add a query to the url, that's technically impossible for our website.

Related

Video is not playing in one iPad specifically

I am developing an app for iOS which includes a UIWebView which, among other this, contains a video (stored locally, in the same folder as some images which are being displayed correctly).
This works fine in my own iPad, but I have been given another one at work to install the app to and there it shows nothing more than the video controls. When I click on the play button nothing happens. The iPad is owned by the company so any security feature might be enabled.
I have researched quite a lot and I cannot find any reasons why the app may be working on one iPad and not on another one. I know it might be impossible to fix without having a passcode or something like that but I need to know at least which configuration might be the one that is making the app not to work.
Using WKWebView fixed it. UIWebView should not be used any longer unless it is specifically needed.
From Apple documentation:
In apps that run in iOS 8 and later, use the WKWebView class instead of using UIWebView. Additionally, consider setting the WKPreferences property javaScriptEnabled to false if you render files that are not supposed to run JavaScript.

How can I cast an HTML page with the Google Cast Chrome extension?

I'm building a simple web application that I want to be able to display on a TV screen using the Google Cast SDK, the Chrome browser and a Chromecast. I know with the Chromecast extension for Chrome Browser, I can cast a tab to a Chromecast device, which, from my laptop works perfectly. However, I want this exact same functionality, but available from iOS devices (iPads and iPhones) running the Chrome Browser.
It seems since Chrome v36 the Cast ability is baked into the iOS versions of Chrome. I have pulled in the Google Cast SDK per these instructions: https://developers.google.com/cast/docs/chrome_sender. I am able to get my iPad to connect to the Chromecast, but when I try to pass in a URL to a web page...
var mediaInfo = new chrome.cast.media.MediaInfo('http://google.com');
var request = new chrome.cast.media.LoadRequest(mediaInfo);
session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError);
I get an error...
invalid_parameter
I have found other, somewhat dated examples, saying I can build a custom Cast Receiver that holds an iFrame and renders the page in there, but I do not want to build a custom Cast Receiver.
Can I accomplish this with just a Cast Sender?
You always need a receiver on the chromecast; that is what gets loaded there. In general, you can either use a default/styled receiver or a custom one. The Default or Styled receivers can only handle media so you are left with the Custom option and having an iframe is the way to go.
Chrome on iOS doesn't support casting. There's a post from early 2016 saying this on the google product forums. (But my reputation is too low to post more than two links).
If it DID work, then all you would need to do is go to this site and choose the ChromeCast option and press Launch after typing in your website. This does work on Chrome on desktop.
The source for this sender/receiver is here: https://github.com/boombatower/chromecast-dashboard
I've used the boombatower.github.io receiver with my own code as sender in an iOS app. I'm also looking at whether an app extension would work, but I suspect not because of app extension limitations.

Is there any way to know if a download is happening

Is there any way to know if a download through a browser is happening? (I am thinking of creating an app,though whole concept relies whether this particular feature is possible or not)
For example: Say I start downloading a file from a web browser, and a program is running in the background( preferably written in Java) which can detect that a download is happening and it can get access to the link.
Ideally it should be able to detect from any browser, but even if it works with one browser it is fine for me at the moment! Any ideas if this is even possible?
I want to do the same thing. My first thoughts are :
1. Low level browser independent :
Sniff traffic and filter captured packets (Protocols HTTP/FTP + other filter rules). You may use WinPcap or even try the LSP approach.
2. High level browser dependent : Create browser plug-ins (BHO for Microsoft Internet Explorer, Extension for Google Chrome, Add-ons for Mozilla Firefox)

using user default browser with htmlloader

so I wrote code in an air app that auths with google / youtube. The code itself is working as expected. The problem is that when I open the auth window using HTMLLoader, it uses the default browser of the machine (safari on mac, ie on win) rather than the default browser that the user uses. So existing sessions that the user has on their default browser are useless. I have added code to account for all scenarios, but I would like to think there is a way to use the users preferred browser and benefit from logged in sessions etc.
I found and tried the property navigateInSystemBrowser which didn't sound like it would help... and interestingly that made the browser stop working. The links in the browser window no longer worked.
Anyone know if this is possible? Am I missing something simple here?

How can I get notification of page load events in Chrome?

I need to be able to monitor navigation events (such as page loads or switching between active tabs) in browsers running on a Windows PC. So far, I can get this to work in IE and Firefox by loading a DLL into all running apps via a call to SetWindowsHookEx, then asking for either the IHTMLDocument2 (in IE) or nsIWebProgress (in Firefox) interface from the application. I can use the appropriate interface to request a callback from the application when an event of interest happens.
Is there a way to do this in Chrome? I have read a little about Chrome extensions, but I have not found any documentation on an API exposed by Chrome that is analogous to COM in IE or XPCOM in Firefox. Will a similar approach work or will I need to do something completely different? (I am working in C++.)
I would appreciate it if someone could at least point me in the right direction.
Thanks.
With Chrome extensions API you can register some events handlers for changing state of tab like when document state is changed (loading or loaded), when new tab is added/removed from window or when user switch between tabs.
More about tabs events You find on http://code.google.com/chrome/extensions/tabs.html#event-onActiveChanged