Capture web page data using native language code - javascript

I'm looking for leads on how to capture web page metadata from the current browser page. I want to create a feature in my application that will allow the user to press a hot key and record meta data from the web page currently open in the user's browser. My application will be running minimized, this feature is to be activated by a global hot key.
I'm using nw.js (formerly Node-Webkit) to create this application, so ideally, the solution would be javascript running in a desktop installation of Node.js. If this is not practical, I understand that I can call platform specific code from nw.js, so solutions developed in any desktop os language would be of interest.
My application targets OS X and Windows.
I'm hoping to capture metadata from all major modern browsers (Chrome, Firefox, Safari and IE 10+).
At a minimum I need to capture the page url, but I also want to capture Keywords, Description and highlighted text for the source web page.
I need to implement this function without modifying the source webpage in any way, and I prefer to avoid the need for browser extensions, bookmarklets or plugins.
If a solution exists using a remote controlled browser extension (no user interaction) that would be of interest, but ideally I want to avoid requiring the end user to install or interact with anything but my application.
My search to date has located no information on reading web page information from applications outside the browser.
Any thoughts or leads are much appreciated.

Related

How do i extract the number of windows open?

How do I detect the number of windows open on the screen?
Like for example, if I have chrome, visual studio, notepad open, I need to get the number of windows open as 3.
Is there a way to detect the number of windows open, specifically from a screen share or via javascript as the application is going to be an online exam taking website?
Websites are highly sandboxed programs. They don't communicate with the OS directly, only through Web APIs. If the feature you want is not available in the Web APIs, you cannot use it.
I don't know every Web API, but i don't think there's any that gives access to the number of open windows. The Screen Capture API looks promising, but I found no method that returns the number of open windows.
Also, even if there was, you would be trusting the user that he/she didn't modify your client (your client-side code), and I believe in this case you don't want to trust the user.

Is there a way to detect if MS Visio, MS Word, or any MS Office app is installed on computer from IE & Chrome?

I have a SharePoint 2019 document library wherein I have a custom JavaScript code to open the MS documents (Word, Excel, Ppt, Visio) in the client application. I am using Office URI schemes for opening the documents in client apps. However, if there is no client application installed on the computer, the Office URI scheme fails without throwing up any error. I want to know if there is a way to check from the browser (IE and Chrome) if a particular MS application (Visio, Word, etc.) is installed on the computer.
P.S. I have tried the ActiveXObject approach, but for some reason, it didn't work for me and, also I want a solution that will be cross-browser compatible and afaik ActiveXObject is supported only on IE.
(Current MSFT employee in Office here. On the team that owns the link invocation handling for the native client side but not the SharePoint or JS side)
The root problem is that the browser object model doesn't give you a result for navigating to the ms-word/etc links. As I understand it that is why the built-in SharePoint open UX has 2 options. One to open in the browser and another to open in the native client. And there is interstitial UX to prompt the user if the file did not successfully open in the native client.
(And, correct, the ActiveX solution will not work even with modern Edge on windows either and is a dead-end technology wise.)
You can try using ActiveX technology to instantiate Office application as described on the detect microsoft office version using javascript thread. But Chrome is not aware of COM technology. So, any code for creating an Office application instance will fail.

Is it possible redirect user to launch scanner application?

I'm writing an application to show the uploaded documents using python3-django-1.8.1. We also want to allow user to scan a document.
As you know that, there is a print dialog in javascript.
window.print()
Is there any support in the browser to scan a document?
Is it possible to launch a scanner application on clients machine, using javascript/python?
like:
"Windows Fax and Scan" on Windows machines
"Simple Scan" on linux, etc. OR
Whatever the default scanner application on respective os of the client.
Any third party python application/js plugin allow to scan a document?
I am not too familiar with a image scanning feature, but I had faced a similar issue with a barcode scanner.
You cannot actually expect something similar to printing, as printing is a browser-enabled feature whereas scanning is something a typical browser does not do.
Moreover, JS has no capability of accessing peripherals directly. What would happen if this page would be browsed by a mobile? (A scan from the camera would be fantastic but never heard of anything like it).
Having said that, there is a scanner.js SDK:
scanner.js enables any web page to acquire images from scanners using JavaScript in most desktop browsers like IE, Chrome, Firefox and more. In most cases, software install is not required and the user can enjoy a great scanning experience.
Also there is a Twain SDK:
Dynamic Web TWAIN is a TWAIN-based scanning SDK software specifically designed for web applications.
These are supposingly dealing with your issue but I haven't used them. Scanner.js demo is not even working now on my Ubuntu machine. My guess is that they are not entirely JS-based anyway (com objects and stuff).
Other things to do is to have a small Firefox plugin developed if your case is specific (such as Intranet) so to control the users' browsers.
Last, but not least, another option would be to develop and provide a small desktop app to handle scanning and uploading.
If there is any other recommendation I would love to see it.

How to create web app shortcut on user's desktop programmatically?

