User:Festucalex/script/DYK claim.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:Festucalex/script/DYK claim. |
// Install the newest version with:
// <code><nowiki> importScript( 'User:Festucalex/script/DYK claim.js' ); // Backlink: [[User:DannyS712/DYK claim.js]] </nowiki></code>
//
// Forking from User:DannyS712/DYK claim.js
mw.loader.using( 'mediawiki.util', function () {
$(document).ready( function () {
var link = mw.util.addPortletLink ( 'p-views', '#', 'Claim', 'ca-DYK', 'Claim this DYK');
$( '#ca-DYK' ).hide();
$( link ).click( function ( event ) {
event.preventDefault();
claim();
} );
$(document).on( "mousemove", check );
} );
} );
function check(){
//$(document).off( "mousemove", check );
if ( (window.location.href.indexOf("Template:Did_you_know_nominations/") > -1) && (mw.config.get( 'wgAction' ) === 'view' || mw.config.get( 'wgAction' ) === 'edit' ) ) {
$( '#ca-DYK' ).show();
}
}
function claim(){
var get_page = {
action: 'raw',
title: mw.config.get( 'wgPageName' ),
};
$.get( mw.config.get( 'wgScriptPath' ) + '/index.php', get_page, function( got_page ) {
var new_page = got_page.replace( '<!-- REPLACE THIS LINE TO WRITE FIRST COMMENT, KEEPING THE ASTERISK * -->', '{' + '{DYK checklist\n<!--Usage instructions: If the article/nomination is compliant with the relevant guideline, put "y"; if not, state what the problem is --->\n|newness = <!---Was the article created, expanded (5x), moved to mainspace, or promoted to Good Article status within 7 days of the nomination?--->\n|length = <!---Is the article at least 1500 bytes long and not a stub?--->\n|eligibilityother = <!---Note other general eligibility problems here (for example, article previously appeared on DYK); leave blank for none--->\n|sourced = <!---Does the article contain at least one citation to a reliable source for each paragraph and direct quote?--->\n|neutral = <!---Does the article cover all major viewpoints in a straightforward manner without using promotional or overly negative language?--->\n|plagiarismfree = <!---Is the article free of material copied from other sources?--->\n|policyother = <!---Note other policy problems here (for example, article copied from another Wikipedia article without attribution); leave blank for none--->\n|hookcited = <!---Check to see if the hook fact is backed by a source. If it is, check the source (if readily available) and make sure it contains the fact and is reliable. "AGF" (assume good faith) may be entered if hook it cited to an offline source--->\n|hookinterest = <!---Is the hook reasonably interesting?--->\n|hookother = <!---Note other hook problems here (for example, hook is over 200 characters); leave blank for none--->\n|picfree = <!---If the hook has a picture, is it freely licensed? If no picture is used, put "NA"--->\n|picused = <!---Is the picture used in the article (hook image may be a crop of an article image)? If no picture is used, leave blank--->\n|picclear = <!---Is the picture easily discernible at 100px? If no picture is used, leave blank--->\n|qpq = <!---Check to make sure the nominator did a proper QPQ. If no QPQ was required (for example, user has less than five DYK credits), put "NA"--->\n|status = <!---Put "y" if no problems, "?" for minor problems, "maybe" if nomination needs work, "no" if completely ineligible, "again" to request another reviewer take a look--->\n|comments = <!---Put any other comments you may have here--->\n|sign = ~~' + '~~<!---Your signature. Generally, can be left as is--->}}');
if ( new_page === got_page ) alert('This DYK review could not be automatically claimed.');
else {
var send_claim = {
action: 'edit',
pageid: mw.config.get( 'wgArticleId' ),
text: new_page,
summary: 'DYK [[User:DannyS712/DYK claim|claimed]]!',
token: mw.user.tokens.get( 'csrfToken' )
};
$.when(
$.post( mw.config.get( 'wgScriptPath' ) + '/api.php', send_claim, function( claim_response ){ } )
).done( function() {
alert('DYK review claimed!');
location.reload();
} );
}
} );
}