Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
This script seems to have a documentation page at User:DannyS712/Change status. |
// Install this version with:
// <code><nowiki> importScript( 'User:DannyS712/Change status.js' ); // Backlink: [[User:DannyS712/Change status.js]] </nowiki></code>
//
// If forking this script, please note my contributions / give me credit
$(function (){
var CS_config = {
name: '[[User:DannyS712/Change status|Change status.js]]',
version: 1.1,
debug: true
};
var CS_summary = 'Change status with ' + CS_config.name + ' (version ' + CS_config.version + ')';
var scriptUrl = mw.config.get( 'wgScriptPath' ) + '/api.php';
mw.loader.using( 'mediawiki.util', function () {
$(document).ready( function () {
if ( mw.config.get('wgNamespaceNumber') === 104 ) {
mw.util.addPortletLink ( 'p-cactions', 'javascript:void(0)', 'Change status', 'ca-change-status', 'Change status');
$('#ca-change-status').on('click', function() {
change_status();
} );
}
} );
} );
function change_status(){
var name = mw.config.get( 'wgPageName' );
var page = get_page ( name );
var this_user = mw.config.get( 'wgUserName' );
if (CS_config.debug) console.log ( page );
var status = page.replace(/(?:.|\n)*(<pagequality.*? \/>)(?:.|\n)*/, '$1');
var status_user = status.replace(/.*?user="(.*?)" \/>/, '$1');
var status_level = status.replace(/.*?level="(\d+)" user=".*\/>/, '$1');
console.log( status, status_user, status_level, this_user );
var new_status, new_page;
if (status_level === "1" || status_level === "2"){
console.log('Status is 1 or 2');
new_status = '<pagequality level="3" user="' + this_user + '" />';
new_page = page.replace(/<pagequality.*? \/>/, new_status);
CS_summary = 'Mark as proofread with ' + CS_config.name + ' (version ' + CS_config.version + ')';
} else if (status_level === "3" && status_user != this_user){
console.log('Status is 3, can be validated');
new_status = '<pagequality level="4" user="' + this_user + '" />';
new_page = page.replace(/<pagequality.*? \/>/, new_status);
CS_summary = 'Mark as validated with ' + CS_config.name + ' (version ' + CS_config.version + ')';
}
if (CS_config.debug) console.log ( new_status, new_page );
if (page === new_page) return;
set_new ( name, new_page );
}
function get_page( name ){
var page_to_get = {
action: 'query',
titles: name,
prop: 'revisions',
rvprop: 'content',
format: 'json',
formatversion: 2
};
var result = null;
$.ajax({
url: scriptUrl,
type: 'get',
data: page_to_get,
dataType: 'json',
async: false,
success: function(page) {
if (CS_config.debug) console.log( page );
result = page.query.pages["0"].revisions["0"].content;
if (CS_config.debug) console.log( result );
}
});
return result;
}
function set_new ( page, new_content ){
console.log( page, new_content );
var to_send = {
action: 'edit',
title: page,
text: new_content,
summary: CS_summary,
token: mw.user.tokens.get( 'csrfToken' )
};
console.log( to_send );
$.when(
$.post( scriptUrl, to_send, function( response ){ } )
).done( function() {
location.reload();
} );
}
});