User:Þjarkur/Draft submit button.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:Þjarkur/Draft submit button. |
/*
Ensures that a "Submit this draft" button is displayed in draftspace for new editors
*/
(function () {
if (
// Don't show for extendedconfirmed users (temporarily commented out to allow for testing)
// mw.config.get('wgUserGroups').includes('extendedconfirmed') ||
// Only show when in view mode
mw.config.get('wgAction') !== 'view' ||
// Only show in draftspace
mw.config.get('wgNamespaceNumber') !== 118 ||
// Don't show on diff pages
mw.config.get('wgDiffOldId') ||
// Don't show when viewing old versions
mw.config.get('wgRevisionId') !== mw.config.get('wgCurRevisionId') ||
// Don't show if article doesn't exist
!mw.config.get('wgCurRevisionId')
) return;
var hasDraftTemplate = 0 <= mw.config.get('wgCategories').findIndex(function (category) {
return /(AfC|Draft articles|Candidates for speedy)/.test(category)
})
if (hasDraftTemplate) return;
var url = (new mw.Uri()).extend({
action: 'edit',
section: 'new',
preload: 'Template:AFC_submission/Subst',
editintro: 'Template:AFC_submission/Subst/Editintro',
}).toString();
var draftnotice =
'<table id="" class="plainlinks ombox ombox-notice" role="presentation" style="background-color: #eaebe4;">'+
'<tbody>'+
'<tr>'+
'<td class="mbox-image"></td>'+
'<td class="mbox-text">'+
'This <a href="https://en.wikipedia.org/wiki/Wikipedia:Drafts">draft</a> is not currently submitted for review.'+
'<div class="afc-draft-submit-button" style="float:right;"> <span class="plainlinks"><a class="external text" href="'+url+'"><span class="mw-ui-button mw-ui-progressive" style="padding: 4px 6px;">Submit your draft for review!</span></a>'+
'</span>'+
'</div>'+
'</td>'+
'</tr>'+
'</tbody>'+
'</table>';
$('#mw-content-text').prepend($(draftnotice))
})()