User:Jarry1250/UserContribsPatch

From Wikipedia, the free encyclopedia

Adds a tab ("User contribs") when looking at a page in namespace 2/3 (User, User talk). Useful for human posting to user talk pages especially, to check whether the editor is still active or not.

Index: Main.cs
===================================================================
--- Main.cs	(revision 4477)
+++ Main.cs	(working copy)
@@ -542,6 +542,20 @@
                 NewHistory();
                 NewWhatLinksHere();
 
+                if (listMaker.SelectedArticle().NameSpaceKey == 2 || listMaker.SelectedArticle().NameSpaceKey == 3)
+                {
+                    // User or user talk page
+                    if (!EditBoxTab.Controls.Contains(tpContribs))
+                    {
+                        EditBoxTab.Controls.Add(tpContribs);
+                    }
+                    NewUserContribs();
+                }
+                else
+                {
+                    this.EditBoxTab.Controls.Remove(this.tpContribs);
+                }
+
                 EditBoxSaveTimer.Enabled = AutoSaveEditBoxEnabled;
 
                 //if (dlg != null && dlg.AutoProtectAll)
@@ -3873,6 +3887,8 @@
                 NewHistory();
             else if (EditBoxTab.SelectedTab == tpLinks)
                 NewWhatLinksHere();
+            else if (EditBoxTab.SelectedTab == tpContribs)
+                NewUserContribs();
         }
 
         private void NewHistory()
@@ -3931,7 +3947,36 @@
             if (webBrowserLinks.Document != null && webBrowserLinks.Document.Body != null)
                 webBrowserLinks.Document.Body.InnerHtml = ProcessHTMLForDisplay(webBrowserLinks.DocumentText);
         }
+        private void NewUserContribs()
+        {
+            try
+            {
+                if (EditBoxTab.SelectedTab == tpContribs && TheArticle != null)
+                {
+                    if (webBrowserContribs.Url !=
+                        new Uri(Variables.URLIndex + "?title=Special:Contributions/" + TheArticle.NamespacelessName +
+                                "&useskin=myskin") && !string.IsNullOrEmpty(TheArticle.NamespacelessName))
+                        webBrowserContribs.Navigate(Variables.URLIndex + "?title=Special:Contributions/" +
+                                                 TheArticle.NamespacelessName + "&useskin=myskin");
+                }
+                else
+                    webBrowserContribs.Navigate("about:blank");
+            }
+            catch
+            {
+                webBrowserContribs.Navigate("about:blank");
 
+                if (webBrowserContribs.Document != null)
+                    webBrowserContribs.Document.Write("<html><body><p>Unable to load user contributions</p></body></html>");
+            }
+        }
+
+        private void webBrowserContribs_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
+        {
+            if (webBrowserContribs.Document != null && webBrowserContribs.Document.Body != null)
+                webBrowserContribs.Document.Body.InnerHtml = ProcessHTMLForDisplay(webBrowserContribs.DocumentText);
+        }
+
         private const string StartMark = "<!-- start content -->", EndMark = "<!-- end content -->";
 
         private string ProcessHTMLForDisplay(string linksHtml)
Index: Main.Designer.cs
===================================================================
--- Main.Designer.cs	(revision 4477)
+++ Main.Designer.cs	(working copy)
@@ -372,6 +372,8 @@
             this.webBrowserHistory = new System.Windows.Forms.WebBrowser();
 			this.tpLinks = new System.Windows.Forms.TabPage();
             this.webBrowserLinks = new System.Windows.Forms.WebBrowser();
+            this.tpContribs = new System.Windows.Forms.TabPage();
+            this.webBrowserContribs = new System.Windows.Forms.WebBrowser();
             this.tpEditSummary = new System.Windows.Forms.TabPage();
             this.txtReviewEditSummary = new System.Windows.Forms.TextBox();
             this.tpLogs = new System.Windows.Forms.TabPage();
