User:CanonNi/Scripts/AlertAssistant.js
Appearance
< User:CanonNi | Scripts
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. |
This user script seems to have a documentation page at User:CanonNi/Scripts/AlertAssistant. |
// <nowiki>
$(function () {
if (typeof alertAssistantConfig == 'undefined') {
alertAssistantConfig = {};
}
if (typeof alertAssistantConfig.topicList == 'undefined') {
alertAssistantConfig.topicList = {
'a-a': ['Armenia, Azerbaijan, or related conflicts'],
'a-i': ['the Arab–Israeli conflict'],
ab: ['abortion'],
acu: ['complementary and alternative medicine'],
ap: [
'post-1992 politics of the United States and closely related people',
],
at: [
'the English Wikipedia article titles policy and Manual of Style',
],
b: ['the Balkans or Eastern Europe '],
blp: [
'articles about living or recently deceased people, and edits relating to the subject (living or recently deceased) of such biographical articles',
],
cc: ['climate change'],
cid: [
' discussions about infoboxes and to edits adding, deleting, collapsing, or removing verifiable information from infoboxes',
],
covid: ['COVID-19, broadly construed'],
fg: ['Falun Gong'],
gc: [
'governmental regulation of firearm ownership; the social, historical and political context of such regulation; and the people and organizations associated with these issues',
],
gg: [
'gender-related disputes or controversies or people associated with them',
],
gmo: [
'genetically modified organisms, commercially produced agricultural chemicals and the companies that produce them, broadly construed',
],
horn: [
'the Horn of Africa (defined as including Ethiopia, Somalia, Eritrea, Djibouti, and adjoining areas if involved in related disputes)',
],
ipa: ['India, Pakistan, and Afghanistan'],
irp: ['post-1978 Iranian politics'],
kurd: ['the topics of Kurds and Kurdistan, broadly construed'],
ps: ['pseudoscience and fringe science'],
'r-i': [
'the intersection of race/ethnicity and human abilities and behaviour',
],
rne: 'the results of any national or sub-national election',
sl: ['Sri Lanka'],
tt: ['The Troubles'],
};
}
if (mw.config.get('wgNamespaceNumber') === 3) {
mw.util.addPortletLink(
'p-cactions',
'#',
'CT Alert',
'pt-alert',
'Alert about contentious topics'
);
}
$('#pt-alert').click(function () {
var Window = new Morebits.simpleWindow(600, 500);
Window.setTitle('Alert about contentious topics');
Window.setScriptName('AlertAssistant');
Window.display();
var form = new Morebits.quickForm(publish);
form.append({
type: 'radio',
name: 'first',
list: [
{ label: 'First', value: 'true' },
{ label: 'Regular', value: 'false' },
],
});
var categories = form.append({
type: 'select',
name: 'topic',
label: 'Select topic:',
});
for (var key in alertAssistantConfig.topicList) {
if (alertAssistantConfig.topicList.hasOwnProperty(key)) {
categories.append({
type: 'option',
label: alertAssistantConfig.topicList[key][0],
value: key,
});
}
}
form.append({ type: 'submit' });
var result = form.render();
Window.setContent(result);
Window.display();
function publish(e) {
var form = e.target;
var topic = form.topic.value;
var first = form.first.value === 'true';
Morebits.simpleWindow.setButtonsEnabled(false);
Morebits.status.init(form);
Morebits.wiki.actionCompleted.notice = 'Alerted!';
var alertPage = new Morebits.wiki.page(
mw.config.get('wgPageName'),
'Processing'
);
alertPage.setFollowRedirect(true);
alertPage.load(function () {
var text = alertPage.getPageText();
if (first) {
text += '\n\n' + '{{subst:alert/first|' + topic + '}} ~~~~';
} else {
text +=
'\n\n' +
'== Contentious topic alert == \n' +
'{{subst:alert|' +
topic +
'}} ~~~~';
}
alertPage.setEditSummary(
'Contentious topic alert: ' +
topic +
') ([[User:CanonNi/Scripts/AlertAssistant|AA]]'
);
alertPage.setPageText(text);
alertPage.save();
alertPage.save();
});
}
});
});
// </nowiki>