title: What information about a DOM element would allow JavaScript to identify it (somewhat) uniquely? (e.g. when it doesn't have `id`)
body: <p>Here's what I'm trying to do: I have a bookmarklet that is looking for elements in the current page (which can be any site) and dispatch a click event on the ones that match. I have that part working.</p>
  
  <p>In some cases though, nothing matches automatically and I want to be able to show (by hovering it) what element should be activated and then save some info about it in <code>localStorage</code>. The next time I'm using the bookmarklet on that page, I want to retrieve that info to identify the element in the DOM and then dispatch a click event.</p>
  
  <p><strong>The question is: what information should I save to be able to identify it?</strong> (in most cases, since it will always be possible to create a case where it doesn't work)</p>
  
  <p>In the best case, said-element will have an <code>id</code> value and I'm good to go. In some other cases, it won't and I'd like to see your suggestions as to what info and what method I should use to get it back.</p>
  
  <p>So far my idea is to save some of the element's properties and traverse the DOM to find elements that match everything. Not all properties will work (e.g. <code>clientWidth</code> will depend on the size of the browser) and not all types of elements will have all properties (e.g. a <code>div</code> node won't have a <code>src</code> value), which means that on one hand, I can't blindly save all properties, but on the other, I need to either choose a limited list of properties that will work for any kinds of element (at the risk of losing some useful info) or have different cases for different elements (which doesn't sound super great).</p>
  
  <p>Things I was thinking I could use:</p>
  
  <ul>
  <li><code>id</code> of course</li>
  <li><code>className</code>, <code>tagName</code> would help, though <code>className</code> is likely to not be a clear match in some cases</li>
  <li><code>innerHTML</code> should work in a lot of cases if the content is text</li>
  <li><code>src</code> should work in most cases if the content is an image</li>
  <li>the hierarchy of ancestors (but that can get messy)</li>
  <li>...?</li>
  </ul>
  
  <p>So, my question is a bit "how would you go about this?", not necessarily code.
  Thanks!</p>