Google Chrome team has just announced some new features for Chrome extensions, which bring many improvements and simplicity in coding for the developers. These features include direct cross-origin XMLHttpRequest calls in the content scripts and new API to configure browser’s proxy settings.
XHR & Greasemonkey Script
Before this announcement, Chrome extension developers were required to use a background page for cross-origin XHR and depend upon certain event listeners. But now, they can implement cross-origin XHR directly in their content scripts.
This has simplified the development process – and brought a really awesome feature to Chrome: support for GM_xmlhttpRequest function. The GM_xmlhttpRequest is an advanced Greasemonkey script API, integrated with the standard Greasemonkey Add-on for the Firefox. Though Chrome has been supporting greasemonkey scripts for long, the GM_* APIs were not supported thoroughly because of the limitations like above. But now, as the cross-origin XHR can be directly implemented in the content scripts, Chrome’s support for greasemonkey scripts has extended. Now, all greasemonkey scripts using GM_xmlhttpRequest should work with Chrome. Just to remind you here, Chrome natively supports userscripts, opposite to Firefox where a separate add-on installation is required.
More new features
Chrome has improved match patterns for content scripts by adding exclude_matches array, which is similar to @exclude of Greasemonkey scripts. Developers can now specify URL patterns more effectively. Along with this, new API for configuring proxy settings has been introduced, which enables managing proxy settings using extensions. To test this feature, users can install Proxy Anywhere and Proxy SwitchyPlus extensions. All above announced features are now live in Chrome 13+.