User:Zeven90/monobook.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
// Script from [[User:Lupin/recent2.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
 
 /*Author: Flcelloguy
 *Program: Flcelloguy's Tool (Stats.java)
 *Version 2.0; released December 07 2005
 *Capabilities: Count edits, break down by namespace, count minor edits and calculate percentage
 *Please leave this block in. 
 *Code from http://en.wikipedia.org/wiki/User:Flcelloguy/Tool
 * [[User:Flcelloguy/Tool]]
 * Permission is granted to distribute freely, provided attribution is granted.
 * Note: To copy and paste, please click edit first and then highlight all, and then copy. I'm having some formatting issues in the "view" mode. Thanks!
 */
 
 import javax.swing.JOptionPane;
 import java.io.BufferedReader;
 import java.io.FileReader;
 import java.util.StringTokenizer;
 import java.io.*;
 import java.util.*;
 //import java.util.FileReader;
 
 public class Stats
 {
         private static int numEdits = 0;
         private static int minorEdits = 0;
         private static int User = 0;
         private static int Category = 0;
         private static int Image_talk= 0;
         private static int Imagew = 0;
         private static int MediaWiki_talk = 0;
         private static int MediaWiki = 0;
         private static int Talk = 0;
         private static int Template_talk = 0;
         private static int Template = 0;
         private static int User_talk = 0;
         private static int Wikipedia_talk = 0;
         private static int Wikipedia = 0;
         private static int Mainspace = 0;
 
        public static void main (String args[]) throws IOException
        {
                JOptionPane.showMessageDialog(null, 
                        "Flcelloguy's Tool \n Designed by Flcelloguy \n Statistics for editcounters", "Welcome!", 
                        JOptionPane.INFORMATION_MESSAGE);
                JOptionPane.showMessageDialog(null, 
                        "Current status: \n Editcount only \n Coming soon: \n Breakdown by namespace" + 
                                "\n User friendly version \n Edit summary usage \n Minor edits usage \n First edit date", "Information", 
                                JOptionPane.INFORMATION_MESSAGE);
                JOptionPane.showMessageDialog(null, 
                        "Number of edits: " + editcount(), "Results",
                                JOptionPane.INFORMATION_MESSAGE);
        }
 
        public static int editcount() throws IOException
        {
                FileReader reader = new FileReader("Input.txt");
                BufferedReader in = new BufferedReader(reader);
                String inputline = "";
                StringTokenizer token;
 
                System.out.println("Computing...");
                while (inputline != null)
                {
                        inputline = in.readLine();
                        if (inputline !=null)
                                token = new StringTokenizer(inputline);
                        else
                                break;
                        for (int i = 1; i<8; i++)
                        {
                                token.nextToken();
                        }
                        String input = token.nextToken();
                        //System.out.println(input);
 
                  if (input.equals("m"))
                        {
                                minorEdits++;
                                input = token.nextToken();
                        }
 
                        if (input.equals("Wikipedia"))
                                Wikipedia_talk++;
                        else if (input.equalsIgnoreCase("User"))
                                User_talk++;
                        else if (input.equals("Template"))
                                Template_talk++;
                        else if (input.equals("MediaWiki"))
                                MediaWiki_talk++;
                        else if (input.equals("Image"))
                                Image_talk++;
                        else if (input.length()>5 && input.substring(0,5).equals("User:"))
                                User++;
                        else if (input.length()>5 && input.substring(0,5).equals("Talk:"))
                                Talk++;
                        else if (input.length()>6 && input.substring(0,6).equals("Image:"))
                                Imagew++;
                        else if (input.length()>9 && input.substring(0,9).equals("Category:"))
                                Category++;
                        else if (input.length()>9 && input.substring(0,9).equals("Template:"))
                                Template++;
                        else if (input.length()>10 && input.substring(0,10).equals("MediaWiki:"))
                                MediaWiki++;
                        else if (input.length()>10 && input.substring(0,10).equals("Wikipedia:"))
                                Wikipedia++;
                        else
                        {
                                Mainspace++;
                                //System.out.println("Mainspace added: " + input);
                        }
 
                        numEdits++;
                }
 
                //Prints out statistics
                System.out.println("-------------------");
                System.out.println("Breakdown by namespace:");
                System.out.println("User: " + User);
                System.out.println("User talk: " + User_talk);   
                System.out.println("Category: " + Category);   
                System.out.println("Image: " + Imagew);   
                System.out.println("Image talk: " + Image_talk);   
                System.out.println("MediaWiki: " + MediaWiki);   
                System.out.println("MediaWiki talk: " + MediaWiki_talk);   
                System.out.println("Template: " + Template);   
                System.out.println("Template talk: " + Template_talk);   
                System.out.println("Project: " + Wikipedia);   
                System.out.println("Project talk: " + Wikipedia_talk);   
                System.out.println("Main (articles): " + Mainspace);   
                System.out.println("Article talk: " + Talk);                  
                System.out.println("-------------------");
                System.out.println("Overall statistics: ");
                System.out.println("Total edits: " + numEdits);
                System.out.println("Minor edits: " + minorEdits);
                System.out.println("Percentage of minor edits: " + (int)(((double)minorEdits)/numEdits * 100.0) + "%  *");
                System.out.println("* - percentage is always rounded down to nearest whole number percentage.");
                System.out.println("Percent edit summary: Not available yet.");
                System.out.println("-------------------");
                return numEdits;
        }
 }