I've got an HTML page that is compiled dynamically from a database that I need to restyle and restructure. It looks messy, I know, but what I'm working with is this (note: no `<head>` or `<body>` tags): 

```
<p>Some paragraph</p>
<h1>Heading 1</h1>
<p>Some paragraph</p>
<p>Some paragraph</p>
<h2>Heading 2</h2>
<p>Some paragraph</p>
<p>Some paragraph</p>
<h3>Heading 3</h3>
<p>Some paragraph</p>
<p>Some paragraph</p>
...

```

I'm trying to code a javascript bookmarklet that will reformat and redivide the page into classed `<div>`'s so that I can restyle it. In other words, I need it to end up like this: 

```
<p>Some paragraph</p>
<div class="one">
 <h1>Heading 1</h1>
 <p>Some paragraph</p>
 <p>Some paragraph</p>
</div>

<div class="two">
 <h2>Heading 2</h2>
 <p>Some paragraph</p>
 <p>Some paragraph</p>
</div>

<div class="three">
 <h3>Heading 3</h3>
 <p>Some paragraph</p>
 <p>Some paragraph</p>
</div>

<div class="two">
 <h2>Heading 2</h2>
 <p>Some paragraph</p>
 <p>Some paragraph</p>
</div>

```

Please note that I can't do anything to the existing page; I have to do it through a bookmarklet or add-on.