User:DannyS712 test/remind bot.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:DannyS712 test/remind bot. |
RemindBot_config = {
name: "[[User:DannyS712/Remind Bot.js|Remind Bot]]",
version: 1.0,
debug: true
};
mw.loader.using( 'mediawiki.util', function () {
importScript('User:DannyS712 test/get JSON.js');
importScript('User:DannyS712 test/set JSON.js');
$(document).ready( function () {
var link = mw.util.addPortletLink( 'p-cactions', null, 'Remind BOT', 'ca-BOT-reminder', 'Check reminders');
$( link ).click( function ( event ) {
event.preventDefault();
check_reminders();
} );
} );
} );
function check_reminders(){
var arr_JSONed = get_JSON( 'User:DannyS712 test/reminders.json' );
if (RemindBot_config.debug) console.log( arr_JSONed );
get_page_list();
}
function get_page_list(){
var get_pages = {
action: 'query',
list: 'categorymembers',
cmlimit: 'max',
cmtitle: 'Category:Wikipedians recieving reminders',
cmprop: 'title',
format: 'json'
};
var result = null;
var scriptUrl = mw.config.get( 'wgScriptPath' ) + '/api.php';
$.ajax({
url: scriptUrl,
type: 'get',
data: get_pages,
dataType: 'json',
async: false,
success: function(catResponse) {
console.log( catResponse );
var pages = catResponse.query.categorymembers;
var listed = [];
for (var i = 0; i < pages.length; i++) {
if ( pages[i].ns === 2 ) {
listed.push(pages[i].title + "/remind.json");
}
}
if ( links === "" ) {
alert( "There are no users recieving reminders." );
}
else {
result = data;
}
}
});
return result;
}