Article word counter
Shows a corner badge with the number of words and characters in the main article.
Code to copy
(function () {
var article = document.querySelector('article, .post, .entry-content, main');
if (!article) return;
var text = (article.innerText || '').trim();
var words = text ? text.split(/\s+/).filter(Boolean).length : 0;
var chars = text.length;
var badge = document.createElement('div');
badge.textContent = words.toLocaleString() + ' words / ' +
chars.toLocaleString() + ' chars';
badge.style.cssText = 'position:fixed;bottom:12px;right:12px;z-index:999999;' +
'background:#1a5fb4;color:#fff;font:600 12px/1 sans-serif;' +
'padding:6px 10px;border-radius:6px;box-shadow:0 2px 6px rgba(0,0,0,.25);';
document.body.appendChild(badge);
})();
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.