مستخدم:Ciphers/SD-nomin.js
Documentation for this user script can be added at مستخدم:Ciphers/SD-nomin. |
ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.
var reason;
function showStatus(status, add) {
var statusDiv = document.createElement('div');
statusDiv.className = 'usermessage';
statusDiv.id = "status";
statusDiv.innerHTML = status;
if (!add) {
document.getElementById('siteSub').appendChild(statusDiv);
} else {
document.getElementById('status').innerHTML += "<br />" + status;
}
}
function main() {
reason = prompt("Enter the reason (with 'لأنها' prefix)");
var query = {
'title': wgPageName,
'action': 'submit'
};
var wikipedia_wiki = new Wikipedia.wiki('Tagging the page with the proper template', query, tagPage);
wikipedia_wiki.get();
}
function tagPage(self) {
var form = self.responseXML.getElementById('editform');
var text = form.wpTextbox1.value;
var regex = /\{\{شطب\|.*?\}\}/;
if (regex.test(text)) {
showStatus('لقد تم وسم الصفحة مسبقاً.', false);
return;
} else {
text = "\{\{شطب|" + reason + "\}\}";
var postData = {
'wpMinoredit': form.wpMinoredit.checked ? '' : undefined,
'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
/*'wpAutoSummary': form.wpAutoSummary.value,*/
'wpEditToken': form.wpEditToken.value,
'wpSection': '',
/*'wpSummary': '',*/
'wpTextbox1': text
};
self.post( postData );
showStatus('تم وسم الصفحة بقالب شطب.', false);
}
}
function getPageCreator(self) {
var xmlDoc = self.responseXML;
var user = xmlDoc.evaluate( '//rev/@user', xmlDoc, null, XPathResult.STRING_TYPE, null ).stringValue;
var query = {
'title': 'user talk:' + user,
'action': 'submit'
};
var wikipedia_wiki = new Wikipedia.wiki('Notifying the user', query, notifyUser);
wikipedia_wiki.get();
}
function notifyUser(self){
var form = self.responseXML.getElementById('editform');
var text = form.wpTextbox1.value;
text += "\n\{\{subst:Db-notice|" + wgTitle + "|header=1\}\}--\~\~\~\~";
var postData = {
'wpMinoredit': form.wpMinoredit.checked ? '' : undefined,
'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
/*'wpAutoSummary': form.wpAutoSummary.value,*/
'wpEditToken': form.wpEditToken.value,
'wpSection': '',
/*'wpSummary': '',*/
'wpTextbox1': text
};
self.post(postData);
showStatus('تم إخطار منشئ الصفحة.', true);
}
if(wgNamespaceNumber == 0) addOnloadHook(function() { mw.util.addPortletLink('p-cactions', 'javascript:main()','ترشيح للشطب') });