@@ -456,11 +458,12 @@
             this.EditBoxTab.SuspendLayout();
             this.tpEdit.SuspendLayout();
             this.tpHistory.SuspendLayout();
-			 this.tpLinks.SuspendLayout();
+            this.tpLinks.SuspendLayout();
             this.tpEditSummary.SuspendLayout();
             this.tpLogs.SuspendLayout();
             this.tpLoggingOptions.SuspendLayout();
             this.tpTypos.SuspendLayout();
+            this.tpContribs.SuspendLayout();
             this.splitContainer1.Panel1.SuspendLayout();
             this.splitContainer1.Panel2.SuspendLayout();
             this.splitContainer1.SuspendLayout();
@@ -3666,7 +3669,7 @@
             this.webBrowserHistory.Size = new System.Drawing.Size(394, 351);
             this.webBrowserHistory.TabIndex = 0;
             this.webBrowserHistory.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowserHistory_DocumentCompleted);
-			 //
+			//
             // tpLinks
             // 
             this.tpLinks.Controls.Add(this.webBrowserLinks);
@@ -3688,7 +3691,29 @@
             this.webBrowserLinks.Size = new System.Drawing.Size(394, 351);
             this.webBrowserLinks.TabIndex = 0;
             this.webBrowserLinks.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowserLinks_DocumentCompleted);
+            //
+            // tpContribs
             // 
+            this.tpContribs.Controls.Add(this.webBrowserContribs);
+            this.tpContribs.Location = new System.Drawing.Point(4, 22);
+            this.tpContribs.Name = "tpContribs";
+            this.tpContribs.Size = new System.Drawing.Size(394, 351);
+            this.tpContribs.TabIndex = 2;
+            this.tpContribs.Text = "User contribs";
+            this.tpContribs.UseVisualStyleBackColor = true;
+            // 
+            // webBrowserContribs
+            // 
+            this.webBrowserContribs.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.webBrowserContribs.IsWebBrowserContextMenuEnabled = false;
+            this.webBrowserContribs.Location = new System.Drawing.Point(0, 0);
+            this.webBrowserContribs.MinimumSize = new System.Drawing.Size(20, 20);
+            this.webBrowserContribs.Name = "webBrowserContribs";
+            this.webBrowserContribs.ScriptErrorsSuppressed = true;
+            this.webBrowserContribs.Size = new System.Drawing.Size(394, 351);
+            this.webBrowserContribs.TabIndex = 0;
+            this.webBrowserContribs.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowserContribs_DocumentCompleted);
+            // 
             // tpEditSummary
             // 
             this.tpEditSummary.Controls.Add(this.txtReviewEditSummary);
@@ -4121,7 +4146,8 @@
             this.tpEdit.ResumeLayout(false);
             this.tpEdit.PerformLayout();
             this.tpHistory.ResumeLayout(false);
-			 this.tpLinks.ResumeLayout(false);
+            this.tpContribs.ResumeLayout(false);
+			this.tpLinks.ResumeLayout(false);
             this.tpEditSummary.ResumeLayout(false);
             this.tpEditSummary.PerformLayout();
             this.tpLogs.ResumeLayout(false);
@@ -4380,8 +4406,10 @@
         private System.Windows.Forms.ContextMenuStrip mnuHistory;
         private System.Windows.Forms.ToolStripMenuItem openInBrowserToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem refreshHistoryToolStripMenuItem;
-		 private System.Windows.Forms.TabPage tpLinks;
-		 private System.Windows.Forms.WebBrowser webBrowserLinks;
+		private System.Windows.Forms.TabPage tpLinks;
+		private System.Windows.Forms.WebBrowser webBrowserLinks;
+        private System.Windows.Forms.TabPage tpContribs;
+        private System.Windows.Forms.WebBrowser webBrowserContribs;
         private System.Windows.Forms.Button btnProtect;
         private LoggingSettings loggingSettings1;
         internal System.Windows.Forms.ToolStripSeparator toolStripSeparator25;