firefox: Thu Oct 6 02:50:00 2005

Thu Oct 6 02:50:00 2005

Working through http://diveintogreasemonkey.org, planning to clone everything I had with applescript and Safari.

Looks like window-logging can be done with onOpen/onClose (or is onOpen implicit? given butler, it probably is) and xmlhttprequest...

ooh, since we're firefox-specific, we can use data: urls...

window.addEventListener("load", ...) can be used to run once pageload completes

window.location.href

"click" event - event.stopPropagation(), event.preventDefault() (too raw?)

GM_xmlhttpRequest({
    method: 'GET',
    url: '<http://greaseblog.blogspot.com/atom.xml',>
    headers: {
        'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',
        'Accept': 'application/atom+xml,application/xml,text/xml',
    },
    data: '...',
    onload: function(responseDetails) {
        var parser = new DOMParser();
        var dom = parser.parseFromString(responseDetails.responseText,
            "application/xml");
        var entries = dom.getElementsByTagName('entry');
        var title;
        for (var i = 0; i < entries.length; i++) {
            title = entries[i].getElementsByTagName('title')[0].textContent;
            alert(title);
        }
    }
});

-- like xmlhtprequest, but it isn't domain-restricted!

comics: add a fetch-next-comic-and-redirect-then-insert-myself button? [use zoomtextarea createButton? ]

document.evaluate("//text()", document, ...) - gets all text nodes, useful for search-and-replace - but is it right for getting snapshots?

GM_setvalue, GM_getvalue - script+user specific - so probably not helpful

GM_registerMenuCommand - tools->user script commands-> ... might do, for snapshot this

"Hide Google Redirects" reprograms Google Personal Search History to use normal <a href="..."> links, but still track clicks by calling GM_xmlhttpRequest on the appropriate tracking URL.

Use http://www.letitblog.com/greasemonkey-compiler/ to take the prototypes and extend them - add menu items everywhere, etc.

GeoTagThisPage: figure out if getting text nodes helps write values back, using offset mode... or use

paras = document.getElementsByTagName("p")
append paras[n].innerHtml

and unpack later...

  txt = document.evaluate("//text()", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null)
  [object XPathResult]
  # but use XPathResult.ORDERED_NODE_SNAPSHOT_TYPE instead!
  txt.snapshotItem(6).nodeValue
  This is my personal collection of Chocolate-related books, including cookbooks, texts, and other books on the subject.
  txt.snapshotItem(6).replaceData(0,9,"ChocoFoo")
  actually changed the page!

useful trick:

params = [ "foo=bar", "baz=3" ];
params.join('&');