User:FR30799386/Main Page edit.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:FR30799386/Main Page edit. |
$.when(mw.loader.using(['mediawiki.util']), $.ready).then(function() {
if(mw.config.get('wgUserGroups').indexOf('sysop')==-1)
{
console.log('Required permissions were denied !');
return;
}
//intialize all configurational variables which may be needed
var d = new Date();
var month = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'];
var config = [{
name: 'tfa',
link: 'Wikipedia\:Today\'s featured article\/' + month[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear()
}, {
name: 'itn',
link: 'Template:In the news'
}, {
name: 'dyk',
link: 'Template:Did you know'
}, {
name: 'otd',
link: 'Template:On this day'
}, {
name: 'tfp',
link: 'Template:POTD protected/' + d.getFullYear() + '-' + (d.getMonth()+1) + '-' + d.getDate()
}, {
name: 'tfl',
link: 'Wikipedia:Today\'s featured list/' + d.getFullYear() + '-' + (d.getMonth()+1) + '-' + d.getDate()
}];//intialized stuff...
if (mw.config.get('wgIsMainPage')) {//when we are on the Main Page....start the music
for (var i = 0; i < config.length; i++) {
makeInterface(config[i].name, mw.util.getUrl(config[i].link, {
action: 'edit'
})+'#wpTextbox1');
if (i == config.length - 1 && (d.getDay() == 1 || d.getDay() == 4)) {//check if its Friday or Monday, if so, add the links for tfl
makeInterface(config[i].name, mw.util.getUrl(config[i].link, {
action: 'edit'
})+'#wpTextbox1');
}
}
function makeInterface(name, link) {
var text = $('#mp-' + name + '-h2').text();
$('#mp-' + name + '-h2').html(text +'<span style="float:right; font-size:85%; font-weight:normal;">[<a href="' + link + '">edit</a>]</span>');
}
}
});