MediaWiki:Common.js/Special:Contributions

From Wikinews, the free news source you can write!
Jump to navigation Jump to search

//

 1 if (location.href.substring(location.href.length - 7, location.href.length) === 'newbies' && mw.config.get('wgUserGroups').join(' ').indexOf('editor') !== -1) {
 2 mw.loader.load( '/w/index.php?title=' + 'User:Bawolff/mwapilib.js' + '&action=raw&ctype=text/javascript' );
 3 wallMartGreet = function() {
 4  if (!wallMartGreet.ok) {
 5   alert("Please reload page before using wallmart greeter again");
 6   return;
 7  }
 8  Bawolff.mwapi.getToken(function () {});
 9  var redlinks = document.getElementById('bodyContent').getElementsByClassName('new');
10  var redtalk = {}, match;
11  var newTalk = /^http:\/\/en.wikinews.org\/w\/index.php\?title=(User_talk:[^&\/]*)&action=edit&redlink=1$/;
12  count=0;
13  for (var i = 0; i < redlinks.length; i++) {
14   match = redlinks[i].href.match(newTalk);
15   if (match &&match.indexOf('%3D') === -1) {
16    if (!(match[1] in redtalk)) {
17     count++;
18     redtalk[match[1]] = true;
19    }
20   }
21  }
22 
23  var mesg = "Welcome to wall-mart greeter gadget!\n\nDo you wish to put{\{howdy}} on "+ count + " new user's talk pages (Everyone listed at [[special:contributions/newbies]] that has a non-existant talk page)?";
24 
25  if (confirm(mesg)) {
26   for (i in redtalk) {
27    if (redtalk.hasOwnProperty(i)) {
28     Bawolff.mwapi.edit({content:'<!--from WM-GREET-->\n{{howdy}}\nSincerely, ~~\~~', summary: 'Welcome to Wikinews!', page: i, minor: true, section: 'new', createonly: true});
29    }
30   }
31   wallMartGreet.ok = false;
32   alert('done');
33  }
34 }
35 wallMartGreet.ok = true; //to stop it from adding to a persons talk twice.
36 
37 $(function () {mw.util.addPortletLink('p-cactions', 'javascript:wallMartGreet();void%200;', 'Greet Newbiews', 'ca-WallMartGreeter');});
38 }
39 //