Couple ideas off the top of my head... the first one, which would really only work on a fixed-width page, would be to store the comment's x/y position on the page (or the original text's position). But in a fluid width page, that location isn't guaranteed. Not the best idea unless you're looking for a quick fix.
The second idea, which is better than the first, would be to create a DOM query string for that text when you are saving the note. Something like this:
- Code: Select all
var elements = $("*:contains('the original highlighted string')");
That will return an array of elements that contain that string. You'd have to account for multiple results. Maybe by getting that string's parent elements and creating a big selector all the way from body down... something that might ultimately look like "body div.content div.entry p:contains('asdf')". You might still have multiple results in that last paragraph element, but once you get down to the raw text, that's the best you can do.
So you'd eventually have that string that you could store in localStorage and reuse as your selector for that particular note.
There's obviously a lot of missing links here, but that might get an idea or two rolling in your head.
.... although you can have your bookmarklet include external scripts (i.e., check for jquery already being loaded, if not yet loaded, add it to the page).