3 ms·
If you want to build a “content script”-type extension that does nothing but interact with the page and run normal JS, think about building the extension on the
by roryokane 13y ago
If you want to build a “content script”-type extension that does nothing but interact with the page and run normal JS, think about building the extension on the GreaseMonkey platform. GreaseMonkey (http://www.greasespot.net/ http://www.greasespot.net/) is an extension that lets you write a content script as a single JavaScript file, with metadata such as the name and version written in specially-formatted comments at the top of the file. That makes scripts easy to develop and install. GreaseMonkey also provides a few functions that allow you to do some things that browser security doesn’t normally let you do – http://wiki.greasespot.net/Greasemonkey_Manual:API http://wiki.greasespot.net/Greasemonkey_Manual:API.
“GreaseMonkey” is only a Firefox add-on. But there are GreaseMonkey-compatible extensions for other browsers, such as Tampermonkey for Chrome (https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en https://chrome.google.com/webstore/detail/tampermonkey/dhdgf...) and GreaseKit for Safari (https://www.macupdate.com/app/mac/20718/greasekit https://www.macupdate.com/app/mac/20718/greasekit). Thus, GreaseMonkey scripts are automatically cross-browser. Chrome even supports installing GreaseMonkey scripts natively, but only through a convoluted process, for security reasons. The reason people made clones for other browsers is the huge library of existing GreaseMonkey extensions at https://userscripts.org/ https://userscripts.org/.
The downside of GreaseMonkey is that the user needs to have a GreaseMonkey-compatible extension installed to run your script. So your extension depends on another extension. It’s also harder to use a build system while writing a GreaseMonkey script, if you want to write it in CoffeeScript or something.
- zxcvgm 13y agoactually Chrome already has native support for GreaseMonkey scripts since a while ago [1]. You can just install scripts directly from http://userscripts.org http://userscripts.org. [1] http://blog.chromium.org/2010/02/40000-more-extensions.html http://blog.chromium.org/2010/02/40000-more-extensions.html
- Flenser 13y agoIf you're a developer of scripts, or want to be able to dive into the source then it's easier to install them via Tampermonkey[1] which provides an editor. It also auto-updates greasemonkey scripts which I don't think chrome is able to do natively. [1] https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo https://chrome.google.com/webstore/detail/tampermonkey/dhdgf...
- fphilipe 13y agoThe other day I needed a script to tweak images on Wikipedia so I looked into Greasmonkey. I installed it on Chrome and started writing the script. Then I remembered that I'd seen an alternative before which simply runs a JS file on your FS that contains the URL's host inside ~/.js. It's called dotjs [1] and it's really strait forward to use as it does not require the complicated header section. See the tiny script I wrote to see how easy it is to run custom JS on any domain [2]. [1] https://github.com/defunkt/dotjs https://github.com/defunkt/dotjs [2] https://github.com/fphilipe/dotfiles/blob/master/js/wikipedia.org.js https://github.com/fphilipe/dotfiles/blob/master/js/wikipedi...