Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Commit

Permalink
Updated many things
Browse files Browse the repository at this point in the history
* Disable JIT Debugging because it removed many information at error handling.
* Fixed the widget disappearance while focusing on taskbar.
* Changed the max cookies string size from 255 to 65536.
* Added the additional logging while encountering an error.
  • Loading branch information
Serena1432 committed Sep 5, 2022
1 parent 6c9e6db commit 7c8aae3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.windows.forms jitDebugging="false" />
</configuration>
4 changes: 3 additions & 1 deletion FacebookWidget.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
18 changes: 13 additions & 5 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Form1()
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

string id, cookie, position, xOffset, yOffset;
string id, cookie, position, xOffset, yOffset, response;
int phase = 1;
bool retrievalError = false;

Expand Down Expand Up @@ -91,6 +91,7 @@ void GetInformation()
Stream data = client.OpenRead(String.IsNullOrEmpty(cookie) ? ("https://mbasic.facebook.com/" + id) : ("https://mbasic.facebook.com/" + id + "?v=timeline"));
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
response = s;
var html = new HtmlAgilityPack.HtmlDocument();
html.LoadHtml(s);
if (!String.IsNullOrEmpty(cookie))
Expand Down Expand Up @@ -138,6 +139,7 @@ void GetInformation()
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
var html = new HtmlAgilityPack.HtmlDocument();
response = s;
html.LoadHtml(s);
var title = html.DocumentNode.SelectSingleNode("//title").InnerText;
if (title.Contains("(") && title.Contains(")"))
Expand All @@ -153,7 +155,8 @@ void GetInformation()
}
catch (Exception ex)
{
if (retrievalError == false) MessageBox.Show("Cannot retrieve the user data!\nPlease check again the Facebook User ID" + (String.IsNullOrEmpty(cookie) ? ", or provide a Facebook cookie for a better retrieving" : ", or provide another cookie and try again.") + ".\nIf you have checked it but the error still occurs, you can contact the developer at GitHub.com/NozakiYuu.\n\nError information:\n" + ex.ToString(), "FacebookWidget", MessageBoxButtons.OK, MessageBoxIcon.Error);
File.WriteAllText(Application.StartupPath + "\\WidgetLog.log", "Response:\n" + response + "\nErrorInformation:\n" + ex.ToString());
if (retrievalError == false) MessageBox.Show("Cannot retrieve the user data!\nPlease check again the Facebook User ID" + (String.IsNullOrEmpty(cookie) ? ", or provide a Facebook cookie for a better retrieving" : ", or provide another cookie and try again.") + ".\nIf you have checked it but the error still occurs, you can contact the developer at GitHub.com/NozakiYuu.\n\nError information:\n" + ex.ToString() + "\n\nTo view more information, open the WidgetLog.log file in the same folder as the executable.", "FacebookWidget", MessageBoxButtons.OK, MessageBoxIcon.Error);
retrievalError = true;
label2.Text = "Cannot retrieve data!";
}
Expand Down Expand Up @@ -265,5 +268,12 @@ private void tableLayoutPanel2_Paint(object sender, PaintEventArgs e)
{

}

private void timer2_Tick(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Normal;
this.Focus();
this.BringToFront();
}
}
}
3 changes: 3 additions & 0 deletions Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,7 @@
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="timer2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>104, 17</value>
</metadata>
</root>
2 changes: 1 addition & 1 deletion IniFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public IniFile(string IniPath = null)

public string Read(string Key, string Section = null)
{
var RetVal = new StringBuilder(255);
var RetVal = new StringBuilder(65536);
GetPrivateProfileString(Section ?? EXE, Key, "", RetVal, 255, Path);
return RetVal.ToString();
}
Expand Down

0 comments on commit 7c8aae3

Please sign in to comment.