User:SSethi (WMF)/Sandbox/SimpleUserScriptExamples.js

/* Simple user script examples to demonstrate the use of ResourceLoader core modules: https://www.mediawiki.org/wiki/ResourceLoader/Core_modules */

// Example 1: Use of jQuery function to make article font size bigger $('body').css('font-size', '1.5em');

// Example 2: Use of `mw.config` & `mw.notify` module to send in a notification // for groups a user is a part of mw.notify(mw.config.get('wgUserGroups'));

// Example 3: Use of `mw.now` module and jQuery function to fetch the date and // display it beneath the article title $('#bodyContent').prepend(new Date(mw.now));

// Example 4: User script to calculate and display estimated reading time of an // article var words = $('#bodyContent').text.split(' ').length, avgSpeed = Math.round(words / 250); $('#firstHeading').append(" (" + avgSpeed + " min" + " read) ");