MediaWiki:Rickroll.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes.
- Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
- Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
- Opera, Konqueror and Safari users can just click the Reload button.
- Chrome: press Ctrl+F5 or Shift+F5
// Rickroll prank for the "Rickrolling" page only
mw.loader.using('mediawiki.util', function () {
if (mw.config.get('wgPageName') !== 'Rickrolling') {
return;
}
const RICKROLL_URL = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
document.addEventListener('click', function (e) {
const link = e.target.closest('a[href]');
if (!link) {
return;
}
// Ignore non-left clicks or modified clicks (ctrl, shift, etc.)
if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
return;
}
const originalUrl = link.href;
// Prevent normal navigation
e.preventDefault();
// Open the Rickroll in a new tab
window.open(RICKROLL_URL, '_blank', 'noopener');
// Navigate the current tab to the original link
window.location.href = originalUrl;
}, true);
});