Three actions worth a toolbar slot: clean URL, CSV, PIP
The JustZix action bar is at its best when it holds the things you use every day. Here are three universal actions — useful almost everywhere, whatever the site. Each is one button and a few lines of code.
Action 1 — a clean URL
You copy a link to send, and a tail of ?utm_source=...&fbclid=... drags behind it. This action copies the address without the tracking junk. Label URL, purple:
const url = new URL(location.href);
const junk = ['fbclid', 'gclid', 'msclkid', 'igshid', 'mc_eid'];
[...url.searchParams.keys()].forEach(k => {
if (k.startsWith('utm_') || junk.includes(k)) {
url.searchParams.delete(k);
}
});
navigator.clipboard.writeText(url.toString());
JUSTZIX.log('Clean URL on the clipboard: ' + url);
Action 2 — export a table to CSV
The page shows data in a table but gives you no "download". This action dumps the first table to a CSV file. Label CSV, green:
const t = document.querySelector('table');
if (!t) { alert('No table on the page.'); }
else {
const csv = [...t.rows].map(r =>
[...r.cells].map(c =>
'"' + c.innerText.trim().replace(/"/g, '""') + '"'
).join(',')
).join('\n');
const a = document.createElement('a');
a.href = URL.createObjectURL(new Blob([csv], { type: 'text/csv' }));
a.download = 'table.csv';
a.click();
}
Action 3 — Picture-in-Picture
Pops the page video into a floating window that stays on top when you switch tabs. Label PIP, blue:
const v = document.querySelector('video');
if (!v) { alert('No video on the page.'); }
else if (document.pictureInPictureElement) {
document.exitPictureInPicture();
} else {
v.requestPictureInPicture();
}
Why actions, not rules
All three share one trait: you want to fire them at a moment you choose, not automatically. That is the definition of an action — code run by a click, not on every page load. A rule that "copies the URL on every visit" would make no sense; a "copy now" button does.
Pitfalls
- clipboard needs a gesture.
navigator.clipboard.writeTextworks because an action is a click — the browser treats it as user consent. The same code in a rule (with no click) would be blocked. - CSV takes the first table. A page with several tables? Narrow
querySelectorto the right one. - PIP only for <video>. Players that draw the image on a
<canvas>will not enter Picture-in-Picture.
See also
- Examples — these and other ready-made actions
- The BUTTON action — the action type behind these three
- window.JZ helpers — the programmatic action API
Install JustZix — and keep these three buttons within reach everywhere.
Rate this post
No ratings yet — be the first.