跳转到内容

User:小躍/test.js:修订间差异

维基百科,自由的百科全书
删除的内容 添加的内容
小躍留言 | 贡献
修改js程式碼設置,由小躍的templatescript所驅動生成的自動摘要
小躍留言 | 贡献
換位
 
(未显示同一用户的33个中间版本)
第1行: 第1行:
//<nowiki>
//Test
//This script automates the process of finding inactive sysops.
//Warning: the script will replace the contents of the page you are currently viewing when you click the link at the top right of the page.
//Output is in the format of "[[User:Example|Example]] || [[Special:PermanentLink/1234|timestamp]] || [[Special:Log/Example|timestamp]]"
var scriptActivationLink = mw.util.addPortletLink(
'p-navigation',
'#',
'不活躍管理員',
null,
'列出不活躍管理人員',
null,
'#pt-sandbox'
);
mw.loader.using(['oojs-ui','mediawiki.util']).done( function () {
$( scriptActivationLink ).click( function () {
var doThis = confirm('想運行此腳本嗎?');
if( doThis ){
$.getJSON(
//Get userlist
mw.util.wikiScript('api'),
{
format: 'json',
action: 'query',
list: 'allusers',
augroup: 'sysop',
aulimit: 100
}
).done( function ( data ) {
try {
var users = data.query.allusers;
var userlist = [];
users.forEach(function(object){
userlist.push(object.name);
});
filterUsers(userlist);
}
catch ( e ) {
console.log( "Content request error: " + e.message );
console.log( "Content request response: " + JSON.stringify( data ) );
}
} ).fail( function () {
console.log( "While getting the userlist, there was an AJAX error." );
} );
}
} );


(function($){
function filterUsers (userlist){
var userstring = userlist.toString();
if(mw.user.options.get('gadget-Twinkle')=='1'/*小工具開啟*/||$("#p-twinkle")){
var reducedList = userstring.split(",");
}else{return;}
var tribsData;
if(/^Wikipedia:(頁面|檔案)存廢討論\/記錄\/\d+\/\d+\/\d+$/.test(mw.config.get('wgPageName'))||mw.config.get('wgPageName')=='User_talk:小躍/Sandbox/Other-Test'){
var logsData;
//Visual output onto the page you activate the script on
}else{
$("#mw-content-text").replaceWith("The following users are inactive:" + "<ul id=\"inactiveList\" style=\"list-style-type:none;list-style-image:none;\"></ul>");
return;
for (x = 0; x < reducedList.length; x++){
}
$.getJSON(
//Get contribs and log entries
var spanTag = function( color, content ) {
mw.util.wikiScript('api'),
var span = document.createElement( 'span' );
{
span.style.color = color;
format: 'json',
span.appendChild( document.createTextNode( content ) );
action: 'query',
return span;
list: 'logevents|usercontribs',
};
leprop: 'timestamp',
ledir: 'older',
leuser: reducedList[x],
lelimit: 1, //We only need the most recent log action/edit
uclimit: 1,
ucuser: reducedList[x],
ucdir: 'older',
ucprop: 'timestamp|ids'
}
).done( function ( data ) {
try {
tribsData = data.query.usercontribs;
logsData = data.query.logevents;
var activeLogs, activeTribs, active;
var tribsInfo;


if(typeof(logsData[0].timestamp) != "undefined") {
var selector = ':has(.mw-headline a:only-of-type):not(:has(+ div.NavFrame))';
activeLogs = compareDates( logsData[0].timestamp, "logs" );
var titles = $('#bodyContent').find('h2' + selector + ':not(:has(+ p + h3)), h3' + selector); // really needs to work on
}

else {
var delNode = document.createElement('strong');
activeLogs = false;
var delLink = document.createElement('a');
}
delLink.appendChild( spanTag( 'Black', '【' ) );
if( typeof(tribsData[0]) != "undefined" ) {
delLink.appendChild( spanTag( 'Blue', wgULS('关闭', '關閉') ) );
tribsInfo = (tribsData[0].revid+"|"+tribsData[0].timestamp);
delLink.appendChild( spanTag( 'Black', '】' ) );
activeTribs = compareDates( tribsInfo, "tribs" );
delNode.appendChild(delLink);
}

else {
titles.each(function(key, current) {
activeTribs = false;
var headlinehref = $(current).find('.mw-headline a').attr('href');
}
var title;
if( activeLogs === false && activeTribs === false ) {
if (headlinehref.indexOf('redlink=1') === -1) {
var user = tribsData[0].user;
title = headlinehref.slice(6);
console.log(user + " is inactive");
}
listInactiveUsers( user, tribsData, logsData );
else {
}
title = headlinehref.slice(19, -22);
}
}
catch ( e ) {
title = decodeURIComponent(title);
console.log( "Content request error: " + e.message );
var pagenotexist = $(current).find('.mw-headline a').hasClass('new');
console.log( "Content request response: " + JSON.stringify( data ) );
var section = /section=(\d+)/.exec($(current).find('.mw-editsection a:last').attr('href'))[1];
}
var node = current.getElementsByClassName('mw-headline')[0];
} ).fail(/*console.log( "While getting the userlist, there was an AJAX error." )*/);
node.appendChild( document.createTextNode(' ') );
var tmpNode = delNode.cloneNode( true );
tmpNode.firstChild.href = '#' + section;
$(tmpNode.firstChild).click(function() {
Twinkle.close.callback(title, section, pagenotexist);
return false;
});
node.appendChild( tmpNode );
});
// Keep this synchronized with {{delh}}
Twinkle.close.codes = {//wgULS('', '')
'無效': {
'ir': {
label: wgULS('请求无效','請求無效'),
action: 'keep'
},
'rep': {
label: wgULS('重复提出,无效','重複提出,無效'),
action: 'keep'
},
'commons': {
label: wgULS('应在维基共享资源提请','請在維基共享資源提出'),
action: 'keep'
},
'ne': {
label: wgULS('目标页面或档案不存在,无效','目標名稱不存在,無效'),
action: 'keep'
},
'nq': {
label: wgULS('未取得提删资格,无效','未取得提刪資格,無效'),
action: 'keep'
}
},
'保留': {
'k': {
label: '保留',
action: 'keep'
},
'sk': {
label: '快速保留',
action: 'keep'
},
'tk': {
label: wgULS('暂时保留','暫時保留'),
action: 'keep'
},
'rr': {
label: wgULS('请求理由消失','請求理由消失'),
action: 'keep'
},
'dan': {
label: wgULS('重建与被删版本不符','重建與被刪的版本不符'),
action: 'keep'
}
},
'快速刪除': {
'sd': {
label: wgULS('被管理员快速删除','被管理員快速删除'),
action: 'csd'
}
},
'轉至其他维基計劃': {
'twc': {
label: wgULS('转至维基共享资源','轉至維基共享資源'),
action: 'noop'
},
'twn': {
label: wgULS('转至维基新闻','轉至維基新聞'),
action: 'noop'
},
'tws': {
label: wgULS('转至维基文库','轉至維基文庫'),
action: 'noop'
},
'twb': {
label: wgULS('转至维基教科书','轉至維基教科書'),
action: 'noop'
},
'twq': {
label: wgULS('转至维基语录','轉至維基語錄'),
action: 'noop'
},
'twt': {
label: wgULS('转至维基词典','轉至維基詞典'),
action: 'noop'
},
'twvoy': {
label: wgULS('转至维基导游','轉至維基導遊'),
action: 'noop'
},
'two': {
label: wgULS('转至其他维基计划','轉至其他維基計劃'),
action: 'noop'
}
},
'其他': {
'c': {
label: wgULS('转交侵权','轉交侵權'),
action: 'noop'
},
'm2ifd': {
label: wgULS('转送文件存废讨论','轉送文件存廢討論'),
action: 'noop'
},
'r': {
label: '重定向',
action: 'noop'
},
'cr': {
label: wgULS('分类重定向','分類重定向'),
action: 'noop'
},
'm': {
label: wgULS('移动','移動'),
action: 'noop'
},
'merge': {
label: wgULS('并入','併入'),
action: 'noop'
},
'nc': {
label: wgULS('无共识','無共識'),
action: 'keep'
}
}
}
var updButton = new OO.ui.ButtonWidget( {
};
label: '更新不活躍管理員清單?',

id: 'upd-inactive-bttn'
Twinkle.close.callback = function twinklecloseCallback(title, section, noop) {
var Window = new Morebits.simpleWindow( 400, 150 );
Window.setTitle( wgULS("关闭存废讨论 \u00B7 ","關閉存廢討論 \u00B7 ") + title );
Window.setScriptName( "Twinkle" );
Window.addFooterLink( wgULS("Twinkle协助","Twinkle協助"), "WP:TW/DOC#close" );

var form = new Morebits.quickForm( Twinkle.close.callback.evaluate );

form.append( {
type: 'select',
label: '處理結果:',
name: 'sub_group',
event: Twinkle.close.callback.change_code
} );
form.append({
type: 'input',
name: 'csdReason',
label: '被快速刪除的理由(ex. G11):'
} );
form.append({
type: 'input',
name: 'turnotherproject',
label: '該其他維基企劃的條目名稱(可選填,ex. voy:台灣):'
} );
form.append( {
type: 'input',
name: 'remark',
label: '其他理由:'
} );

form.append( {
type: 'checkbox',
list: [
{
label: '只关闭讨论,不进行其他操作',
value: 'noop',
name: 'noop',
checked: noop
}
]
} );
} );
$("#inactiveList").after(updButton.$element.click(function(){updList();}));
}
function compareDates ( data, dataType ){
//Gets current date in yyyymmdd
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
//Set back 6 months
mm -= 6;
if (mm < 0){
mm += 12;
yyyy -= 1;
}
if(dd<10) {
dd='0'+dd;
}


if(mm<10) {
form.append( { type:'submit' } );
mm='0'+mm;
}
today = ''+yyyy+mm+dd; //This is a string


var result = form.render();
var date;
var isActive;
Window.setContent( result );
if( dataType === "logs" ){
Window.display();
date = data.slice(0,data.indexOf('T'));

date = date.replace("-","");
var sub_group = result.getElementsByTagName('select')[0]; // hack

var resultData = {
title: title,
section: parseInt(section),
noop: noop
};
$(result).data("resultData", resultData);
// worker function to create the combo box entries
var createEntries = function( contents, container ) {
$.each( contents, function( itemKey, itemProperties ) {
var key = (typeof itemKey === "string") ? itemKey : itemProperties.value;

var elem = new Morebits.quickForm.element( {
type: 'option',
label: key + ':' + itemProperties.label,
value: key,
selected: itemProperties.selected
} );
var elemRendered = container.appendChild( elem.render() );
$(elemRendered).data("messageData", itemProperties);
} );
};

$.each( Twinkle.close.codes, function( groupLabel, groupContents ) {
var optgroup = new Morebits.quickForm.element( {
type: 'optgroup',
label: groupLabel
} );
optgroup = optgroup.render();
sub_group.appendChild( optgroup );
// create the options
createEntries( groupContents, optgroup );
} );

var evt = document.createEvent( "Event" );
evt.initEvent( 'change', true, true );
result.sub_group.dispatchEvent( evt );

};
Twinkle.close.callback.change_code = function twinklecloseCallbackChangeCode(e) {
var resultData = $(e.target.form).data("resultData");
var messageData = $(e.target).find('option[value="' + e.target.value + '"]').data("messageData");
var noop = e.target.form.noop;
if (resultData.noop || messageData.action === 'noop' ||messageData.action === 'csd') {
noop.checked = true;
noop.disabled = true;
}
}
else {
else if( dataType === "tribs" ){
date = data.slice(data.indexOf('|') + 1, data.indexOf('T'));
noop.checked = false;
date = date.replace("-","");
noop.disabled = false;
}
}
if(messageData.action === 'csd'){
if (date < today){
isActive = false;
e.target.form.csdReason.parentElement.removeAttribute('hidden');
}else{
e.target.form.csdReason.parentElement.setAttribute('hidden', '');
}
}
else{

isActive = true;
switch(e.target.value){
case 'twc':case 'twn':case'tws':case 'twb':case 'twq':case 'twt':case 'two':case 'twvoy':
e.target.form.turnotherproject.parentElement.removeAttribute('hidden');
break;
default:
e.target.form.turnotherproject.parentElement.setAttribute('hidden', '');
break;
}
}
return isActive;
}


function listInactiveUsers( userName, tribsArray, logsArray ){
};
var userLink = "[[User:<a href=\"https://zh.wikipedia.org/wiki/Special:Contribs/" + userName + "\">" + userName + "</a>|" + userName + "]]";
var tribsInfo = tribsArray[0].timestamp;
tribsInfo = tribsInfo.slice(0, tribsInfo.indexOf("T"));
tribsInfo = tribsArray[0].revid + "|" + tribsInfo;
var logsInfo = logsArray[0].timestamp;
logsInfo = logsInfo.slice(0, logsInfo.indexOf("T"));
tribsInfo = "[[Special:PermanentLink/" + tribsInfo + "]]";
logsInfo = "[[Special:Log/" + userName + "|" + logsInfo + "]]";
$("#inactiveList").append( "<li>" + userLink + " || " + tribsInfo + " || " + logsInfo + "</li>" );
}


function updList() {
Twinkle.close.callback.evaluate = function twinklecloseCallbackEvaluate(e) {
var list = $("#inactiveList")[0].innerText;
var code = e.target.sub_group.value;
list = '|-\n|' + list;
var resultData = $(e.target).data('resultData');
while(list.indexOf("\n[[User:") > 0){
var messageData = $(e.target.sub_group).find('option[value="' + code + '"]').data("messageData");
list = list.substr(0,list.indexOf("\n[[User:")) + '\n|-\n|' + list.substr(list.indexOf("\n[[User:") + 1);
var noop = e.target.noop.checked;
var params = {
title: resultData.title,
code: code,
remark: e.target.remark.value,
csdreason: e.target.csdReason.value,
optitle:e.target.turnotherproject.value,
section: resultData.section,
messageData: messageData
};

Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( e.target );

Morebits.wiki.actionCompleted.notice = "操作完成";

if (noop || messageData.action === 'noop'||messageData.action === 'csd') {
Twinkle.close.callbacks.talkend( params );
}
else {
switch (messageData.action) {
case 'keep':
var wikipedia_page = new Morebits.wiki.page( params.title, wgULS('移除存废讨论模板', '移除存廢討論模板') );
wikipedia_page.setCallbackParameters( params );
wikipedia_page.load( Twinkle.close.callbacks.keep );
break;
default:
alert("Twinkle.close:未定义 " + code);
return;
}
}
};

Twinkle.close.callbacks = {
keep: function (pageobj) {
var statelem = pageobj.getStatusElement();

if (!pageobj.exists()) {
statelem.error( wgULS("页面不存在,可能已被删除", "頁面不存在,可能已被刪除") );
return;
}

var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();

var pagetitle = mw.Title.newFromText(params.title);
if (pagetitle.getNamespaceId() % 2 === 0) {
var talkpagetitle = new mw.Title(pagetitle.getMainText(), pagetitle.getNamespaceId() + 1);
var talkpage = new Morebits.wiki.page(talkpagetitle.toString(), wgULS('标记讨论页', '標記討論頁'));
var vfdkept = '{{vfd-kept|' + mw.config.get('wgPageName').split('/').slice(2).join('/') + '|' + params.messageData.label + '}}\n';
talkpage.setPrependText(vfdkept);
talkpage.setEditSummary('[[' + mw.config.get('wgPageName') + ']]:' + params.messageData.label + Twinkle.getPref('summaryAd')+' by Twinkle.Eagerclose ver.');
talkpage.setCreateOption('recreate');
talkpage.prepend();
}

var newtext = text.replace(/<noinclude>\s*\{\{([rsaiftcmv]fd)\|[^{}]*?\}\}\s*<\/noinclude>\s*/gi, '');
newtext = newtext.replace(/\{\{([rsaiftcmv]fd)\|[^{}]*?\}\}\s*/gi, '');
if (params.code !== 'tk') {
newtext = newtext.replace(/\{\{(notability|fame|mair|知名度|重要性|显著性|顯著性|知名度不足|人物重要性|重要性不足|notable|关注度|关注度不足|關注度|關注度不足|重要|重要度)\|[^{}]*?\}\}\n*/gi, '');
newtext = newtext.replace(/\{\{(substub|小小作品|cod|小小條目|小小条目)\|[^{}]*?\}\}\n*/gi, '');
}
if (newtext === text) {
statelem.warn(wgULS("未找到存废讨论模板,可能已被移除", "未找到存廢討論模板,可能已被移除"));
Twinkle.close.callbacks.talkend( params );
return;
}
var editsummary = wgULS('存废讨论关闭', '存廢討論關閉')+':[[' + mw.config.get('wgPageName') + ']]'+' by Twinkle.Eagerclose ver.';

pageobj.setPageText(newtext);
pageobj.setEditSummary(editsummary + Twinkle.getPref('summaryAd')+' by Twinkle.Eagerclose ver.');
pageobj.setCreateOption('nocreate');
pageobj.save(Twinkle.close.callbacks.keepComplete);
},
keepComplete: function (pageobj) {
var params = pageobj.getCallbackParameters();
Twinkle.close.callbacks.talkend( params );
},

talkend: function (params) {
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), wgULS('关闭讨论', '關閉討論'));
wikipedia_page.setCallbackParameters(params);
wikipedia_page.setPageSection(params.section);
wikipedia_page.load(Twinkle.close.callbacks.saveTalk);
},
saveTalk: function (pageobj) {
var statelem = pageobj.getStatusElement();
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();

if (text.indexOf('{{delh') !== -1) {
statelem.error( wgULS("讨论已被关闭", "討論已被關閉") );
return;
}

var sbegin = text.indexOf('<section begin=backlog />') !== -1;
var send = text.indexOf('<section end=backlog />') !== -1;
text = text.replace('\n<section begin=backlog />', '');
text = text.replace('\n<section end=backlog />', '');

var bar = text.split('\n----\n');
var split = bar[0].split('\n');

text = split[0] + '\n{{delh|' + params.code + '}}\n' + split.slice(1).join('\n');
text += '\n----\n: ' + params.messageData.label;
if(params.optitle){
text +='[[:'+params.optitle+']]';
}
if(params.csdreason){
text += '(' +params.csdreason+')';
}
if (params.remark) {
text += ':' + params.remark;
}
else {
text += '。';
}
text += '--~~'+'~~\n{{delf}}';

if (bar[1]) {
text += '\n----\n' + bar.slice(1).join('\n----\n');
}
if (send) {
text += '\n<section end=backlog />';
}
if (sbegin) {
// guaranteed to be at tne end?
text += '\n<section begin=backlog />';
}

pageobj.setPageText(text);
pageobj.setEditSummary('/* ' + params.title + ' */ ' + params.messageData.label + Twinkle.getPref('summaryAd')+' by Twinkle.Eagerclose ver.');
pageobj.setCreateOption('nocreate');
pageobj.save(Twinkle.close.callbacks.disableLink);
},

disableLink: function (pageobj) {
var params = pageobj.getCallbackParameters();
$('strong a[href=#' + params.section + '] span').css('color', 'grey');
}
}
$.getJSON(
mw.util.wikiScript('api'),
{
format: 'json',
action: 'query',
pageids: 6067515,
prop: 'revisions',
rvprop: 'content'
}
).done( function ( data ) {
try {
var wtext = data.query.pages[6067515].revisions[0]['*'];
wtext = wtext.substr(0, wtext.indexOf("|-")) + list + "\n"+wtext.substr(wtext.indexOf("|}"));
$.ajax( {
url: mw.util.wikiScript( 'api' ),
type: 'POST',
dataType: 'json',
data: {
format: 'json',
action: 'edit',
title: 'User:小躍/Sandbox/Inactive administrators',
text: wtext,
summary: '輔助更新清單',
token: mw.user.tokens.get( 'csrfToken' ),
}
} ).done(function() {
alert( "已更新 User:小躍/Sandbox/Inactive administrators" );
var reload = new OO.ui.ButtonWidget({ label: '重新讀取原頁面' });
$('#upd-inactive-bttn').replaceWith(reload.$element.click(function(){window.location.reload();}));
}
).fail( function ( e, data ){
console.log( e.message );
console.log( JSON.stringify( data ) );
});
}
catch(e){}
}).fail( function ( e, data ){
console.log( e.message );
console.log( JSON.stringify( data ) );
});
}
}
});

