I am developing an extension that will read HTML elements value, then make API calls to an external website, get the results and display them in newly created HTML elements.
What are the pro/cons of writing it in native chrome extensions vs. userscripts?
There are a few differences between a native Chrome extension and a user script.
See this wiki section for a list of differences between Greasemonkey scripts and Chrome userscripts.
If you want to take advantage of cross-browser user scripts, try to not use GM_*
methods or unsafeWindow
.
From a developer's perspective, there is no advantage of preferring either User scripts or Chrome extensions, because any user script can easily be embedded in a Chrome extension.
If you view this topic in the light of deployment, then the differences are significant:
I recommend to develop native extensions. You can easily create a Chrome extension from a user script by using the following directory structure:
manifest.json
whatever.user.js
Minimal manifest.json:
{
"name": "name of extension",
"version": "1",
"manifest_version": 2,
"content_scripts": [{
"js": ["whatever.user.js"],
"matches": ["http://example.com/*"]
}]
}