← All examples

Action Productivity merchants.google.com

Summarize visible product statuses

Counts visible product rows by status and shows a quick summary of approved, disapproved and pending items.

Code to copy

(function () {
  var rows = document.querySelectorAll('table tbody tr, [role="row"]');
  var c = { approved: 0, disapproved: 0, pending: 0, expiring: 0, other: 0 };
  rows.forEach(function (row) {
    var t = (row.textContent || '').toLowerCase();
    if (!t.trim()) return;
    if (/disapproved|not approved/.test(t)) c.disapproved++;
    else if (/pending|under review/.test(t)) c.pending++;
    else if (/expiring|expires soon/.test(t)) c.expiring++;
    else if (/approved|active/.test(t)) c.approved++;
    else c.other++;
  });
  alert('Visible product rows\n' +
        'Approved: ' + c.approved + '\n' +
        'Disapproved: ' + c.disapproved + '\n' +
        'Pending: ' + c.pending + '\n' +
        'Expiring: ' + c.expiring + '\n' +
        'Other: ' + c.other);
})();

How to use this example

  1. Copy the code with the button above.
  2. Install JustZix (2 minutes) and open the extension on the target page.
  3. Add a new rule matching that page.
  4. Enable the action panel, add a button in the Actions tab and paste the code into it — run it with one click.

Rate this example

No ratings yet — be the first.

Does this example work?

Snippets are useless without somewhere to paste them.

JustZix takes 2 minutes to install and runs your code on every matching page. No account, no payment.

Download free See use cases