//</nowiki>
})(jQuery);

2022年2月2日 (三) 18:51的最新版本

//<nowiki>
//This script automates the process of finding inactive sysops.
//Warning: the script will replace the contents of the page you are currently viewing when you click the link at the top right of the page.
//Output is in the format of "[[User:Example|Example]] || [[Special:PermanentLink/1234|timestamp]] || [[Special:Log/Example|timestamp]]"
var scriptActivationLink = mw.util.addPortletLink(
    'p-navigation',
    '#',
    '不活躍管理員',
    null,
    '列出不活躍管理人員',
    null,
    '#pt-sandbox'
);
mw.loader.using(['oojs-ui','mediawiki.util']).done( function () {
$( scriptActivationLink ).click( function () {
	var doThis = confirm('想運行此腳本嗎?');
	if( doThis ){
		$.getJSON(
			//Get userlist
            mw.util.wikiScript('api'),
            {
                format: 'json',
                action: 'query',
                list: 'allusers',
                augroup: 'sysop',
                aulimit: 100
            }
        ).done( function ( data ) {
            try {
            	var users = data.query.allusers;
            	var userlist = [];
            	users.forEach(function(object){
            		userlist.push(object.name);
            	});
            	filterUsers(userlist);
            }
        catch ( e ) {
            console.log( "Content request error: " + e.message );
            console.log( "Content request response: " + JSON.stringify( data ) );
        }
    } ).fail( function () {
        console.log( "While getting the userlist, there was an AJAX error." );
    } );
}
} );

function filterUsers (userlist){
	var userstring = userlist.toString();
	var reducedList = userstring.split(",");
	var tribsData;
	var logsData;
	//Visual output onto the page you activate the script on
	$("#mw-content-text").replaceWith("The following users are inactive:" + "<ul id=\"inactiveList\" style=\"list-style-type:none;list-style-image:none;\"></ul>");
	for (x = 0; x < reducedList.length; x++){
		$.getJSON(
		//Get contribs and log entries
            mw.util.wikiScript('api'),
            {
                format: 'json',
                action: 'query',
                list: 'logevents|usercontribs',
                leprop: 'timestamp',
                ledir: 'older',
                leuser: reducedList[x],
                lelimit: 1, //We only need the most recent log action/edit
                uclimit: 1,
                ucuser: reducedList[x],
                ucdir: 'older',
                ucprop: 'timestamp|ids'
            }
        ).done( function ( data ) {
            try {
            	tribsData = data.query.usercontribs;
            	logsData = data.query.logevents;
            	var activeLogs, activeTribs, active;
            	var tribsInfo;

            	if(typeof(logsData[0].timestamp) != "undefined") {
            		activeLogs = compareDates( logsData[0].timestamp, "logs" );
            	}
            	else {
            		activeLogs = false;
            	}
            	if( typeof(tribsData[0]) != "undefined" ) {
            		tribsInfo = (tribsData[0].revid+"|"+tribsData[0].timestamp);
            		activeTribs = compareDates( tribsInfo, "tribs" );
            	}
            	else {
            		activeTribs = false;
            	}
            	if( activeLogs === false && activeTribs === false ) {
            		var user = tribsData[0].user;
            		console.log(user + " is inactive");
            		listInactiveUsers( user, tribsData, logsData );
            	}
            }
        catch ( e ) {
            console.log( "Content request error: " + e.message );
            console.log( "Content request response: " + JSON.stringify( data ) );
        }
    } ).fail(/*console.log( "While getting the userlist, there was an AJAX error." )*/);
	}
	var updButton = new OO.ui.ButtonWidget( {
		label: '更新不活躍管理員清單?',
		id: 'upd-inactive-bttn'
	} );
	$("#inactiveList").after(updButton.$element.click(function(){updList();}));
}
function compareDates ( data, dataType ){
	//Gets current date in yyyymmdd
	var today = new Date();
	var dd = today.getDate();
	var mm = today.getMonth() + 1; //January is 0!
	var yyyy = today.getFullYear();
	//Set back 6 months
	mm -= 6;
	if (mm < 0){
		mm += 12;
		yyyy -= 1;
	}
	
	if(dd<10) {
    	dd='0'+dd;
	} 

	if(mm<10) {
	    mm='0'+mm;
	} 
	today = ''+yyyy+mm+dd; //This is a string

	var date;
	var isActive;
	if( dataType === "logs" ){
		date = data.slice(0,data.indexOf('T'));
		date = date.replace("-","");
	}
	else if( dataType === "tribs" ){
		date = data.slice(data.indexOf('|') + 1, data.indexOf('T'));
		date = date.replace("-","");
	}
	if (date < today){
		isActive = false;
	}
	else{
		isActive = true;
	}
	return isActive;
}

function listInactiveUsers( userName, tribsArray, logsArray ){
	var userLink = "[[User:<a href=\"https://zh.wikipedia.org/wiki/Special:Contribs/" + userName + "\">" + userName + "</a>|" + userName + "]]";
	var tribsInfo = tribsArray[0].timestamp;
	tribsInfo = tribsInfo.slice(0, tribsInfo.indexOf("T"));
	tribsInfo = tribsArray[0].revid + "|" + tribsInfo;
	var logsInfo = logsArray[0].timestamp;
	logsInfo = logsInfo.slice(0, logsInfo.indexOf("T"));
	tribsInfo = "[[Special:PermanentLink/" + tribsInfo + "]]";
	logsInfo = "[[Special:Log/" + userName + "|" + logsInfo + "]]";
	$("#inactiveList").append( "<li>" + userLink + " || " + tribsInfo + " || " + logsInfo + "</li>" );
}

function updList() {
	var list = $("#inactiveList")[0].innerText;
	list = '|-\n|' + list;
	while(list.indexOf("\n[[User:") > 0){
		list = list.substr(0,list.indexOf("\n[[User:")) + '\n|-\n|' + list.substr(list.indexOf("\n[[User:") + 1);
	}
	$.getJSON(
		mw.util.wikiScript('api'),
            {
                format: 'json',
                action: 'query',
                pageids: 6067515,
                prop: 'revisions',
                rvprop: 'content'
            }
        ).done( function ( data ) {
            try {
            	var wtext = data.query.pages[6067515].revisions[0]['*'];
            	wtext = wtext.substr(0, wtext.indexOf("|-")) + list + "\n"+wtext.substr(wtext.indexOf("|}"));
            	$.ajax( {
        			url: mw.util.wikiScript( 'api' ),
			        type: 'POST',
			        dataType: 'json',
			        data: {
			            format: 'json',
			            action: 'edit',
			            title: 'User:小躍/Sandbox/Inactive administrators',
			            text: wtext,
			            summary: '輔助更新清單',
			            token: mw.user.tokens.get( 'csrfToken' ),
			        }
    			} ).done(function() {
    				alert( "已更新 User:小躍/Sandbox/Inactive administrators" );
    				var reload = new OO.ui.ButtonWidget({ label: '重新讀取原頁面' });
    				$('#upd-inactive-bttn').replaceWith(reload.$element.click(function(){window.location.reload();}));
    			}
    			).fail( function ( e, data ){
    				console.log( e.message );
    				console.log( JSON.stringify( data ) );
    			});
            }
            catch(e){}
        }).fail( function ( e, data ){
    		console.log( e.message );
    		console.log( JSON.stringify( data ) );
    });
}
});
//</nowiki>