View difference between Paste ID: q8WRA4R8 and zQxGF0Zz
SHOW: | | - or go back to the newest paste.
1
/* Chatconnect log IP & user listing
2
* @description Display IP and usernames of [[Special:Log/chatconnect]]
3
* @author Ozuzanna
4
*/
5
if ("Special:Log/chatconnect".indexOf(mw.config.get('wgPageName')) !== -1) {
6
   $('#WikiaArticle').prepend('<textarea id="output-box" rows="10" cols="100"></textarea>');
7
   $('#WikiaArticle').prepend('<span style="color:white" id="button-filter" class="button">Filter</span>'); 
8
   $('li.mw-logline-chatconnect').each(function() {
9-
      var text = $(this).text().split('address ')[1];
9+
      var text = $(this).text().match(/((?:\d{1,3}\.){3}\d{1,3})/)[0] + ' ';
10-
	  text += $(this).children('a.mw-userlink,a.new mw-userlink').attr('href').split(':')[1]+'\n';
10+
	  text += decodeURIComponent($(this).children('a.mw-userlink,a.new mw-userlink').attr('href').split(':')[1])+'\n';
11
	  $('#output-box').append(text);
12
   });
13
14
   $('#button-filter').click(function () {
15
      var uniqueDetails = [];    
16
      var nameList = $('#output-box').val();
17
      $.each(nameList.split(/\n/), function(i, details) {
18
	  details += '\n';
19
         if ($.inArray(details, uniqueDetails) === -1) 
20
	        uniqueDetails.push(details);
21
      });     
22-
      $('#output-box').val(uniqueDetails);	   
22+
      $('#output-box').val(uniqueDetails.join('\n').trim());	   
23
   });
24
}