chrome.input.ime - Switch between languages - javascript

I am creating an application which supports multiple regional languages using "Google Input Tool" chrome extension.
can I switch between input languages on "onfocus()" event of an element?
I have searched on the net and come across "chrome.input.ime"
but don't know how to manage it with JavaScript
I found Extension ID "mclkkofklkfljcocdinagocijmpgbhab"
and need something to do like
chrome.runtime.sendMessage({ up: 1 });
Can anyone help?
~Manoj

chrome.input.ime allows you to implement a new input method on Chrome OS only. So it's not what you seek.
It does not seem like you can control the GIT extension from your code.
You suggest messaging the extension; however, it does not listen to any external messaging events - I have explicitly verified that. So it wouldn't work.

Related

Detect user installed browser extensions with JavaScript [duplicate]

I spent a fair amount of time trying to determine why my view of a site didn't match a clients, after looking at the cache etc. we determined the problem to be with one of the add-ons (Adblock Plus in this particular case). It would have been much simpler if we could have had an easy way to query what add-ons were installed, and ideally active. Is there anyway to generate a list programmatically perhaps with JavaScript?
No, you can't do this with user/page JavaScript. I imagine it would be a security risk, if you could.
But there is an add-on you can install that will generate a printable, copyable list of installed extensions/Add-ons.
Check out: "Extension List Dumper".
You cannot get a complete list just by using Javascript, but some Addons allow a check anyway.
accessing the chrome://-protocol was considered a security risk and
therefore has been disabled. Nonetheless you can still accomplish to detect
an extension with the image-load trick. Why? Because extension
developers may mark their extension as web-accessible setting the
property “contentaccessible=yes” inside the chrome.manifest file of
the extension. This is e.g. the case for the two famous plugins
Firebug and Web Developer Toolbar
source: http://webdevwonders.com/detecting-firefox-add-ons/

Enable/Disable Chrome global commands

Looking through the API docs I think that the answer to this is no, but is there any way to toggle support for Chrome commands from inside an extension?
The problem: When using global commands Chrome will hijack that hotkey so other applications that are listening for that key will never get it. For example, I have an extension that uses the media keys. Many desktop applications (itunes, etc.) use the media keys as hotkeys as well. When the extension commands are set to use the media keys globally, Chrome is the only application that receives those key presses.
There is a bug report here about this problem, but no work has been done on it yet.
From an extension perspective, the best solution with the current implementation would be a button inside the extension's browser action that could toggle Chrome listening for commands (which would in turn free up the keys that it is listening for). Is anything like this possible?
The best that I have come up with is a button inside the browser action to actually disable the extension (using management.setEnabled). The problem with this approach is that the user will then have to navigate to chrome://extensions to re-enable it - far from ideal.
I have been recommending to my users to change the hotkeys to something else if they are encountering this problem, but that is also not a great solution.
Any other suggestions?

How would one monitor JavaScript execution in a web browser programmatically?

