Wikipedia: jump to a random link with r
The r key on Wikipedia jumps to a random article linked within the current text.
Code to copy
document.addEventListener('keydown', function (e) {
if (e.target.matches('input, textarea, [contenteditable]')) { return; }
if (e.key !== 'r') { return; }
var links = document.querySelectorAll('#mw-content-text p a[href^="/wiki/"]');
if (links.length) {
var pick = links[Math.floor(Math.random() * links.length)];
location.href = pick.href;
}
});
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.