YouTube: confirm before opening Shorts
Shows a confirmation prompt whenever a Shorts page is about to open, helping curb mindless scrolling.
Code to copy
// Ask for confirmation before a Shorts page actually loads
function guardShorts() {
if (location.pathname.startsWith('/shorts/')) {
if (!confirm('Open this Short? Cancel to go back.')) {
history.length > 1 ? history.back() : (location.href = 'https://www.youtube.com/');
}
}
}
guardShorts();
window.addEventListener('yt-navigate-finish', guardShorts);
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.