Browser Hacks

Browsers should be a lot more hackable; some bits I've done with firefox and conkeror that should have been a lot easier...

See page_saver_server for the actual code.


firefox: Tue Jul 24 01:50:00 2007

Tue Jul 24 01:50:00 2007

I did try the search-through-HTML approach to strip the Conkeror link-numbers (since I have the cut&paste selection with contamination, and the raw HTML of the page, I can search for one to find the other.) My results were fuzzier than I liked, and refining the effort didn't really hold my attention.

I found something simpler:

function strip_numbers_hard()
{
   removeExisting(document.commandDispatcher.focusedWindow.document);
}

If I run that before the cut&paste, I lose the numbered-links entirely, and the existing code should just work...


firefox: Tue Nov 21 18:36:00 2006

Tue Nov 21 18:36:00 2006

Since moving to the thinkpad, I've been temporarily tagging things differently, so I can reassemble things into a consistent whole later. It's now (much) later. I think I'll also try to do some kind of "search through the HTML" trick to counteract the not-so-hidden numbers from Conkeror link-numbers.

I still want to grab the HTML of the selection instead, but I don't have time to add this to firefox myself - that starts moving in the direction of building my own browser and I really shouldn't go there :-)


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('&');