Crazy Blazin' DOM Injection Introduction
This problem is a challenge that has to do with DOM manipulation at scale and overcoming some issues that may be inherent in dealing with the DOM.

This challenge is interesting because limitations push us to think through things differently and lean on the strengths of languages different than what we usually use.
I created this challenge myself based on a real world problem I ran into myself (details can be provided if needed). If this challenge has any relation to a differently know problem, those similarities are coincidental.

This challenge will be scored based on fastest execution.
Challenge
You must render one of the challenge levels in the Chrome web browser (84.0.4147.89 for standardization purposes) (submissions will need to be JavaScript functions for timing purposes):

easy
medium
hard

Using JavaScript please complete the following:

Get each table displayed and add a class table-n to each table where n is a zero based index of order of the table on the screen. If a table is nested within a table the parent would be N and the child would be N+1 with the next table being N+2.
Get each row displayed in each table and add a class of table-n-row-r where r is a zero based index of rows in the table represented by table-n.
Get each cell displayed in each table and add a class of table-n-row-r-cell-c where c is a zero based index of cells in a row represented by table-n-row-r.

At the end of the challenge the web page should still be able to be interacted through in the browser, and a call to document.getElementsByClassName('table-n-row-r-cell-c'); should return one and only one cell from the DOM.
Any method available to you as valid as long as:

Access to one of the difficulty levels has been done through Chrome (84.0.4147.89)
The URL of the browser and the page displayed doesn't change
A call to document.getElementsByClassName('table-n-row-r-cell-c'); returns only one element

Output Examples
For this example we're using the easy level as input.
The abbreviated output in the DOM should be.
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;ie=edge&quot;&gt;
    &lt;title&gt;Code Golf Challenge&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;table class=&quot;table-0&quot;&gt;
        &lt;thead&gt;
            &lt;tr class=&quot;table-0-row-0&quot;&gt;
                &lt;th class=&quot;table-0-row-0-cell-0&quot;&gt;1&lt;/th&gt;
                ...
            &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
            &lt;tr class=&quot;table-0-row-1&quot;&gt;
                &lt;td class=&quot;table-0-row-1-cell-0&quot;&gt;11&lt;/td&gt;
                &lt;td class=&quot;table-0-row-1-cell-1&quot;&gt;12&lt;/td&gt;
                ...
            &lt;/tr&gt;
            ...
    &lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;

There are only &lt;td&gt; and &lt;th&gt; elements used as cell elements for the challenge.
As long as document.getElementsByClassName('table-n-row-r-cell-c'); returns an element with this class, we're good to go.
Qualifying Entries
All entries need to have an execution speed of under 40 seconds for at least one difficulty level to qualify.
Timing starts when your algorithm starts, but after the page has loaded completely as all elements must be available (the browser spinner has stopped spinning).
Calculate the runtime for your method by calling performance.now() before and and after your injection method, and subtracting the first from the second as in the example below.
let t0 = performance.now();
doSomething()   // &lt;---- The function you're measuring time for 
let t1 = performance.now();
let totalTime = t1 - t0;

Winner
The entry that handles the highest difficulty within 40 seconds wins. Ties are broken by execution time at that difficulty.
About 200 ms
function mark() {
  var t = 0, tp = '';
  var c = [], i = { r: 0, p: '', c: 0 };
  var elements = document.body.getElementsByTagName('*');
  var length = elements.length, index, v;
  for (index = 0; index &lt; length; ++index) {
    v = elements[index];
    switch (v.tagName) {
      case 'TH':
      case 'TD':
        v.className = i.p + i.c++;
        if (i.c == 10 &amp;&amp; i.r == 10) {
          i = c.pop();
        }
        continue;
      case 'TR':
        v.className = i.p = i.t + i.r++;
        i.c = 0;
        i.p += '-col-';
        continue;
      case 'TABLE':
        v.className = tp = 'table-' + t++;
        tp += '-row-';
        c.push(i);
        i = { t: tp, r: 0, p: '', c: 0 };
    }
  }
}

If your code runs more than 2s, you must do something wrong. I believe.