Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/**
* @author Tohaomg
* @license CC BY-SA 3.0
* @source https://uk.wikipedia.org/w/index.php?title=Користувач:Tohaomg/automatic_wikimail_sender.js&oldid=30938250
*/
(function($, mw) {
if ( mw.config.get('wgCanonicalSpecialPageName')!=='Emailuser' || $('#askusername').length==0 ) {return}
var time_delay = 3000
var bar_length = 850
var users_list
var users_list_pointer = 0
$("#jump-to-nav").after('<div style="border: thin solid rgb(197, 197, 197); box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.25); border-radius: 3px; padding: 5px; position: relative;">' +
'<table>' +
'<tr><td colspan="2"><b>Заголовок листа (тема):</b>' +
'<tr><td colspan="2"><textarea id="subject" cols="75" rows="1" style="background-color:#f4f4f4;resize:none;font-size:1.5em"></textarea>' +
'<tr>' +
'<td><b>Текст листа:</b><td><b>Список користувачів:</b>' +
'<tr>' +
'<td><textarea id="letter" cols="80" rows="30" style="background-color:#f4f4f4"></textarea>' +
'<td><textarea id="list" cols="40" rows="30" style="background-color:#f4f4f4"></textarea>' +
'<tr><td id="start_button"></td>' +
'</table>' +
'' +
'<svg id="progress_bar" display="none" width="852" height="27">' +
' <rect style="fill:#eee;stroke:black;stroke-width:1px" x="0.5" y="0.5" width="850" height="26"/>' +
' <rect id="pb_progress" fill="#5a8" x="1" y="1" width="0" height="25"/>' +
' <text id="pb_text" x="10" y="18"></text>' +
'</svg>' +
'' +
'<form id="wpForm" action="' + mw.config.get('wgServer') + '/wiki/Special:Emailuser" method="post" target="_blank" enctype="application/x-www-form-urlencoded">' +
' <input name="wpSubject" id="wpSubject" type="hidden" value="">' +
' <input name="wpText" id="wpText" type="hidden" value="">' +
' <input name="wpFormIdentifier" id="wpFormIdentifier" type="hidden" value="sendEmailForm">' +
' <input name="wpEditToken" id="wpEditToken" type="hidden" value="">' +
' <input name="title" id="title" type="hidden" value="Special:Emailuser">' +
' <input name="wpTarget" id="wpTarget" type="hidden" value="">' +
' <input id="wpSubmit" type="submit" style="opacity:0">' +
'</form>' +
'</div>');
$("#start_button").append($("<button>").addClass("mw-ui-button").addClass("mw-ui-progressive").text("Почати").click(function(e)
{
function process_user()
{
if (users_list_pointer >= users_list.length)
{
document.getElementById('pb_text').textContent = "ЗРОБЛЕНО"
return
}
document.getElementById('pb_text').textContent = users_list[users_list_pointer] + " (" + (users_list_pointer+1) + "/" + users_list.length + ")"//alert(users_list[users_list_pointer])
document.getElementById('wpTarget').setAttribute('value', users_list[users_list_pointer] )
$.ajax(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php', {
type: 'POST',
data: {'action': 'query', 'meta': 'tokens', 'format': 'json'},
}).done(function(response)
{
var current_token = response.query.tokens.csrftoken
document.getElementById('wpEditToken').setAttribute('value', current_token)
setTimeout(function()
{
document.getElementById('wpForm').submit()
}, time_delay/2)
setTimeout(function()
{
users_list_pointer++
document.getElementById('pb_progress').setAttribute('width', Math.round( bar_length*users_list_pointer/users_list.length ).toString())
process_user()
}, time_delay)
})
}
document.getElementById('progress_bar').setAttribute('display', 'inline')
document.getElementById('wpSubject').setAttribute('value', document.getElementById('subject').value )
document.getElementById('wpText').setAttribute('value', document.getElementById('letter').value )
users_list = document.getElementById('list').value.replace('\r', '').split('\n')
process_user()
}))
}(jQuery, mediaWiki));