← All examples

JavaScript Ads & clutter search.google.com

Focus-on-table toggle

Adds a floating button that hides navigation and header in one click, leaving just the data table.

Code to copy

(function () {
  var btn = document.createElement('button');
  btn.textContent = 'Focus table';
  btn.style.cssText = 'position:fixed;right:14px;bottom:14px;z-index:99999;' +
    'padding:8px 12px;background:#1a73e8;color:#fff;border:0;border-radius:6px;' +
    'font:13px sans-serif;cursor:pointer;box-shadow:0 2px 6px rgba(0,0,0,.3);';
  var on = false;
  btn.addEventListener('click', function () {
    on = !on;
    var nav = document.querySelector('[role="navigation"]');
    var banner = document.querySelector('[role="banner"]');
    [nav, banner].forEach(function (el) {
      if (el) el.style.display = on ? 'none' : '';
    });
    btn.textContent = on ? 'Show all' : 'Focus table';
  });
  document.body.appendChild(btn);
})();

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. 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.

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