Emulate Greasemonkey functions
- Published: 2005-05-30 23:16
- Modified: 2005-10-27 12:57
- Author: TarquinWJ
- Requires: Opera 8.0
- Install as: Opera User JS
Learn how to install scripts
- Stores the variable value as a cookie so it can be retrieved later. With Greasemonkey, these would be available to the script no matter what site it is being used on. With this script, it is available only for the current domain (as with normal cookies). Unlike Greasemonkey, which can store only numbers, strings and boolean values, this script can store regular expressions, dates, functions, arrays and objects as well.
- Returns the previously stored variable using the given key. If none, it returns the defaultValue, or undefined if no defaultValue is provided.
- Deletes the stored value - this is not a normal Greasemonkey function, but it just seemed sensible to provide a way to delete them again…
- Adds a menu item with the specified title that runs the specified function when clicked. Unlike Greasemonkey (which uses the browser’s own menu), this script places a menu in the top right corner of the page when needed - it is even keyboard accessible, using spatial navigation.
- Synonym for the XMLHttpRequest constructor. With Greasemonkey, this has no cross domain restrictions. I cannot replicate that behaviour here.
- Synonym for window.opera.postError.
Additionally, it maps window._content to window, as this is unnecessarily used by many Greasemonkey scripts.
Note: many Greasemonkey scripts also use XPath (whether they actually need to or not is beside the point). If you want to use these scripts, you can either use Opera 9, which natively supports XPath, or use Cameron McCormack’s excellent script library, which should provide the necessary functionality in Opera 8.