MediaWiki:Common.js: Difference between revisions
Created page with "→Any JavaScript here will be loaded for all users on every page load.: mw.hook('wikipage.content').add(function ($content) { // Only inject if the page actually has commentary blocks if (!$content.find('.commentary-block').length) return; var hidden = mw.cookie.get('commentaryHidden') === '1'; if (hidden) $('body').addClass('hide-commentary'); var $btn = $('<button>') .addClass('commentary-toggle-btn') .text(hidden ? 'Show Commentary' : 'Hide Comm..." |
No edit summary |
||
| Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
mw.hook('wikipage.content').add(function ( | mw.hook('wikipage.content').add($(function () { | ||
var $content = $('#mw-content-text'); | |||
if (!$content.find('.commentary-block').length) return; | if (!$content.find('.commentary-block').length) return; | ||
| Line 18: | Line 18: | ||
$content.prepend($btn); | $content.prepend($btn); | ||
}); | })); | ||