மீடியாவிக்கி:Gadget-twinklearv.js: திருத்தங்களுக்கு இடையிலான வேறுபாடு
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
"//<nowiki> (function($){ /* *********************************..."-இப்பெயரில் புதிய பக்கம் உருவாக்கப்பட்டுள்ளது |
update from enwiki |
||
வரிசை 1:
// <nowiki>
(function($) {
வரிசை 10:
****************************************
* Mode of invocation: Tab ("ARV")
* Active on:
*/
Twinkle.arv = function twinklearv() {
var username = mw.config.get('wgRelevantUserName');
if (
return;
}
var
var title = isIP ? 'Report IP to administrators' : 'Report user to administrators'; Twinkle.addPortletLink(
Twinkle.arv.callback(username, isIP); }, };
Twinkle.arv.callback = function (
var Window = new Morebits.simpleWindow(600, 500);
Window.setTitle('Advance Reporting and Vetting'); // Backronym
Window.setScriptName('Twinkle');
Window.addFooterLink('AIV guide', 'WP:GAIV');
Window.addFooterLink('UAA guide', 'WP:UAAI');
Window.addFooterLink('SPI guide', 'Wikipedia:Sockpuppet investigations/SPI/Guide to filing cases');
Window.addFooterLink('ARV prefs', 'WP:TW/PREF#arv');
Window.addFooterLink('Twinkle help', 'WP:TW/DOC#arv');
Window.addFooterLink('Give feedback', 'WT:TW');
var
var categories = form.append({
type: 'select',
name: 'category',
label: 'Select report type: ',
event: Twinkle.arv.callback.changeCategory
});
categories.append({
type: 'option',
label: 'Vandalism (WP:AIV)',
value: 'aiv'
});
categories.append({
type: 'option',
label: 'Username (WP:UAA)',
value: 'username',
disabled: mw.util.isIPAddress(uid)
});
categories.append({
type: 'option',
label: 'Sockpuppeteer (WP:SPI)',
value: 'sock'
});
categories.append({
type: 'option',
label: 'Sockpuppet (WP:SPI)',
value: 'puppet'
});
categories.append({
type: 'option',
label: 'Edit warring (WP:AN3)',
value: 'an3'
});
form.append({
type: 'div',
label: '',
style: 'color: red',
id: 'twinkle-arv-blockwarning'
});
form.append({
type: 'field',
});
form.append({ type: 'submit' });
form.append({
type: 'hidden',
value: uid
});
var result = form.render();
Window.setContent(
Window.display();
// Check if the user is blocked, update notice
var query = {
action: 'query',
list: 'blocks',
bkprop: 'range|flags',
format: 'json'
};
if (isIP) {
query.bkip = uid;
} else {
query.bkusers = uid;
}
new Morebits.wiki.api("Checking the user's block status", query, function(apiobj) {
var blocklist = apiobj.getResponse().query.blocks;
if (blocklist.length) {
var block = blocklist[0];
var message = (isIP ? 'This IP address' : 'This account') + ' is ' + (block.partial ? 'partially' : 'already') + ' blocked';
// Start and end differ, range blocked
message += block.rangestart !== block.rangeend ? ' as part of a rangeblock.' : '.';
if (block.partial) {
$('#twinkle-arv-blockwarning').css('color', 'black'); // Less severe
}
$('#twinkle-arv-blockwarning').text(message);
}
}).post();
// We must init the
var evt = document.createEvent(
evt.initEvent(
result.category.dispatchEvent(
};
வரி 96 ⟶ 130:
var value = e.target.value;
var root = e.target.form;
var old_area = Morebits.quickForm.getElements(root,
var work_area = null;
switch (
/* falls through */
work_area = new Morebits.quickForm.element(
type: 'field',
label: 'Report user for vandalism',
name: 'work_area'
}
work_area.append(
type: 'input',
name: 'page',
label: 'Primary linked page: ',
tooltip: 'Leave blank to not link to the page in the report',
value:
event: function(e) {
var value = e.target.value;
var root = e.target.form;
if (
root.badid.disabled = root.goodid.disabled = true;
} else {
வரி 124 ⟶ 158:
}
}
}
work_area.append(
type: 'input',
name: 'badid',
label: 'Revision ID for target page when vandalised: ',
tooltip: 'Leave blank for no diff link',
value:
disabled: !
event: function(e) {
var value = e.target.value;
வரி 137 ⟶ 171:
root.goodid.disabled = value === '';
}
}
work_area.append(
type: 'input',
name: 'goodid',
label: 'Last good revision ID before vandalism of target page: ',
tooltip: 'Leave blank for diff link to previous revision',
value:
disabled: !
}
work_area.append(
type: 'checkbox',
name: 'arvtype',
வரி 161 ⟶ 195:
label: 'Evidently a vandalism-only account',
value: 'vandalonly',
disabled:
},
{
label: 'Account is
value: '
disabled: mw.util.isIPAddress(root.uid.value)
},
{
label: 'Account is evidently a spambot or a
value: '
}
]
}
work_area.append(
type: 'textarea',
name: 'reason',
label: 'Comment: '
}
work_area = work_area.render();
old_area.parentNode.replaceChild(
break;
work_area = new Morebits.quickForm.element(
type: 'field',
label: 'Report username violation',
name: 'work_area'
}
work_area.append
type: 'header',
label: 'Type(s) of inappropriate username',
tooltip: 'Wikipedia does not allow usernames that are misleading, promotional, offensive or disruptive. Domain names and email addresses are likewise prohibited. These criteria apply to both usernames and signatures. Usernames that are inappropriate in another language, or that represent an inappropriate name with misspellings and substitutions, or do so indirectly or by implication, are still considered inappropriate.'
}
work_area.append(
type: 'checkbox',
name: 'arvtype',
வரி 222 ⟶ 257:
}
]
}
work_area.append(
type: 'textarea',
name: 'reason',
label: 'Comment:'
}
work_area = work_area.render();
old_area.parentNode.replaceChild(
break;
work_area = new Morebits.quickForm.element(
type: 'field',
label: 'Report suspected sockpuppet',
name: 'work_area'
}
work_area.append(
{
type: 'input',
name: 'sockmaster',
label: 'Sockpuppeteer',
tooltip: 'The username of the sockpuppeteer (sockmaster) without the User:-prefix'
}
);
work_area.append(
type: 'textarea',
label: 'Evidence:',
name: 'evidence',
tooltip: '
}
work_area.append(
type: 'checkbox',
list: [
{
label: 'Request CheckUser
name: 'checkuser',
tooltip: 'CheckUser is a tool used to obtain technical evidence related to a
},
{
label: 'Notify reported users',
name: 'notify',
tooltip: 'Notification is not mandatory. In many cases, especially of chronic sockpuppeteers, notification may be counterproductive. However, especially in less egregious cases involving users who
}
]
}
work_area = work_area.render();
old_area.parentNode.replaceChild(
break;
work_area = new Morebits.quickForm.element(
type: 'field',
label: 'Report suspected sockpuppeteer',
name: 'work_area'
}
work_area.append(
{
type: 'dyninput',
name: 'sockpuppet',
label: 'Sockpuppets',
sublabel: 'Sock: ',
tooltip: 'The username of the sockpuppet without the User:-prefix',
min: 2
}
work_area.append(
type: 'textarea',
label: 'Evidence:',
name: 'evidence',
tooltip: '
}
work_area.append(
type: 'checkbox',
list: [ {
label: 'Request CheckUser
name: 'checkuser',
tooltip: 'CheckUser is a tool used to obtain technical evidence related to a
}, {
label: 'Notify reported users',
name: 'notify',
tooltip: 'Notification is not mandatory. In many cases, especially of chronic sockpuppeteers, notification may be counterproductive. However, especially in less egregious cases involving users who
} ]
}
work_area = work_area.render();
old_area.parentNode.replaceChild(
work_area = new Morebits.quickForm.element(
type: 'field',
label: 'Report edit warring',
name: 'work_area'
}
work_area.append({
type: 'input',
name: 'page',
label: 'Page',
tooltip: 'The page being reported'
});
work_area.append({
type: 'button',
name: 'load',
label: 'Load',
event: function(e) {
var root = e.target.form;
var date = new Morebits.date().subtract(48, 'hours'); // all since 48 hours
var getAN3Entries = function(field, rvuser, titles) {
var $field = $(root).find('[name=' + field + ']');
$field.find('.entry').remove();
action: 'query',
rvprop: 'sha1|ids|timestamp|parsedcomment|comment',
rvlimit: 500, // intentionally limited
}).done(function(data) {
var pageid = data.query.pageids[0];
var page = data.query.pages[pageid];
if (!page.revisions) {
$('<span class="entry">None found</span>').appendTo($field);
for (var i = 0; i < page.revisions.length; ++i) {
var rev = page.revisions[i];
class: 'entry'
});
$input.data('
// revdel/os
if (typeof rev.commenthidden === 'string') {
comment += '(comment hidden)';
} else {
comment += '"' + rev.parsedcomment + '"';
}
comment += ' at <a href="' + mw.config.get('wgScript') + '?diff=' + rev.revid + '">' + new Morebits.date(rev.timestamp).calendar() + '</a></span>';
$
}
}
// add free form input for resolves
});
var $free_input = $('<input/>', {
name: 's_resolves_free'
var $free_label = $('<label/>', {
for: 's_resolves_free',
html: 'URL link of diff with additional discussions: '
});
$free_entry.append($free_label).append($free_input).appendTo($field);
}).fail(function() {
$('<span class="entry">API failure, reload page and try again</span>').appendTo($field);
});
};
// warnings
var uid = root.uid.value;
getAN3Entries('warnings', mw.config.get('wgUserName'), 'User talk:' + uid);
// diffs and resolves require a valid page
var
if (page) {
// diffs
getAN3Entries('diffs', uid, page);
// resolutions
var t = new mw.Title(page);
var talk_page = t.getTalkPage().getPrefixedText();
getAN3Entries('resolves', mw.config.get('wgUserName'), talk_page);
} else {
$(root).find('[name=diffs]').find('.entry').remove();
$(root).find('[name=resolves]').find('.entry').remove();
}
}
});
work_area.append({
type: 'field',
name: 'diffs',
label: 'User\'s reverts',
tooltip: 'Select the edits you believe are reverts'
});
work_area.append({
type: 'field',
name: 'warnings',
label: 'Warnings given to subject',
tooltip: 'You must have warned the subject before reporting'
});
work_area.append({
type: 'field',
name: 'resolves',
label: 'Resolution initiatives',
tooltip: 'You should have tried to resolve the issue on the talk page first'
});
work_area.append({
});
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
}
};
வரி 498 ⟶ 481:
Twinkle.arv.callback.evaluate = function(e) {
var form = e.target;
var reason =
var comment =
if (
comment = form.reason.value;
}
வரி 506 ⟶ 489:
var types;
switch (
// Report user for vandalism
வரி 512 ⟶ 495:
/* falls through */
default:
types = form.getChecked(
if
alert(
return;
}
types = types.map(
if (
// Allow links to redirects, files, and categories
reason = 'On {{No redirect|:' + form.page.value + '}}';
if (form.badid.value !== '') {
reason += ' ({{diff|' + form.page.value + '|' + form.badid.value + '|' + form.goodid.value + '|diff}})';
}
வரி 547 ⟶ 529:
}
if (
reason +=
}
if (comment !==
reason += (reason ===
}
reason = reason.trim();
if (
reason +=
}
reason +=
reason = reason.replace(/\r?\n/g,
Morebits.simpleWindow.setButtonsEnabled(
Morebits.status.init(
Morebits.wiki.actionCompleted.redirect =
Morebits.wiki.actionCompleted.notice =
var aivPage = new Morebits.wiki.page(
aivPage.setPageSection(
aivPage.setFollowRedirect(
aivPage.load(
var text = aivPage.getPageText();
var $aivLink = '<a target="_blank" href="/wiki/WP:AIV">WP:AIV</a>';
// check if user has already been reported
if (new RegExp(
aivPage.getStatusElement().error(
Morebits.status.printUserText(
return;
}
// then check for any bot reports
var tb2Page = new Morebits.wiki.page('Wikipedia:Administrator intervention against vandalism/TB2', 'Checking bot reports');
var tb2Text = tb2Page.getPageText();
var tb2statelem = tb2Page.getStatusElement();
if (new RegExp('\\{\\{\\s*(?:(?:[Ii][Pp])?[Vv]andal|[Uu]serlinks)\\s*\\|\\s*(?:1=)?\\s*' + Morebits.string.escapeRegExp(uid) + '\\s*\\}\\}').test(tb2Text)) {
if (confirm('The user ' + uid + ' has already been reported by a bot. Do you wish to make the report anyway?')) {
tb2statelem.info('Proceeded despite bot report');
} else {
tb2statelem.error('Report from a bot is already present, stopping');
Morebits.status.printUserText(reason, 'The comments you typed are provided below, in case you wish to manually post them at ' + $aivLink + ':');
return;
}
} else {
tb2statelem.info('No conflicting bot reports');
}
aivPage.getStatusElement().status('Adding new report...');
aivPage.setEditSummary('Reporting [[Special:Contributions/' + uid + '|' + uid + ']].');
aivPage.setChangeTags(Twinkle.changeTags);
aivPage.setAppendText('\n*{{' + (mw.util.isIPAddress(uid) ? 'IPvandal' : 'vandal') + '|' + (/=/.test(uid) ? '1=' : '') + uid + '}} – ' + reason);
aivPage.append();
});
});
break;
// Report inappropriate username
case 'username':
types = form.getChecked(
var hasShared = types.indexOf(
if (
types.splice(
}
if (
types = types.join(
} else {
types = [ types.slice(
}
var article = 'a';
if (
article = 'an';
}
reason =
if (
reason +=
(
}
if (
reason += Morebits.string.toUpperCaseFirstChar(comment) +
}
reason +=
reason = reason.replace(/\r?\n/g,
Morebits.simpleWindow.setButtonsEnabled(
Morebits.status.init(
Morebits.wiki.actionCompleted.redirect =
Morebits.wiki.actionCompleted.notice =
var uaaPage = new Morebits.wiki.page(
uaaPage.setFollowRedirect(
uaaPage.load(
var text = uaaPage.getPageText();
// check if user has already been reported
if (new RegExp(
uaaPage.getStatusElement().error(
var $uaaLink = '<a target="_blank" href="/wiki/WP:UAA">WP:UAA</a>';
Morebits.status.printUserText(reason, 'The comments you typed are provided below, in case you wish to manually post them under the existing report for this user at ' + $uaaLink + ':');
return;
}
uaaPage.getStatusElement().status(
uaaPage.setEditSummary(
uaaPage.
// Blank newline per [[Special:Permalink/996949310#Spacing]]; see also [[WP:LISTGAP]] and [[WP:INDENTGAP]]
uaaPage.setPageText(text + '\n' + reason + '\n*');
uaaPage.save();
}
break;
// WP:SPI
case
/* falls through */
case
var sockParameters = {
evidence: form.evidence.value.trim(),
வரி 650 ⟶ 658:
};
var puppetReport = form.category.value ===
if (puppetReport && !
} else if (!puppetReport && !form.sockpuppet[0].value.trim()) {
alert('You have not entered any sockpuppet account(s) for this sockmaster. Consider reporting this account as a sockpuppet instead.');
return;
}
sockParameters.uid = puppetReport ? form.sockmaster.value.trim() : uid;
sockParameters.sockpuppets = puppetReport ? [uid] : $.map(
return $(o).val() || null });
Morebits.simpleWindow.setButtonsEnabled(
Morebits.status.init(
Twinkle.arv.processSock(
break;
case 'an3':
var diffs = $.map(
return $(o).data('revinfo' });
if (diffs.length < 3 && !confirm(
return;
}
var warnings = $.map(
return $(o).data('revinfo' });
if (!warnings.length && !confirm(
return;
}
var resolves = $.map(
return $(o).data('revinfo' });
var free_resolves = $('input[name=s_resolves_free]').val();
var an3_next = function(free_resolves) {
if (!resolves.length && !free_resolves && !confirm(
return;
}
var an3Parameters = {
};
Morebits.simpleWindow.setButtonsEnabled(
Morebits.status.init(
Twinkle.arv.processAN3(
};
if (free_resolves) {
var query;
var
var specialDiff = /Special:Diff\/(\d+)(?:\/(\S+))?/i.exec(free_resolves);
if (specialDiff) {
oldid = specialDiff[1];
diff = specialDiff[2];
diff = specialDiff[1];
}
} else {
diff = mw.util.getParamValue('diff', free_resolves);
oldid = mw.util.getParamValue('oldid', free_resolves);
}
var title = mw.util.getParamValue('title', free_resolves);
var diffNum = /^\d+$/.test(diff); // used repeatedly
// rvdiffto in prop=revisions is deprecated, but action=compare doesn't return
// timestamps ([[phab:T247686]]) so we can't rely on it unless necessary.
// Likewise, we can't rely on a meaningful comment for diff=cur.
// Additionally, links like Special:Diff/123/next, Special:Diff/123/456, or ?diff=next&oldid=123
// would each require making use of rvdir=newer in the revisions API.
// That requires a title parameter, so we have to use compare instead of revisions.
if (oldid && (diff === 'cur' || (!title && (diff === 'next' || diffNum)))) {
query = {
action: 'compare',
fromrev: oldid,
prop: 'ids|title',
format: 'json'
};
if (diffNum) {
query.torev = diff;
} else {
query.torelative = diff;
}
} else {
query = {
action: 'query',
prop: 'revisions',
rvprop: 'ids|timestamp|comment',
format: 'json',
indexpageids: true
};
if (diff && oldid) {
if (diff === 'prev') {
query.revids = oldid;
} else {
query.titles = title;
query.rvdir = 'newer';
query.rvstartid = oldid;
if (diff === 'next' && title) {
query.rvlimit = 2;
} else if (diffNum) {
// Diffs may or may not be consecutive, no limit
query.rvendid = diff;
}
}
} else {
// diff=next|prev|cur with no oldid
// Implies title= exists otherwise it's not a valid diff link (well, it is, but to the Main Page)
if (diff && /^\D+$/.test(diff)) {
query.titles = title;
} else {
query.revids = diff || oldid;
}
}
}
new mw.Api().get(query).done(function(data) {
var page;
if (data.compare && data.compare.fromtitle === data.compare.totitle) {
page = data;
} else if (data.query) {
var pageid = data.query.pageids[0];
page = data.query.pages[pageid];
} else {
return;
}
an3_next(page);
}).fail(function(data) {
console.log(
});
} else {
வரி 726 ⟶ 811:
};
Twinkle.arv.processSock = function(
Morebits.wiki.addCheckpoint(); // prevent notification events from causing an erronous "action completed"
// notify all user accounts if requested
if (params.notify && params.sockpuppets.length > 0) {
var notifyEditSummary =
var notifyText =
// notify user's master account
var masterTalkPage = new Morebits.wiki.page(
masterTalkPage.setFollowRedirect(
masterTalkPage.setEditSummary(
masterTalkPage.
masterTalkPage.setAppendText(notifyText);
masterTalkPage.append();
var statusIndicator = new Morebits.status(
var total = params.sockpuppets.length;
var current =
// display status of notifications as they progress
var onSuccess = function(
var now = parseInt(
statusIndicator.update(
sockTalkPage.getStatusElement().unlink();
if (
statusIndicator.info(
}
};
வரி 759 ⟶ 845:
// notify each puppet account
for
var sockTalkPage = new Morebits.wiki.page(
sockTalkPage.setFollowRedirect(
sockTalkPage.setEditSummary(
sockTalkPage.
sockTalkPage.
sockTalkPage.append(onSuccess);
}
}
// prepare the SPI report
var text =
params.sockpuppets.map(
if (
text +=
}
text +=
var reportpage = 'Wikipedia:Sockpuppet investigations/' + params.uid;
Morebits.wiki.actionCompleted.redirect = reportpage;
Morebits.wiki.actionCompleted.notice =
var spiPage = new Morebits.wiki.page(
spiPage.setFollowRedirect(
spiPage.setEditSummary(
spiPage.
spiPage.setAppendText(text);
spiPage.setWatchlist(Twinkle.getPref('spiWatchReport'));
spiPage.append();
வரி 804 ⟶ 882:
};
Twinkle.arv.processAN3 = function(
// prepare the AN3 report
var minid;
for (var i = 0; i < params.diffs.length; ++i) {
if
minid = params.diffs[i].parentid;
}
}
action: 'query',
prop: 'revisions',
format: 'json',
rvprop: 'sha1|ids|timestamp|comment',
rvlimit: 100, // intentionally limited
rvstartid: minid,
rvexcludeuser: params.uid,
indexpageids: true,
titles: params.page
}).done(function(data) {
Morebits.wiki.addCheckpoint(); // prevent notification events from causing an erronous "action completed"
// In case an edit summary was revdel'd
var hasHiddenComment = function(rev) {
if (!rev.comment && typeof rev.commenthidden === 'string') {
return '(comment hidden)';
}
return '"' + rev.comment + '"';
};
var orig;
if (data.length) {
var sha1 = data[0].sha1;
for (var i = 1; i < data.length; ++i) {
if (data[i].sha1 === sha1) {
orig = data[i];
break;
வரி 837 ⟶ 923:
}
if (!orig) {
orig = data[0];
}
}
var origtext =
if (orig) {
origtext = '{{diff2|' + orig.revid + '|' + orig.timestamp + '}}
}
வரி 850 ⟶ 936:
var parentid, lastid;
for (var j = 0; j < params.diffs.length; ++j) {
var cur = params.diffs[j];
if
lastid = cur.revid;
grouped_diffs[lastid] = [];
வரி 860 ⟶ 946:
}
var difftext = $.map(grouped_diffs, function(sub
var ret =
if (sub.length >= 2) {
var last = sub[0];
var first = sub.slice(-1)[0];
var label =
ret =
}
ret += sub.reverse().map(function(v) {
return (sub.length >= 2 ? '#' : '') + '# {{diff2|' + v.revid + '|' +
}).join(
return ret;
}).reverse().join(
var warningtext = params.warnings.reverse().map(function(v) {
return '# ' + ' {{diff2|' + v.revid + '|' +
}).join(
var resolvetext = params.resolves.reverse().map(function(v) {
return '# ' + ' {{diff2|' + v.revid + '|' +
}).join(
if (params.free_resolves) {
var page = params.free_resolves;
resolvetext +=
} else if (page.revisions) {
var revCount = page.revisions.length;
var rev;
if (revCount < 3) { // diff=prev or next
rev = revCount === 1 ? page.revisions[0] : page.revisions[1];
resolvetext += '\n# ' + ' {{diff2|' + rev.revid + '|' + new Morebits.date(rev.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) on ' + page.title + '}} ' + hasHiddenComment(rev);
} else { // diff and oldid are nonconsecutive
rev = page.revisions[0];
var revLatest = page.revisions[revCount - 1];
var label = 'Consecutive edits made from ' + new Morebits.date(rev.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) to ' + new Morebits.date(revLatest.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) on ' + page.title;
resolvetext += '\n# {{diff|oldid=' + rev.revid + '|diff=' + revLatest.revid + '|label=' + label + '}}\n';
}
}
}
var comment = params.comment.replace(/~*$/g, '').trim();
if (comment) {
comment +=
}
var text =
var reportpage = 'Wikipedia:Administrators\' noticeboard/Edit warring';
Morebits.wiki.actionCompleted.redirect = reportpage;
Morebits.wiki.actionCompleted.notice =
var an3Page = new Morebits.wiki.page(
an3Page.setFollowRedirect(
an3Page.setEditSummary(
an3Page.
an3Page.setAppendText(text);
an3Page.append();
// notify user
var notifyText = '\n\n{{subst:an3-notice|1=' + mw.util.wikiUrlencode(params.uid) + '|auto=1}} ~~~~';
var talkPage = new Morebits.wiki.page(
talkPage.setFollowRedirect(
talkPage.setEditSummary('Notifying
talkPage.
talkPage.setAppendText(notifyText);
talkPage.append();
Morebits.wiki.removeCheckpoint(); // all page updates have been started
}).fail(function(data) {
console.log(
});
};
Twinkle.addInitCallback(Twinkle.arv, 'arv');
})(jQuery);
// </nowiki>
|