For enterprise intranet web application, is there any way to create a desktop shortcut of web application on user's desktop? I'm looking for functionality similar to Google Gears, but without installing Google Gears. I'm looking to give user's a link on web application that says "Click here to install desktop shortcut", when they click on it, a desktop shortcut is installed with the custom icon for our application. Is there a way to do it using javascript or any other client side technologies? I don't want to run any exe on user's machines. Even though it's intranet, I have to jump through lot of corporate hoops, compliance approvals, etc to run exe on their machine. We are trying to avoid that, due to time constraints. User machines are windows XP with IE6 installed. They may all upgrade within next year's time to Windows 7 with IE8. Intranet web application in question is developed using asp.net 3.5, c#.
If this is really a corporate environment then just go talk to the network operations team.
It should be trivial for them to add something to the login script to push this link to the people's desktops.
More Info:
http://www.petri.co.il/forums/showthread.php?t=6154
http://social.technet.microsoft.com/Forums/en/winserverGP/thread/02a7bfbb-180f-40eb-82e3-2343b2bf31eb
Alright, at first I thought that this was an impossible task, until I realized that it's not.
A shortcut is just a file, and we all know you can download files from links.
I'm not sure how well windows shortcuts can be transferred from computer to computer, but I would assume that a shortcut with a location like http://www.google.com/ is not tied to any specific windows machine.
You could zip the shortcut, and point the link to the location of the zip file. Tell the users to unzip the file and place the shortcut. You may be able to just serve the shortcut, but you'd have to give the right headers, and probably specify application/octet-stream or something like it.
Alternatively you can tell them to right click, go to new -> shortcut, and copy-pasta the url into the location box.
Alternatively you could write a batch file for the users to download that opens a url in the default browser.
I know it's not quite as direct as click-button -> receive bacon but it will work.
Try looking at SaveAs
document.execCommand("SaveAs", false, "url to desktop");
The user will still have to click save and it only saves a HTML page. You would have to open a hidden IFrame containing a web application and call .execCommand on the iframe's document.`
You can create a shortcut (.lnk) file in a directory in your site and put it as the Url for a hyperlink so the users right click and save as they download the .lnk file. Your server will need the mime-type .lnk application/x-ms-shortcut adding.
The icon can be done by putting it on a network location and using the "Change icon" function to refer to this network location. This works on Windows. I suppose it could be adapted for each OS required?

What is the best way for a website to check if a user has installed a client app?

Let's say I've got a website that works better if a client has installed and logged into a desktop application. I'd like to be able to do 2 things:
Alter the website if they haven't installed the app (to make it easy for them to find a link to the installer)
If they've installed the app on a couple of machines, determine which machine they are browsing from
I'd like something that works on Windows and OSX, on any of the major browsers. Linux is a bonus.
A few thoughts:
Websites can detect if you've got Flash installed. How does that work and could it be used for both of my goals?
Could I just let the client serve HTTP on localhost and do some javascript requests to fetch a local ID? I know google desktop search did something like this at one point. Is this a standard practice?
Thanks!
You can register a protocol from your desktop application (see this). This can be used, for example, to open your desktop application with arbitrary data from the website. You could then have your desktop app send a HTTP request to your webserver, telling it what machine you are on.
You can have a browser plugin (activex for IE or Netscape plugin for the rest of the browsers) that can communicate with the application. When the webpage is loaded, it can try to instantiate the plugin and if it succeeded, it can use it as a proxy to the application. If it fails, then either the app is not installed or the plugin was explictly disabled by the user. Either way, your website should degrade its functionality accordingly.
Update: Forgot to answer your questions:
Flash does it exactly this way. Flash is a browser plugin that is created by the web pages.
You can have a machine ID generated at the application/plugin install time and your plugin can pass that machine ID to the webpage when it is created.
On the topic of using local webserver:
I would stay away from having a local webserver, mainly because of security considerations. It takes quite a lot of work to make sure your local webserver is locked down sufficiently and there are no XSS vulnerabilities that other malicious websites can exploit to make it do stuff on their behalf.
Plus, having a webserver means that either it has to run as a system-wide process, or if it runs as the user, you can have the website interact with only one user's instance of the application, even though multiple users can be logged on and running it at the same time.
Google Desktop Search suffered from both the XSS security vulnerability (though they fixed it) and the limitation of only one user being able to use it on a machine (I don't know if they fixed this one yet, though chances are they did).
Websites can detect if you've got Flash installed.
Actually, I believe a browser can detect if you have the Flash plugin for the browser installed, and webpages can offer "installed" and "uninstalled" option that the browser can choose.
Otherwise, you are asking for a means, by putting some code in a webpage, of being able to analyze a user's home computer, and report what it learned to you website.
Can you say Major Security Hole?
If you can pick a development environment for the desktop app, then check out AIR from Adobe. It lets you develop desktop applications using either html/javascript, Flash, or Flex.
It has API calls you can use from a browser based flash app to see if the desktop based AIR app is installed, what version, etc. You can even launch it and pass parameters from the web app to the desktop app.
http://www.rogue-development.com/blog2/2008/03/interacting-with-an-air-app-from-a-browser-based-app/
Websites can detect if you've got Flash installed. How does that work and could it be used for both of my goals?
it's quite a bit simple, your browser tries to render some additional files, with some specific formats such as flash .swf and I the browser doesn't find installation, then will be start downloading, or you will get the option to download that program.
Flash also uses AC_RunActiveContent.js please take a look at this js, people usually put this on their webpages
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave cabs/flash swflash.cab#version=8,0,0,0','width','981','height','635','id','build5','align','middle','src','build5','quality','high','bgcolor','#ffffff','name','build5','allowscriptaccess','sameDomain','allowfullscreen','false','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','build5' ); //end AC code
}

Categories