On Tue, Jan 3, 2012 at 8:47 PM, John J. Foerch <[email protected]>wrote:

> On Tue, Jan 03, 2012 at 07:29:48PM -0800, Sean McAfee wrote:
> > What next?
> >
>
> Now you can either scrape with regexps, or, if the content is well-formed,
> you can use DOMParser to create a DOM tree that you could do xpath queries
> on.
>
>
Well, I eventually decided I wanted some slightly different behavior: When
I visit the index page, I want Conkeror to open a new buffer for each game
waiting for me to move, except for the first game's buffer, which should
replace the index page.  That was relatively straightforward using
buffer_loaded_hook:

function open_boardgaming_buffers(buffer) {
    var $ = $B(buffer);
    var seen = { };
    $("td.tabPartiesFond2 a").map(function (i) {
        if (!seen[this.href]) {
            seen[this.href] = true;
            return { first: i == 0, href: this.href };
        }
    }).get().reverse().forEach(function (game) {
        var target = game.first ? OPEN_CURRENT_BUFFER : OPEN_NEW_BUFFER;
        browser_object_follow(buffer, target, game.href);
    });
}

(I load a lightly patched jQuery into Conkeror at startup, with routines to
instantiate a jQuery object from a buffer or interactive context object.)

As for whether the page is well-formed, I woudn't want to assume that it
is, or would stay that way.  I'd like to be able to get Conkeror to produce
a document object that's resulted from it making the same effort to process
possibly badly-formed HTML that it makes for ordinary web pages, but from
my Googling around that doesn't seem to be easily possible.  I've read a
bit about document.implementation.createDocument, which I've never used
before, but it requires one to have a document object to start with, which
I wouldn't necessarily have.
_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to