Miscellaneous collection of Google Apps Scripts.
To add a script to an existing document, go to
Tools > Script editor... and
Ignores table of contents and text [in brackets] when calculating word count. Optionally lets you manually adjust the word count, or have a custom "ignore everything after this point" marker.
You can also directly update a spreadsheet with your word count — useful for writing challenges like NaNoWriMo. (It does assume that your spreadsheet is laid out the same way as mine is, however; I'll make it more generic if folks ask for it.)
Google Apps Script editor, if you want:
rm WordCount.gs ; cat *.gs > WordCount.gs