I would like to be able to know when arbitrary JavaScript successfully executes a command in a web browser. The medium doesn't matter, it could be a log, stack trace, event signal, it just has to be something that can be programmatically analyzed.
I've thought about this problem for some time now and I have not been able to come up with an adequate solution. I'm no expert with JavaScript though, so I'm wondering what ideas you have?
Since you'll probably be wondering why, it's just something I'm very interested in.
Any input is appreciated. Can you help me?
EDIT: I've investigated using something like Firebug to monitor JavaScript functions, however I wasn't able to determine if Firebug can be run programmatically on a simulated Web Browser (like a web-browser control in ASP.NET, which is what I'm currently using.) Does anyone know if it can?
You can use the profiler of Firebug.
Go to the console tab and click Profile. The profiler starts and all the javascript actions are "logged" till you click Profile again. Then you get the list of javascript functions that were executed in this interval.
A similar feature is available in most modern browsers' consoles.
Source: See/Log which javascript function is being executed by the browser
The firefox browser could be used in asp .net using the selenium web driver and it also provide the ability to access all details from a web page. see the document and download api code and integrate it in your project its very easy to integrate using its help.
http://docs.seleniumhq.org/projects/webdriver/

Start speaking text

I am wanting to incorporate the built-in text-to-speech tool on a mac to a website. Basically, the website will show a list of tasks, and in a different view mode, it will only show one task on the screen. In the "one task" mode, I want to to the "text-to-speech" software on Macs to read the task. I would want to do this on a PC too, if they come with a similar tool built in (unlikely).
Is there some JavaScript command I could use to tell it to start speaking the text, or is this way too advanced for JavaScript?
There isn't any JavaScript command but you can use:
http://www.jtalkplugin.com/
https://github.com/kripken/speak.js
Both seems like a good option to gain the ability to 'start speaking the text'.
Text-To-Speech is part of the os and not of the browser (or any HTML specifications for that matter). Thus there are several hypothetical ways of triggering it:
Call a js function that does a call to the underlying OS
I have not hear yet of any browser that implements that
Call AppleScript from JS
I have not hear yet that this is possible
Create a browser extension that is capable of calling AppleScript/Underlying OS/Shell command...
Probably your best bet but then the webside is non-function without the extension
I don't think you can access OSX's text-to-speech feature directly, but if you're looking for a text-to-speech solution, you should look into speak.js:
Speak.js on GitHub
Working demo of speak.js

how to start up a desktop application in client side

In my web page, I have to start a desktop application on the client's computer if it's installed. Any idea how I can do this?
If the application is MS Office or Adobe Reader, I know how to start them, but the application I want to start is a custom application. You can not find it on the internet.
How can I open the application?
Basically it's not possible to achieve unless an application registers a protocol that will trigger it. If it does that all you need to do is to provide a link using this protocol
yourcustomapp://some.parameters
Another way the 3rd party app can integrate with the browser is if it hooks to it as a plugin. This is how flash apps work etc.
If the app you are trying to launch does not support something like that it's going to be close to impossible to achieve what you want.
The browser sandbox prohibits you from executing local resources, for good reason - to thwart a website destroying your box with malicious code. I've been researching the same functionality.
The only solution I've found is to build an extension in Mozilla Firefox which can launch your app. Extensions live outside the sandbox so they can execute local resources. See this page for how to do that. You may be able to do it cross-browser using crossrider, though I haven't had success with that yet.
You could alternatively build a thick client populated from a web service, and launched from the browser through an extension as mentioned above. This is what I'm doing to get around the sandbox. I'm using local XUL for this.
See my question for additional discussion.
First off - you can't do it using javascript in any sort of a portable mechanism.
If the application is ms office or adobe reader,I know how to startup them
No you don't - you know how to send a document, which the browser associates with these applications and invokes them supplying the name of the local copy of the response. You can't just start the programs.
You just need to do the same for your app - invent a new mime type (the major type would be 'application' and by convention, non-standard minor types are prefixed with 'x-', so you might use application/x-hguser) then associate that mimetype with the relevant program browser side.
i.e: You need to explicitly configure each browser
I already encouter that problem in some complex production environnements.
I do the trick using the following code :
function launch(p_app_path)
{
var oShell = new ActiveXObject("WScript.Shell");
oShell.Run('"' + p_app_path + '"', 1);
}
In IE options > Security > Customize the level > ActiveX controls and plugins > Initialization and script ActiveX controls not marked as safe for scripting, set the value to Ask or Active.
It isn't a security problem when your website is enclosed into a specific security context.
And as they say, it's not worth it to build a gas plant.
JavaScript alone can't do this. (No, not even with MS Office or Adobe Reader.) Thankfully.
There are a number of old ways, including using ActiveX, which may work for your needs. As others have pointed out while typing this, you can customize responses based on the mime type or the protocol, etc.
Any way you look at it, you're going to need control over the end users' browser. If you're in a close environment where you can dictate policy (users must use a specific browser, with a specific configuration), then you're going to need to do that. For an open environment with no control over the end users, you're out of luck.
I'm actually having a lot of success right now with SiteFusion. It's a PHP client/server application framework that serves out XUL/JavaScript applications from a server deamon running in Apache. You access applications from a very thin client in XULRunner, or potentially off a web page using extensions. Clients can execute on any platform, and they're outside of the browser sandbox so you can access local resources such as executables. It'a a fairly elegant solution, their website provides great examples and documentation, and their forum is very responsive. I actually found a minor bug in passing arguments to local executables, posted a question about the forum, and it was fixed by the chief developer in under 15 minutes. Very impressive, overall!

Categories