MediaWiki:Gadget-twinkleblock.js: Difference between revisions
Content deleted Content added
Amorymeltzer (talk | contribs) Repo at 387720d6: GamerGate arb case moved to Gender and sexuality |
MusikAnimal (talk | contribs) deploy #2180: soft redirect to Special:Block for multi-blocked targets |
||
(18 intermediate revisions by 5 users not shown) | |||
Line 1:
// <nowiki>
(function() {
const api = new mw.Api();
let relevantUserName, blockedUserName, blockWindow;
const menuFormattedNamespaces = $.extend({}, mw.config.get('wgFormattedNamespaces'));
menuFormattedNamespaces[0] = '(Article)';
Line 35:
Twinkle.block.field_template_options = {};
// need to be verbose about who we're blocking
// Always added, hidden later if actual user not blocked
type: 'field',
label: 'Type of action'
Line 93:
using Morebits.ip.get64 provides a modicum of relief in thise case.
*/
if (sixtyFour && sixtyFour !== mw.config.get('wgRelevantUserName')) {
type: 'field',
label: 'Convert to /64 rangeblock',
Line 111:
event: Twinkle.block.callback.change_block64,
list: [{
checked: Twinkle.getPref('defaultToBlock64'),
label: 'Block the /64 instead',
value: 'block64',
Line 125:
form.append({ type: 'submit' });
result.root = result;
Twinkle.block.fetchUserInfo(
// Toggle initial partial state depending on prior block type,
// will override the defaultToPartialBlocks pref
Line 141:
// init the controls after user and block info have been fetched
evt.initEvent('change', true, true);
if (result.block64 && result.block64.checked) {
// Calls the same change_action event once finished
result.block64.dispatchEvent(evt);
} else {
result.actiontype[0].dispatchEvent(evt);
}
});
};
Line 149 ⟶ 155:
// Store fetched user data, only relevant if switching IPv6 to a /64
Twinkle.block.fetchedData = {};
// Processes the data from
// Twinkle.block.fetchUserInfo to allow reprocessing of already-fetched data
Twinkle.block.processUserInfo = function twinkleblockProcessUserInfo(data, fn) {
// Soft redirect to Special:Block if the user is multi-blocked (#2178)
if (blockinfo && data.query.blocks.length > 1) {
// Remove submission buttons.
$(blockWindow.content).dialog('widget').find('.morebits-dialog-buttons').empty();
Morebits.Status.init(blockWindow.content.querySelector('form'));
Morebits.Status.warn(
`This target has ${data.query.blocks.length} active blocks`,
`Multiblocks is not supported by Twinkle. Use [[Special:Block/${relevantUserName}]] instead.`
);
return;
}
const userinfo = data.query.users[0];
// If an IP is blocked *and* rangeblocked, the above finds
// whichever block is more recent, not necessarily correct.
Line 165 ⟶ 182:
Twinkle.block.isRegistered = !!userinfo.userid;
if (Twinkle.block.isRegistered) {
Twinkle.block.userIsBot = !!userinfo.groupmemberships && userinfo.groupmemberships.map(
} else {
Twinkle.block.userIsBot = false;
Line 182 ⟶ 197:
// Toggle unblock link if not the user in question; always first
if (blockedUserName !== relevantUserName) {
unblockLink.hidden = true
unblockLink.nextSibling.hidden = true; // link+trailing bullet } else {
unblockLink.hidden = false
unblockLink.nextSibling.hidden = false; // link+trailing bullet }
Line 207 ⟶ 224:
Twinkle.block.fetchUserInfo = function twinkleblockFetchUserInfo(fn) {
format: 'json',
action: 'query',
Line 227 ⟶ 244:
}
api.get(query).then(
Twinkle.block.processUserInfo(data, fn);
},
Morebits.
Morebits.
});
};
Line 237 ⟶ 254:
Twinkle.block.callback.saveFieldset = function twinkleblockCallbacksaveFieldset(fieldset) {
Twinkle.block[$(fieldset).prop('name')] = {};
$(fieldset).serializeArray().forEach(
// namespaces and pages for partial blocks are overwritten
// here, but we're handling them elsewhere so that's fine
Line 245 ⟶ 262:
Twinkle.block.callback.change_block64 = function twinkleblockCallbackChangeBlock64(e) {
// Show/hide block64 button
// Single IPv6, or IPv6 range smaller than a /64
if ($block64.is(':checked')) {
relevantUserName = Morebits.ip.get64(mw.config.get('wgRelevantUserName'));
Line 257 ⟶ 274:
// No templates for ranges, but if the original user is a single IP, offer the option
// (done separately in Twinkle.block.callback.issue_template)
$form.find('[name=actiontype][value=template]').prop('disabled', originalIsRange).prop('checked', !originalIsRange);
// Refetch/reprocess user info then regenerate the main content
// Tweak titlebar text. In theory, we could save the dialog
// at initialization and then use `.setTitle` or
Line 267 ⟶ 284:
// the scriptName and requires `.display`ing, which jumps the
// window. It's just a line of text, so this is fine.
titleBar.nodeValue = titleBar.nodeValue.replace(priorName, relevantUserName);
// Tweak unblock link
unblockLink.href = unblockLink.href.replace(priorName, relevantUserName);
unblockLink.title = unblockLink.title.replace(priorName, relevantUserName);
Line 292 ⟶ 309:
Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction(e) {
const $form = $(e.target.form); // Make ifs shorter
$partial.prop('disabled', !blockBox && !templateBox);
// Add current block parameters as default preset
if (blockedUserName === relevantUserName) {
Twinkle.block.blockPresetsInfo.prior = Twinkle.block.currentBlockInfo;
Line 310 ⟶ 328:
// Arrays of objects are annoying to check
if (!blockGroup.some(
blockGroup.push(prior);
}
Line 328 ⟶ 344:
} else {
// But first remove any prior prior
blockGroup = blockGroup.filter(
}
Line 342 ⟶ 356:
if (blockBox) {
field_preset = new Morebits.
field_preset.append({
type: 'select',
Line 351 ⟶ 365:
});
field_block_options = new Morebits.
field_block_options.append({ type: 'div', name: 'currentblock', label: ' ' });
field_block_options.append({ type: 'div', name: 'hasblocklog', label: ' ' });
Line 397 ⟶ 411:
tooltip: '10 page max.'
});
type: 'select',
multiple: true,
Line 405 ⟶ 419:
tooltip: 'Block from editing these namespaces.'
});
$.each(menuFormattedNamespaces,
// Ignore -1: Special; -2: Media; and 2300-2303: Gadget (talk) and Gadget definition (talk)
if (number >= 0 && number < 830) {
Line 413 ⟶ 427:
}
{
checked: Twinkle.block.field_block_options.nocreate,
Line 510 ⟶ 524:
}
}
// grab discretionary sanctions list from en-wiki
Twinkle.block.dsinfo = Morebits.wiki.getCachedJson('Template:Ds/topics.json');
Twinkle.block.dsinfo.then((dsinfo) => {
const $select = $('[name="dstopic"]');
const $options = $.map(dsinfo, (value, key) => $('<option>').val(value.code).text(key).prop('label', key));
$select.append($options);
});
// DS selection visible in either the template field set or preset,
// joint settings saved here
type: 'select',
name: 'dstopic',
Line 519 ⟶ 542:
value: '',
tooltip: 'If selected, it will inform the template and may be added to the blocking message',
event: Twinkle.block.callback.toggle_ds_reason
};
if (templateBox) {
field_template_options = new Morebits.
field_template_options.append({
type: 'select',
Line 559 ⟶ 579:
type: 'input',
name: 'template_expiry',
label: 'Period of blocking:
value: '',
tooltip: 'The period the blocking is due for, for example 24 hours, 2 weeks, indefinite etc...'
Line 567 ⟶ 587:
type: 'input',
name: 'block_reason',
label: '"You have been blocked for ..."
tooltip: 'An optional reason, to replace the default generic reason. Only available for the generic block templates.',
value: Twinkle.block.field_template_options.block_reason
Line 610 ⟶ 630:
}
$previewlink.off('click').on('click',
Twinkle.block.callback.preview($form[0]);
});
Line 622 ⟶ 642:
}
if (field_preset) {
oldfield = $form.find('fieldset[name="field_preset"]')[0];
Line 633 ⟶ 653:
oldfield.parentNode.replaceChild(field_block_options.render(), oldfield);
$form.find('fieldset[name="field_64"]').show();
$form.find('[name=pagerestrictions]').select2({
theme: 'default select2-morebits',
width: '100%',
placeholder: 'Select pages to block user from',
Line 650 ⟶ 670:
delay: 100,
data: function(params) {
if (!title) {
return;
Line 665 ⟶ 685:
processResults: function(data) {
return {
results: data.query.allpages.map(
return {
id: title,
Line 684 ⟶ 704:
$form.find('[name=namespacerestrictions]').select2({
theme: 'default select2-morebits',
width: '100%',
matcher: Morebits.select2.matchers.wordBeginning,
Line 715 ⟶ 736:
oldfield = $form.find('fieldset[name="field_template_options"]')[0];
oldfield.parentNode.replaceChild(field_template_options.render(), oldfield);
e.target.form.root.previewer = new Morebits.wiki.
} else {
$form.find('fieldset[name="field_template_options"]').hide();
Line 724 ⟶ 745:
// false for an ip covered by a range or a smaller range within a larger range;
// true for a user, single ip block, or the exact range for a range block
Morebits.
// Range blocked
Line 736 ⟶ 757:
statusStr += ' within a' + (Morebits.ip.get64(relevantUserName) === blockedUserName ? ' /64' : '') + ' rangeblock';
// Link to the full range
statusStr += ' (' + $rangeblockloglink.html() + ')';
}
Line 743 ⟶ 764:
if (Twinkle.block.currentBlockInfo.expiry === 'infinity') {
statusStr += ' (indefinite)';
} else if (new Morebits.
statusStr += ' (expires ' + new Morebits.
}
let infoStr = 'This form will';
if (sameUser) {
infoStr += ' change that block';
Line 761 ⟶ 781:
}
Morebits.
// Default to the current block conditions on intial form generation
Line 771 ⟶ 791:
// exact range, not merely a funtional equivalent
if (Twinkle.block.hasBlockLog) {
if (!Twinkle.block.currentBlockInfo) {
if (lastBlockAction.action === 'unblock') {
$blockloglink.append(' (unblocked ' + new Morebits.
} else { // block or reblock
$blockloglink.append(' (' + lastBlockAction.params.duration + ', expired ' + new Morebits.
}
}
Morebits.
Morebits.
}
Line 802 ⟶ 822:
* disabletalk: <disable user from editing their own talk page while blocked>
* expiry: <string - expiry timestamp, can include relative times like "5 months", "2 weeks" etc>
*
* forRegisteredOnly: <show block option in the interface only if the relevant user is registered>
* label: <string - label for the option of the dropdown in the interface (keep brief)>
Line 808 ⟶ 828:
* pageParam: <set if the associated block template accepts a page parameter>
* prependReason: <string - prepends the value of 'reason' to the end of the existing reason, namely for when revoking talk page access>
* nocreate: <block account creation from the user's IP (for
* nonstandard: <template does not conform to stewardship of WikiProject User Warnings and may not accept standard parameters>
* reason: <string - block rationale, as would appear in the block log,
Line 824 ⟶ 844:
*/
Twinkle.block.blockPresetsInfo = {
expiry: '31 hours',
nocreate: true,
nonstandard: true,
Line 834 ⟶ 854:
'anonblock - school': {
expiry: '36 hours',
nocreate: true,
nonstandard: true,
Line 843 ⟶ 863:
'blocked proxy': {
expiry: '1 year',
nocreate: true,
nonstandard: true,
Line 852 ⟶ 872:
'CheckUser block': {
expiry: '1 week',
nocreate: true,
nonstandard: true,
Line 868 ⟶ 888:
},
'checkuserblock-wide': {
nocreate: true,
nonstandard: true,
Line 874 ⟶ 894:
sig: '~~~~'
},
expiry: '1 year',
nonstandard: true,
reason: '{{colocationwebhost}}',
sig: null
},
autoblock: true,
expiry: 'infinity',
Line 890 ⟶ 910:
},
'school block': {
nocreate: true,
nonstandard: true,
Line 896 ⟶ 916:
sig: '~~~~'
},
expiry: '1 month',
disabletalk: true,
Line 903 ⟶ 923:
reason: '{{spamblacklistblock}} <!-- editor only attempts to add blacklisted links, see [[Special:Log/spamblacklist]] -->'
},
reason: '{{rangeblock}}',
nocreate: true,
nonstandard: true,
sig: '~~~~'
},
expiry: '1 year',
nonstandard: true,
reason: '{{Tor}}',
sig: null
},
expiry: '1 year',
nonstandard: true,
reason: '{{webhostblock}}',
Line 936 ⟶ 956:
autoblock: true,
expiry: '31 hours',
nocreate: true,
pageParam: true,
Line 1,010 ⟶ 1,030:
nocreate: true,
reason: '{{uw-botuhblock}} <!-- Username implies a bot, hard block -->',
summary: 'You have been indefinitely blocked from editing because your username is a blatant violation of the [[WP:U|username policy]]
},
'uw-causeblock': {
Line 1,050 ⟶ 1,070:
autoblock: true,
nocreate: true,
reason: '
summary: 'You have been blocked from editing for
},
'uw-ewblock': {
Line 1,069 ⟶ 1,089:
},
'uw-ipevadeblock': {
nocreate: true,
reason: '[[WP:Blocking policy#Evasion of blocks|Block evasion]]',
Line 1,202 ⟶ 1,222:
forRegisteredOnly: true,
nocreate: true,
reason: '{{uw-
summary: 'You have been indefinitely blocked from editing because your [[WP:U|username]] appears to impersonate another established Wikipedia user'
},
Line 1,221 ⟶ 1,241:
pageParam: true,
reason: '{{uw-vaublock}} <!-- Username violation, vandalism-only account -->',
summary: 'You have been indefinitely blocked from editing because your account is being [[WP:
},
'uw-vblock': {
Line 1,237 ⟶ 1,257:
nocreate: true,
pageParam: true,
reason: '[[WP:
summary: 'You have been indefinitely blocked from editing because your account is being [[WP:
},
'zombie proxy': {
expiry: '1 month',
nocreate: true,
nonstandard: true,
Line 1,313 ⟶ 1,333:
reasonParam: true,
summary: 'You have been indefinitely [[WP:PB|partially blocked]] from certain areas of the encyclopedia'
}
};
Line 1,454 ⟶ 1,338:
Twinkle.block.transformBlockPresets = function twinkleblockTransformBlockPresets() {
// supply sensible defaults
$.each(Twinkle.block.blockPresetsInfo,
settings.summary = settings.summary || settings.reason;
settings.sig = settings.sig !== undefined ? settings.sig : 'yes';
Line 1,524 ⟶ 1,408:
{ label: 'Promotional username, hard block', value: 'uw-spamublock' },
{ label: 'Promotional username, soft block', value: 'uw-softerblock' },
{ label: 'Similar username, soft block', value: 'uw-ublock-double' },
{ label: 'Username violation, soft block', value: 'uw-ublock' },
{ label: 'Username violation, hard block', value: 'uw-uhblock' },
{ label: 'Username impersonation, hard block', value: 'uw-uhblock-double' },
{ label: 'Username represents a well-known person, soft block', value: 'uw-ublock-wellknown' },
{ label: 'Username represents a non-profit, soft block', value: 'uw-causeblock' },
Line 1,570 ⟶ 1,454:
}
];
Twinkle.block.callback.filtered_block_groups = function twinkleblockCallbackFilteredBlockGroups(group, show_template) {
return $.map(group,
switch (blockPreset.value) {
case 'uw-talkrevoked':
Line 1,595 ⟶ 1,478:
break;
case 'oversightblock':
if (!Morebits.userIsInGroup('
return;
}
Line 1,603 ⟶ 1,486:
}
let registrationRestrict;
if (blockSettings.forRegisteredOnly) {
registrationRestrict = Twinkle.block.isRegistered;
} else if (blockSettings.forUnregisteredOnly) {
registrationRestrict = !Twinkle.block.isRegistered;
} else {
registrationRestrict = true;
}
if (!(blockSettings.templateName && show_template) && registrationRestrict) {
return {
label: (show_template ? '{{' + templateName + '}}: ' : '') + blockPreset.label,
Line 1,629 ⟶ 1,521:
Twinkle.block.callback.change_preset = function twinkleblockCallbackChangePreset(e) {
if (!key) {
return;
Line 1,639 ⟶ 1,531:
Twinkle.block.callback.change_template(e);
} else {
Morebits.
}
};
Twinkle.block.callback.change_expiry = function twinkleblockCallbackChangeExpiry(e) {
if (e.target.value === 'custom') {
Morebits.
} else {
Morebits.
expiry.value = e.target.value;
}
Line 1,655 ⟶ 1,547:
Twinkle.block.seeAlsos = [];
Twinkle.block.callback.toggle_see_alsos = function twinkleblockCallbackToggleSeeAlso() {
new RegExp('( <!--|;)
);
Twinkle.block.seeAlsos = Twinkle.block.seeAlsos.filter(
if (this.checked) {
Twinkle.block.seeAlsos.push(this.value);
}
if (!Twinkle.block.seeAlsos.length) {
this.form.reason.value = reason;
} else if (reason.
this.form.reason.value = reason + ' <!-- see also ' + seeAlsoMessage + ' -->';
} else {
Line 1,679 ⟶ 1,569:
Twinkle.block.dsReason = '';
Twinkle.block.callback.toggle_ds_reason = function twinkleblockCallbackToggleDSReason() {
new RegExp(' ?\\(\\[\\[' + Twinkle.block.dsReason + '\\]\\]\\)'), ''
);
Twinkle.block.dsinfo.then((dsinfo) => {
const sanctionCode = this.selectedIndex;
const sanctionName = this.options[sanctionCode].label;
Twinkle.block.dsReason = dsinfo[sanctionName].page;
if (!this.value) {
this.form.reason.value = reason;
} else {
this.form.reason.value = reason + ' ([[' + Twinkle.block.dsReason + ']])';
}
});
};
Twinkle.block.callback.update_form = function twinkleblockCallbackUpdateForm(e, data) {
let expiry = data.expiry; // don't override original expiry if useInitialOptions is set
Line 1,705 ⟶ 1,600:
form.expiry.value = expiry;
if (form.expiry_preset.value === 'custom') {
Morebits.
} else {
Morebits.
}
}
Line 1,720 ⟶ 1,615:
}
$(form).find('[name=field_block_options]').find(':checkbox').each(
// don't override original options if useInitialOptions is set
if (data.useInitialOptions && data[el.name] === undefined) {
Line 1,726 ⟶ 1,621:
}
$(el).prop('checked', check);
});
Line 1,738 ⟶ 1,633:
// Clear and/or set any partial page or namespace restrictions
if (form.pagerestrictions) {
// Respect useInitialOptions by clearing data when switching presets
Line 1,751 ⟶ 1,646:
if (data.restrictions) {
if (data.restrictions.pages && !$pageSelect.val().length) {
// since page restrictions use an ajax source, we
// short-circuit that and just add a new option
pages.forEach(
if (!$pageSelect.find("option[value='" + $.escapeSelector(page) + "']").length) {
$pageSelect.append(newOption);
}
Line 1,772 ⟶ 1,665:
Twinkle.block.callback.change_template = function twinkleblockcallbackChangeTemplate(e) {
// Block form is not present
Line 1,796 ⟶ 1,689:
form.expiry.value = Twinkle.block.prev_template_expiry;
}
Morebits.
// Partial
Morebits.
Morebits.
} else if (templateBox) { // Only present if block && template forms both visible
Morebits.
form.blank_duration.parentNode,
!settings.indefinite && !settings.nonstandard
Line 1,807 ⟶ 1,700:
}
Morebits.
// Only particularly relevant if template form is present
Morebits.
Morebits.
// Partial block
Morebits.
form.root.previewer.closePreview();
Line 1,821 ⟶ 1,714:
Twinkle.block.callback.preview = function twinkleblockcallbackPreview(form) {
article: form.article.value,
blank_duration: form.blank_duration ? form.blank_duration.checked : false,
Line 1,839 ⟶ 1,732:
};
form.previewer.beginRender(templateText, 'User_talk:' + relevantUserName); // Force wikitext/correct username
Line 1,845 ⟶ 1,738:
Twinkle.block.callback.evaluate = function twinkleblockCallbackEvaluate(e) {
toBlock = $form.find('[name=actiontype][value=block]').is(':checked'),
toWarn = $form.find('[name=actiontype][value=template]').is(':checked'),
toPartial = $form.find('[name=actiontype][value=partial]').is(':checked')
Twinkle.block.callback.saveFieldset($form.find('[name=field_block_options]'));
Line 1,879 ⟶ 1,772:
if (toBlock) {
if (blockoptions.partial) {
if (blockoptions.disabletalk && !blockoptions.namespacerestrictions.
return alert('Partial blocks cannot prevent talk page access unless also restricting them from editing User talk space!');
}
Line 1,901 ⟶ 1,794:
}
Morebits.
Morebits.
blockoptions.action = 'block';
Line 1,938 ⟶ 1,831:
same block is still active (same status, no confirmation).
*/
format: 'json',
action: 'query',
Line 1,952 ⟶ 1,845:
query.bkusers = blockoptions.user;
}
api.get(query).then(
// As with the initial data fetch, if an IP is blocked
// *and* rangeblocked, this would only grab whichever
Line 1,963 ⟶ 1,856:
block = data.query.blocks[1];
}
if (logid !== Twinkle.block.blockLogId || !!block !== !!Twinkle.block.currentBlockInfo) {
if (block) {
message += 'New status: ';
Line 1,974 ⟶ 1,867:
}
if (logevents.params.duration) {
if (logevents.params.duration === 'infinity') {
logExpiry = 'indefinitely';
} else {
logExpiry += (expiryDate.isBefore(new Date()) ? ', expired ' : ' until ') + expiryDate.calendar();
}
} else { // no duration, action=unblock, just show timestamp
logExpiry = ' ' + new Morebits.
}
message += Morebits.string.toUpperCaseFirstChar(logevents.action) + 'ed by ' + logevents.user + logExpiry +
Line 1,989 ⟶ 1,882:
if (!confirm(message)) {
Morebits.
return;
}
Line 1,998 ⟶ 1,891:
blockoptions.tags = Twinkle.changeTags;
blockoptions.token = mw.user.tokens.get('csrfToken');
statusElement.info('Completed');
if (toWarn) {
Twinkle.block.callback.issue_template(templateoptions);
}
}));
mbApi.post();
});
} else if (toWarn) {
Morebits.
Morebits.
Twinkle.block.callback.issue_template(templateoptions);
} else {
Line 2,019 ⟶ 1,912:
// Use wgRelevantUserName to ensure the block template goes to a single IP and not to the
// "talk page" of an IP range (which does not exist)
const params = Twinkle.block.combineFormDataAndFieldTemplateOptions(
Twinkle.block.blockPresetsInfo[formData.template], Morebits.wiki.actionCompleted.redirect = userTalkPage;
Morebits.wiki.actionCompleted.notice = 'Actions complete, loading user talk page in a few seconds';
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.block.callback.main);
};
Twinkle.block.combineFormDataAndFieldTemplateOptions = function(formData, messageData, reason, disabletalk, noemail, nocreate) {
return $.extend(formData, {
messageData: messageData,
reason: reason,
disabletalk: disabletalk,
noemail: noemail,
nocreate: nocreate
});
};
Twinkle.block.callback.getBlockNoticeWikitext = function(params) {
const settings = Twinkle.block.blockPresetsInfo[params.template]; if (!settings.nonstandard) {
text += 'subst:' + params.template;
Line 2,051 ⟶ 1,956:
if (params.indefinite) {
text += '|indef=yes';
} else if (!params.blank_duration && !new Morebits.
// Block template wants a duration, not date
text += '|time=' + params.expiry;
Line 2,072 ⟶ 1,977:
if (params.partial) {
if (params.pagerestrictions.length || params.namespacerestrictions.length) {
if (array.length < 3) {
return array.join(' and ');
}
return array.join(', ') + ', and ' + last;
Line 2,082 ⟶ 1,987:
text += '|area=' + (params.indefinite ? 'certain ' : 'from certain ');
if (params.pagerestrictions.length) {
text += 'pages (' + makeSentence(params.pagerestrictions.map(
text += params.namespacerestrictions.length ? ') and certain ' : ')';
}
if (params.namespacerestrictions.length) {
// 1 => Talk, 2 => User, etc.
text += '[[Wikipedia:Namespace|namespaces]] (' + makeSentence(namespaceNames) + ')';
}
Line 2,116 ⟶ 2,017:
Twinkle.block.callback.main = function twinkleblockcallbackMain(pageobj) {
date = new Morebits.
messageData = params.messageData
params.indefinite = Morebits.string.isInfinity(params.expiry);
if (Twinkle.getPref('blankTalkpageOnIndefBlock') && params.template !== 'uw-lblock' && params.indefinite) {
Morebits.
text = date.monthHeader() + '\n';
} else {
text = pageobj.getPageText();
let dateHeaderRegexLast, dateHeaderRegexResult; while ((dateHeaderRegexLast = dateHeaderRegex.exec(text)) !== null) {
dateHeaderRegexResult = dateHeaderRegexLast;
Line 2,136 ⟶ 2,038:
// \n== is not found, then the date header must be at the very start of the page. lastIndexOf
// returns -1 in this case, so lastHeaderIndex gets set to 0 as desired.
if (text.length > 0) {
Line 2,143 ⟶ 2,045:
if (!dateHeaderRegexResult || dateHeaderRegexResult.index !== lastHeaderIndex) {
Morebits.
text += date.monthHeader() + '\n';
}
Line 2,153 ⟶ 2,055:
// build the edit summary
if (messageData.suppressArticleInSummary !== true && params.article) {
summary += ' on [[:' + params.article + ']]';
Line 2,167 ⟶ 2,069:
Twinkle.addInitCallback(Twinkle.block, 'block');
}
// </nowiki>
|