Substack: reading progress bar
Adds a thin bar at the top of the page that shows how much of the article you have already read.
Code to copy
// Reading-progress bar at the top of the page, tied to the post body
(function () {
if (document.getElementById('jz-sub-progress')) { return; }
var bar = document.createElement('div');
bar.id = 'jz-sub-progress';
bar.style.cssText = 'position:fixed;top:0;left:0;height:3px;width:0;background:#ff6719;z-index:99999;transition:width 90ms linear;';
document.documentElement.appendChild(bar);
function root() {
return document.querySelector('.body.markup, .available-content, [class*="postBody"]');
}
function update() {
var r = root(); if (!r) { bar.style.width = '0'; return; }
var rect = r.getBoundingClientRect();
var total = rect.height + window.innerHeight * 0.4;
var seen = Math.min(total, Math.max(0, window.innerHeight - rect.top));
var pct = Math.min(100, Math.max(0, (seen / total) * 100));
bar.style.width = pct + '%';
}
update();
window.addEventListener('scroll', update, { passive: true });
window.addEventListener('resize', update);
})();
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.