title: How to create a plugin for "recording" web-scrape execution steps into a file?
body: <p>I am frequently tasked with the creation of web-scraping algorithms, and the way I have been doing it is directly to the scraping code, which makes each tool page-specific.</p>
  <p>I'd like to create a plugin (preferably JavaScript) for the browser so that the user can define the scraping execution sequence dynamically (Record a script that will later be interpreted and executed for the actual scraping).</p>
  <p>The idea is the following:</p>
  <ol>
  <li>The user opens the page he wants to scrape, right clicks anywhere,
  and hits &quot;starts recording&quot;, which &quot;activates&quot; the addon and saves
  the page's URL to it's &quot;recording file&quot;.</li>
  <li>For every element the user needs to click/type/change, he
  right-clicks it, and a set of element-specific options is shown. The
  addon saves these chosen options in order.</li>
  </ol>
  <hr />
  <ul>
  <li>Buttons can be clicked.</li>
  <li>Edits can be filled with a single specific string, or loop-scraped
  with a list of strings from a file.</li>
  <li>Lists can be loop-scraped for each of the items in them or for items
  that match a list from a file.</li>
  <li>Etc...</li>
  </ul>
  <hr />
  <p>When recording is done, the user simply right-clicks anywhere and hits &quot;stop recording&quot;, and he will have a script-like file containing the needed scraping actions.</p>
  <p>After that, the actual scraping application takes over (automatically or manually started), and just reads the file that was recorded, executes the actions described and saves the resulting page.</p>
  <p>These resulting pages can later be parsed by an easier-coded page-specific algorithm.</p>
  <hr />
  <p>I know it's easier said than done, but I am pretty sure it's possible to code. I'd like some help figuring the &quot;substeps&quot;:</p>
  <ul>
  <li>&quot;How to display a new option in the browser's (+element's)
  context-menu?&quot;</li>
  <li>&quot;How to know what element was right-clicked?&quot;</li>
  <li>&quot;How to write a file from an addon?&quot;</li>
  <li>Etc...</li>
  </ul>
  <p>Although some of these questions have already been asked before, most of them are on a different context; Namely, a context in which you already know what element that was clicked, and wants to execute a function after it's clicked; Not the case here.</p>