User:NhacNy2412/EditNotice.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// Install with:
// <code><nowiki>		{{subst:Iusc|User:NhacNy2412/EditNotice.js}}	</nowiki></code>
// or with
// <code><nowiki>		mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:NhacNy2412/EditNotice.js&action=raw&ctype=text/javascript');		</nowiki></code> 
//

mw.loader.using ('mediawiki.util').done (function() {
	if (mw.config.get('wgNamespaceNumber') != -1) {
		var page = mw.config.get('wgPageName') + '/Editnotice';
		mw.util.addPortletLink ('p-views', 'https://' + mw.config.get('wgServer') +'/w/index.php?title=' + page + '&redirect=no', 'Edit notice', 'ca-pageEditNotice', 'View edit notice');
		var get_EN = {
			action: 'query',
			prop: 'revisions',
			rvprop: 'ids',
			titles: page,
			format: 'json'
		};
		$.get( mw.config.get( 'wgScriptPath' ) + '/api.php', get_EN, function (data) {
			console.log( data );
			if (data && data.query && data.query.pages && data.query.pages["-1"]){
				$('#ca-pageEditNotice').addClass('new');
			}
		} );
	}
});