Enhance Facebook Notes with Greasemonkey

greasemonkey hack

The UI of Write a New Note of Facebook is quite straightforward and … shabby:

The UI of Write a New Note in Facebook
The UI of Write a New Note in Facebook

If you happen to use Firefox, this userscript would make Facebook’s notes suck less.

Screenshot

The UI of Write a New Note in Facebook
The UI of Write a New Note in Facebook

Requirement

Usage

Exactly the same as WordPress’s quicktags, – no wonder, the core functionality is a port from WordPress’s quicktags.js:

License This piece of script is released under the GNU General Public License as WordPress, a compatible license would make my life much easier.

Install this script

Development

The development is a little bumpy than my expectation. The biggest obstacle in the way is the namespace in Greasemonky is not consistent to the general DOM model. When the page is loaded, GM takes control, we may manipulate the DOM nodes using various ways. When it is done, all the object in GM’s anonymous global namespace runs out of the scope, and they are garbage-collected.

For every rule, there is an exception: the closure as documented in the bible. The anonymous function would create a closure that wraps a function in the GM’s namespace. However this does not work for us since we need to maintain several records to bookkeeping the status. So eventually we have to inject the scripts and objects into the host. Here is a tip to inject the functions, but for the Javascript objects, we have to manually do the dirty work, error-prone and tedious. If you have a better idea to access the objects that resident in the GM namespace, please leave a comment here.