Google: collapse knowledge panel to a button
Hides the knowledge panel by default and adds a small button to expand it when needed.
Code to copy
// Collapse the right knowledge panel into a small toggle strip
const ID = 'jz-gsr-kp-toggle';
function setup() {
const rhs = document.getElementById('rhs');
if (!rhs || document.getElementById(ID)) { return; }
rhs.style.display = 'none';
const btn = document.createElement('button');
btn.id = ID;
btn.textContent = 'Show knowledge panel';
btn.style.cssText = 'margin:8px 0;padding:6px 12px;cursor:pointer;'
+ 'border:1px solid #dadce0;border-radius:18px;background:#fff';
btn.addEventListener('click', function () {
const on = rhs.style.display === 'none';
rhs.style.display = on ? '' : 'none';
btn.textContent = on ? 'Hide knowledge panel' : 'Show knowledge panel';
});
const col = document.getElementById('center_col') || rhs.parentElement;
col.insertBefore(btn, col.firstChild);
}
setup();
const obs = new MutationObserver(setup);
obs.observe(document.documentElement, { 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.