Number the table rows
Prepends a running number to each table row so list positions are easy to reference.
Code to copy
(function () {
function number() {
var grid = document.querySelector('[role="grid"], [role="table"], table');
if (!grid) return;
var rows = grid.querySelectorAll('[role="row"]');
var n = 0;
rows.forEach(function (r) {
if (r.querySelector('[role="columnheader"]')) return;
var first = r.querySelector('[role="cell"], [role="gridcell"]');
if (!first || first.dataset.jzNumbered) return;
n += 1;
first.dataset.jzNumbered = '1';
var tag = document.createElement('span');
tag.textContent = n + '. ';
tag.style.cssText = 'color:#9aa0a6;font-variant-numeric:tabular-nums;';
first.insertBefore(tag, first.firstChild);
});
}
number();
new MutationObserver(number).observe(document.body, { childList: true, subtree: true });
})();
How to use this example
- Copy the code with the button above.
- Install JustZix (2 minutes) and open the extension on the target page.
- Add a new rule matching that page.
- Paste the code into the rule's JavaScript panel and save — it runs on every page visit.
Rate this example
No ratings yet — be the first.