User:Novem Linguae/Scripts/DetectG4G5.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:Novem Linguae/Scripts/DetectG4G5. |
// <nowiki>
/*
- Displays an alert if an article may be a CSD G4 (previous AFD) or CSD G5 (created by a sockpuppet)
- Useful for new page patrolling
- Only runs on pages that have not been marked as reviewed
*/
$(async function() {
/** returns the pagename, including the namespace name, but with spaces replaced by underscores */
function getArticleName() {
return mw.config.get('wgPageName');
}
function displayWarning(html) {
$('#contentSub').before(`<div class="DetectG4G5" style="background-color: red">${html}</div>`);
}
async function isReviewed(title) {
return false;
}
async function afdExists(title) {
return true;
}
async function isBlocked(username) {
return true;
}
async function isGloballyLocked(username) {
return true;
}
async function getPageCreator(title) {
return '';
}
// don't run when not viewing articles
let action = mw.config.get('wgAction');
if ( action != 'view' ) return;
// don't run when viewing diffs
let isDiff = mw.config.get('wgDiffNewId');
if ( isDiff ) return;
let isDeletedPage = ( ! mw.config.get('wgCurRevisionId') );
if ( isDeletedPage ) return;
// Only run in mainspace
let namespace = mw.config.get('wgNamespaceNumber');
let title = getArticleName();
if ( namespace !== 0 && title != 'User:Novem_Linguae/sandbox' ) return;
if ( isReviewed(title) ) return;
if ( afdExists(title) ) {
displayWarning('<span style="font-weight:bold">CSD G4:</span> There is an AFD page for this article. It may qualify for CSD G4.');
}
let pageCreator = getPageCreator(title);
if ( isBlocked(pageCreator) || isGloballyLocked(pageCreator) ) {
displayWarning('<span style="font-weight:bold">CSD G5:</span> The creator of this page is blocked or globally locked. This article may qualify for CSD G5.');
}
});
// </nowiki>