مستخدم:AhmadSherif/copyright-vio.js
![]() | يمكن توفير توثيق لسكربت المستخدم هذا في الصفحة : مستخدم:AhmadSherif/copyright-vio. |
ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.
/* Copyright (C) 2009 AhmadSherif
*
* A script to help me with repeated copyright violation issues in Wikipedia.
* The script still in beta stage, so if you want to use it, do it on your own.
*
* THIS SCRIPT IS WRITTEN BADLY, SINCE IT COULD BE WRITTEN IN A BETTER WAY, SO PLEASE
* BEAR WITH ME UNTIL I MAKE A BETTER VERSION. --AhmadSherif 27 October 2009
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*/
var url;
var date = new Date;
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 CheckValidUrl(strUrl) {
var RegexUrl = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
return RegexUrl.test(strUrl);
}
function main() {
url = prompt("Enter the link (with 'http://' prefix)");
if (!CheckValidUrl(url)) {
return;
} else {
var query = {
'title': mw.config.get('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 = "\{\{خرق|1=" + url + "|تاريخ=\{\{نسخ:اسم_شهر\}\}_\{\{نسخ:عام\}\}\}\}";
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);
var query = {
'title': 'ويكيبيديا:مقالات خرق حقوق النشر/' + date.getUTCFullYear() + '/' + (date.getUTCMonth() + 1 < 10 ? '0' + (date.getUTCMonth() + 1) : (date.getUTCMonth() + 1)),
/*'section': 'new',*/
'action': 'submit'
};
var wikipedia_wiki = new Wikipedia.wiki('Posting the log', query, postLog);
wikipedia_wiki.get();
}
}
function postLog(self) {
var form = self.responseXML.getElementById('editform');
var text = form.wpTextbox1.value;
text = "\{\{خرق/سجل" + '|' + 'مصدر=' + url + '|' + mw.config.get('wgTitle') + "|\~\~\~|" + date.getUTCFullYear() + '-' + (date.getUTCMonth() + 1) + '-' + date.getUTCDate() + "\}\}";
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': 'new',
/*'wpSummary': '',*/
'wpTextbox1': text
};
self.post(postData);
showStatus('تم إرفاق سجل الخرق.', true);
var query = {
'action': 'query',
'prop': 'revisions',
'titles': mw.config.get('wgPageName'),
'rvlimit': 1,
'rvprop': 'user',
'rvdir': 'newer'
}
var wikipedia_api = new Wikipedia.api('Grabbing username of initial contributor', query, getPageCreator);
wikipedia_api.post();
}
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\{\{نسخ:تنبيه خرق|" + mw.config.get('wgTitle') + "\}\}--\~\~\~\~";
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(mw.config.get('wgNamespaceNumber') == 0) $(function() { mw.util.addPortletLink('p-cactions', 'javascript:main()','خرق') });