Пример #1
0
        public static async Task GetEditor(EditorPackage package)
        {
            if (package.Intent == EditorIntent.MultiQuote)
            {
                if (string.IsNullOrEmpty(Loc.Editor.MultiQuoteTemporaryContent))
                {
                    Loc.Editor.MultiQuoteTemporaryContent = "";
                }
                Loc.Editor.MultiQuoteTemporaryContent += await FetchMessageContent(package);

                Loc.Editor.MultiQuoteTemporaryContent += Environment.NewLine;
            }
            else
            {
                Debug.WriteLine("Fetching Form");
                var editor = await Fetch(package);

                Debug.WriteLine("Updating UI with new Editor");

                await ThreadUI.Invoke(() =>
                {
                    Loc.Editor.CurrentEditor = editor;
                });
            }
        }
Пример #2
0
        public static async Task GetTopics(SubCategory subcat)
        {
            Debug.WriteLine($"Fetching topics from {subcat.Name}");
            var topics = await FetchTopics(subcat);

            Debug.WriteLine("Updating UI with topics from cat");
            await ThreadUI.Invoke(() =>
            {
                Loc.SubCategory.Topics = topics;
            });
        }
Пример #3
0
        public static async Task GetEditor(string url)
        {
            Debug.WriteLine("Fetching Form");
            var editor = await Fetch(url);

            Debug.WriteLine("Updating UI with new Editor");

            await ThreadUI.Invoke(() =>
            {
                Loc.Editor.CurrentEditor = editor;
            });
        }
Пример #4
0
        public static async Task GetPrivateChats()
        {
            Debug.WriteLine("Fetching Messages");
            var msgs = await Fetch();

            Debug.WriteLine("Updating UI with new Messages list");
            await ThreadUI.Invoke(() =>
            {
                Loc.Main.PrivateChats = msgs;
                if (msgs != null)
                {
                    Loc.Main.PrivateChatsGrouped = msgs.GroupBy(x => x.ThreadLastPostDate.ToString("Y"));
                }
            });
        }
Пример #5
0
        static async Task GetAvatar(Account account)
        {
            var html = await HttpClientHelper.Get(HFRUrl.ProfilePageUrl, Loc.Main.AccountManager.CurrentAccount.CookieContainer);

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);

            string[] userAvatarFileArray = htmlDoc.DocumentNode.Descendants("img").Where(x => x.GetAttributeValue("src", "").Contains("http://forum-images.hardware.fr/images/mesdiscussions-")).Select(y => y.GetAttributeValue("src", "")).ToArray();

            if (userAvatarFileArray.Length != 0)
            {
                await ThreadUI.Invoke(() => account.AvatarId = userAvatarFileArray[0].Split('/')[4].Replace(".jpg", "").Replace("mesdiscussions-", ""));
            }
        }
Пример #6
0
        public static async Task GetAvatar(Account account)
        {
            var html = await HttpClientHelper.Get(HFRUrl.ProfilePageUrl, Loc.Main.AccountManager.CurrentAccount.CookieContainer);

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);

            var avatarSrc = htmlDoc.DocumentNode.Descendants("img").FirstOrDefault(x => x.GetAttributeValue("src", "").Contains("http://forum-images.hardware.fr/images/mesdiscussions-")).GetAttributeValue("src", "");

            if (!string.IsNullOrEmpty(avatarSrc))
            {
                await ThreadUI.Invoke(() => account.AvatarId = avatarSrc.Split('/')[4].Replace("mesdiscussions-", ""));
            }
        }
Пример #7
0
        public static async Task GetCats()
        {
            Debug.WriteLine("Fetching Categories");
            var cats = await Fetch();

            Debug.WriteLine("Updating UI with new Drapeaux list");
            await ThreadUI.Invoke(() =>
            {
                Loc.SubCategory.Categories = cats;
                if (cats != null)
                {
                    Loc.SubCategory.CategoriesGrouped = cats.GroupBy(x => x.CategoryName);
                }
            });
        }
Пример #8
0
        public static async Task GetDraps(FollowedTopicType topicType)
        {
            Debug.WriteLine("Fetching Drapeaux");
            var draps = await Fetch(topicType);

            Debug.WriteLine("Updating UI with new Drapeaux list");
            await ThreadUI.Invoke(() =>
            {
                Loc.Main.Drapeaux = draps;
                if (draps != null)
                {
                    Loc.Main.DrapsGrouped = draps.GroupBy(x => x.TopicCatName);
                }
            });
        }
Пример #9
0
        public static async Task Fetch(Topic currentTopic)
        {
            await ThreadUI.Invoke(() =>
            {
                Loc.Topic.IsTopicLoading = true;
            });

            var html = await HttpClientHelper.Get(currentTopic.TopicDrapURI);

            if (string.IsNullOrEmpty(html))
            {
                return;
            }

            await ThreadUI.Invoke(() =>
            {
                Loc.Topic.CurrentTopic.Html = html;
            });

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);

            var postNodes =
                htmlDoc.DocumentNode.Descendants("table")
                .Where(x => x.GetAttributeValue("class", "") == "messagetable")
                .ToArray();

            if (postNodes == null || !postNodes.Any())
            {
                return;
            }

            string TempHTMLMessagesList = "";
            string TempHTMLMessage      = "";
            string TempHTMLTopic        = "";

            string BodyTemplate    = "";
            string MessageTemplate = "";

            // This is absolutely quick and dirty code :o
            Assembly asm = typeof(App).GetTypeInfo().Assembly;

            using (Stream stream = asm.GetManifestResourceStream(HFRRessources.Tpl_Topic))
                using (StreamReader reader = new StreamReader(stream))
                {
                    BodyTemplate = reader.ReadToEnd();
                }

            using (Stream stream = asm.GetManifestResourceStream(HFRRessources.Tpl_Message))
                using (StreamReader reader = new StreamReader(stream))
                {
                    MessageTemplate = reader.ReadToEnd();
                }

            var i = 0;

            foreach (var postNode in postNodes)
            {
                TempHTMLMessage = MessageTemplate;

                // Id de la réponse
                var reponseId =
                    postNode.Descendants("a")
                    .FirstOrDefault(x => x.GetAttributeValue("href", "").StartsWith("#t"))
                    .GetAttributeValue("href", "")
                    .Replace("#t", "");

                // Pseudo
                var pseudo = postNode.Descendants("b").FirstOrDefault(x => x.GetAttributeValue("class", "") == "s2").InnerText.CleanFromWeb();

                // Mood
                var mood = postNode.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "MoodStatus")?.InnerText.CleanFromWeb();

                // Img
                var avatarUri     = "ms-appx-web:///Assets/HTML/UI/rsz_no_avatar.png";
                var avatarClass   = "no_avatar";
                var divAvatarNode = postNode.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("class", "") == "avatar_center");
                if (divAvatarNode != null && divAvatarNode.ChildNodes.Any())
                {
                    var imgAvatarNode = divAvatarNode.FirstChild;
                    var uri           = imgAvatarNode.GetAttributeValue("src", "");
                    if (!string.IsNullOrEmpty(uri))
                    {
                        avatarUri   = uri;
                        avatarClass = "";
                    }
                }

                // Date
                var date = postNode.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("class", "") == "toolbar").InnerText.CleanFromWeb();
                date = date.Replace("Posté le ", "");

                // Content
                var content      = postNode.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("id", "").Contains("para")).InnerHtml;
                int lastPostText = content.IndexOf("<div style=\"clear: both;\"> </div>", StringComparison.Ordinal);
                if (lastPostText == -1)
                {
                    lastPostText = content.Length;
                }

                content = content.Substring(0, lastPostText);
                content = content.CleanFromWeb();

                TempHTMLMessage = TempHTMLMessage.Replace("%%ID%%", i.ToString());
                TempHTMLMessage = TempHTMLMessage.Replace("%%POSTID%%", reponseId);

                if (pseudo == "Modération")
                {
                    TempHTMLMessage = TempHTMLMessage.Replace("%%moderation%%", "moderation");
                }
                else
                {
                    TempHTMLMessage = TempHTMLMessage.Replace("%%moderation%%", "");
                }

                TempHTMLMessage = TempHTMLMessage.Replace("%%no_avatar_class%%", avatarClass);

                if (Loc.Settings.SquareAvatarStylePreferred)
                {
                    TempHTMLMessage = TempHTMLMessage.Replace("%%round_avatar_class%%", "");
                }
                else
                {
                    TempHTMLMessage = TempHTMLMessage.Replace("%%round_avatar_class%%", "round");
                }

                TempHTMLMessage = TempHTMLMessage.Replace("%%AUTEUR_AVATAR%%", avatarUri);
                TempHTMLMessage = TempHTMLMessage.Replace("%%AUTEUR_PSEUDO%%", pseudo);
                TempHTMLMessage = TempHTMLMessage.Replace("%%MESSAGE_DATE%%", date);

                TempHTMLMessage = TempHTMLMessage.Replace("%%MESSAGE_CONTENT%%", content);

                TempHTMLMessagesList += TempHTMLMessage;
                i++;
            }

            // Get URL of the new post form
            var url = htmlDoc.DocumentNode.Descendants("form").FirstOrDefault(x => x.GetAttributeValue("id", "") == "repondre_form").GetAttributeValue("action", "");

            currentTopic.TopicNewPostUriForm = WebUtility.HtmlDecode(url);

            TempHTMLTopic = BodyTemplate.Replace("%%MESSAGES%%", TempHTMLMessagesList);

            await ThreadUI.Invoke(() =>
            {
                SolidColorBrush color = (SolidColorBrush)App.Current.Resources["SystemControlHighlightAltListAccentLowBrush"];
                var colorString       = $"{color.Color.R.ToString()}, {color.Color.G.ToString()}, {color.Color.B.ToString()}";

                TempHTMLTopic = TempHTMLTopic.Replace("%%ACCENTCOLOR%%", colorString);
                //await FileIO.WriteTextAsync(cssFile, css);
            });


            // Create/Open WebSite-Cache folder
            var subfolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(Strings.WebSiteCacheFolderName, CreationCollisionOption.OpenIfExists);

            var file = await subfolder.CreateFileAsync($"{Strings.WebSiteCacheFileName}", CreationCollisionOption.ReplaceExisting);

            await FileIO.WriteTextAsync(file, TempHTMLTopic);

            await ThreadUI.Invoke(() =>
            {
                Loc.Topic.UpdateTopicWebView(currentTopic);

                Loc.Topic.IsTopicLoading = false;
            });
        }
Пример #10
0
        static async Task <ObservableCollection <Topic> > Fetch(FollowedTopicType topicType)
        {
            var url = "";

            switch (topicType)
            {
            case FollowedTopicType.Favoris:
                url = HFRUrl.FavsUrl;
                break;

            case FollowedTopicType.Drapeaux:
                url = HFRUrl.DrapsUrl;
                break;

            case FollowedTopicType.Lus:
                url = HFRUrl.ReadsUrl;
                break;

            default:
                break;
            }
            var html = await HttpClientHelper.Get(url);

            if (string.IsNullOrEmpty(html))
            {
                return(null);
            }

            /* DG */
            Stopwatch stopwatch = new Stopwatch();

            Debug.WriteLine("Start Bench");
            stopwatch.Reset();
            stopwatch.Start();
            /* DG */

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);
            string[] userIdArray = htmlDoc.DocumentNode.Descendants("a")
                                   .Where(x => x.GetAttributeValue("href", "").Contains("/user/allread.php?id_user="******"href", "")).ToArray();

            int userID = Convert.ToInt32(userIdArray[0].Split('=')[1].Split('&')[0]);
            await ThreadUI.Invoke(() => Loc.Main.AccountManager.CurrentAccount.UserId = userID);

            Loc.Main.AccountManager.UpdateCurrentAccountInDB();

            int i = 0;

            string[] favorisTopicNames = htmlDoc.DocumentNode.Descendants("a")
                                         .Where(x =>
                                                x.GetAttributeValue("class", "") == "cCatTopic" &&
                                                x.GetAttributeValue("title", "").Contains("Sujet"))
                                         .Select(y => y.InnerText).ToArray();

            string[] favorisTopicNumberOfPages = htmlDoc.DocumentNode.Descendants("td")
                                                 .Where(x => x.GetAttributeValue("class", "") == "sujetCase4")
                                                 .Select(y => y.InnerText).ToArray();

            string[] favorisTopicUri = htmlDoc.DocumentNode.Descendants("a")
                                       .Where(x =>
                                              x.GetAttributeValue("class", "") == "cCatTopic" &&
                                              x.GetAttributeValue("title", "").Contains("Sujet"))
                                       .Select(y => y.GetAttributeValue("href", "")).ToArray();

            //Debug.WriteLine(string.Join("\n\r", favorisTopicUri));

            string[] favorisLastPost = htmlDoc.DocumentNode.Descendants("td")
                                       .Where(x => x.GetAttributeValue("class", "").Contains("sujetCase9"))
                                       .Select(y => y.InnerText).ToArray();

            string[] favorisIsHot = htmlDoc.DocumentNode.Descendants("img")
                                    .Where(x => x.GetAttributeValue("alt", "") == "Off" ||
                                           x.GetAttributeValue("alt", "") == "On")
                                    .Select(y => y.GetAttributeValue("alt", "")).ToArray();

            string[] favorisBalise = htmlDoc.DocumentNode.Descendants("a")
                                     .Where(x => x.GetAttributeValue("href", "").Contains("#t"))
                                     .Select(y => y.GetAttributeValue("href", "")).ToArray();

            //Debug.WriteLine(string.Join("\n\r", favorisBalise));

            string[] mpArray =
                htmlDoc.DocumentNode.Descendants("a").Where(x => x.GetAttributeValue("class", "") == "red")
                .Select(y => y.InnerText).ToArray();


            /* DG */
            stopwatch.Stop();
            Debug.WriteLine("Bench Middle: " + stopwatch.ElapsedTicks +
                            " mS: " + stopwatch.ElapsedMilliseconds);
            stopwatch.Reset();
            stopwatch.Start();
            /* DG */

            int j      = 0;
            var topics = new ObservableCollection <Topic>();

            foreach (string line in favorisTopicNames)
            {
                if (favorisIsHot[i] == "On")
                {
                    var numberOfPagesTopicLine = favorisTopicNumberOfPages[i] != "&nbsp;"
                        ? int.Parse(favorisTopicNumberOfPages[i])
                        : 1;

                    var firstTopicCatId =
                        WebUtility.HtmlDecode(favorisBalise[j]).IndexOf("&cat=", StringComparison.Ordinal) +
                        "&cat=".Length;
                    var lastTopicCatId = WebUtility.HtmlDecode(favorisBalise[j])
                                         .IndexOf("&", firstTopicCatId, StringComparison.Ordinal);
                    int topicCatId;
                    int.TryParse(
                        WebUtility.HtmlDecode(favorisBalise[j])
                        .Substring(firstTopicCatId, lastTopicCatId - firstTopicCatId), out topicCatId);

                    var firstTopicSubCatId =
                        WebUtility.HtmlDecode(favorisBalise[j])
                        .IndexOf("&subcat=", StringComparison.Ordinal) + "&subcat=".Length;
                    var lastTopicSubCatId = WebUtility.HtmlDecode(favorisBalise[j])
                                            .IndexOf("&", firstTopicSubCatId, StringComparison.Ordinal);
                    var topicSubCatId = WebUtility.HtmlDecode(favorisBalise[j])
                                        .Substring(firstTopicSubCatId, lastTopicSubCatId - firstTopicSubCatId);

                    var firstTopicId =
                        WebUtility.HtmlDecode(favorisBalise[j]).IndexOf("&post=", StringComparison.Ordinal) +
                        "&post=".Length;
                    var lastTopicId = WebUtility.HtmlDecode(favorisBalise[j])
                                      .LastIndexOf("&page", StringComparison.Ordinal);
                    var topicId = WebUtility.HtmlDecode(favorisBalise[j])
                                  .Substring(firstTopicId, lastTopicId - firstTopicId);

                    var firstReponseId =
                        WebUtility.HtmlDecode(favorisBalise[j]).IndexOf("#t", StringComparison.Ordinal) +
                        "#t".Length;
                    var lastReponseId = WebUtility.HtmlDecode(favorisBalise[j]).Length;
                    var reponseId     = "rep" +
                                        WebUtility.HtmlDecode(favorisBalise[j])
                                        .Substring(firstReponseId, lastReponseId - firstReponseId);

                    var firstPageNumber =
                        WebUtility.HtmlDecode(favorisBalise[j]).IndexOf("&page=", StringComparison.Ordinal) +
                        "&page=".Length;
                    var lastPageNumber = WebUtility.HtmlDecode(favorisBalise[j])
                                         .LastIndexOf("&p=", StringComparison.Ordinal);
                    var pageNumber = int.Parse(WebUtility.HtmlDecode(favorisBalise[j])
                                               .Substring(firstPageNumber, lastPageNumber - firstPageNumber));

                    // URL du flag
                    var drapURI = WebUtility.HtmlDecode(favorisBalise[j]);

                    // Formatage topic name
                    string topicNameFav = TopicNameHelper.Shorten(WebUtility.HtmlDecode(line));

                    // Conversion date
                    string favorisSingleLastPostTimeString =
                        Regex.Replace(
                            Regex.Replace(WebUtility.HtmlDecode(favorisLastPost[i].Substring(0, 28)), "à",
                                          ""), "-", "/");
                    DateTime favorisSingleLastPostDt;
                    favorisSingleLastPostDt = DateTime.Parse(favorisSingleLastPostTimeString,
                                                             new CultureInfo("fr-FR"));
                    double favorisSingleLastPostTime;
                    favorisSingleLastPostTime = Convert.ToDouble(favorisSingleLastPostDt.ToFileTime());

                    // Nom du dernier posteur
                    string favorisLastPostUser =
                        WebUtility.HtmlDecode(favorisLastPost[i].Substring(28,
                                                                           favorisLastPost[i].Length - 28));

                    // Temps depuis dernier post
                    TimeSpan timeSpent;
                    timeSpent = DateTime.Now.Subtract(favorisSingleLastPostDt);
                    string favorisLastPostText = TopicNameHelper.TimeSinceLastReadMsg(timeSpent, favorisLastPostUser);

                    topics.Add(new Topic()
                    {
                        TopicName             = topicNameFav,
                        TopicCatId            = topicCatId,
                        TopicSubCatId         = topicSubCatId,
                        TopicId               = topicId,
                        TopicCatName          = HFRCats.PlainNameFromId(topicCatId),
                        TopicLastPostDate     = favorisSingleLastPostTime,
                        TopicLastPost         = favorisLastPostText,
                        TopicLastPostTimeSpan = timeSpent,
                        TopicNbPage           = numberOfPagesTopicLine,
                        TopicCurrentPage      = pageNumber,
                        TopicReponseId        = reponseId,
                        TopicIndexCategory    = HFRCats.GetHFRIndexFromId(topicCatId),
                        TopicDrapURI          = drapURI,
                    });
                    j++;
                }
                i++;
            }

            /* DG */
            stopwatch.Stop();
            Debug.WriteLine("Bench End: " + stopwatch.ElapsedTicks +
                            " mS: " + stopwatch.ElapsedMilliseconds);
            /* DG */

            Debug.WriteLine("Drapeaux fetched");
            return(topics);
        }
Пример #11
0
        static async Task <ObservableCollection <Topic> > Fetch(FollowedTopicType topicType)
        {
            var url = "";

            switch (topicType)
            {
            case FollowedTopicType.Favoris:
                url = HFRUrl.FavsUrl;
                break;

            case FollowedTopicType.Drapeaux:
                url = HFRUrl.DrapsUrl;
                break;

            case FollowedTopicType.Lus:
                url = HFRUrl.ReadsUrl;
                break;

            default:
                break;
            }
            var html = await HttpClientHelper.Get(url);

            if (string.IsNullOrEmpty(html))
            {
                return(null);
            }

            /* DG */
            Stopwatch stopwatch = new Stopwatch();

            Debug.WriteLine("Start Bench");
            stopwatch.Reset();
            stopwatch.Start();
            /* DG */

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);
            string[] userIdArray = htmlDoc.DocumentNode.Descendants("a")
                                   .Where(x => x.GetAttributeValue("href", "").Contains("/user/allread.php?id_user="******"href", "")).ToArray();

            int userID = Convert.ToInt32(userIdArray[0].Split('=')[1].Split('&')[0]);
            await ThreadUI.Invoke(() => Loc.Main.AccountManager.CurrentAccount.UserId = userID);

            Loc.Main.AccountManager.UpdateCurrentAccountInDB();

            /* DG */
            stopwatch.Stop();
            Debug.WriteLine("Bench Middle: " + stopwatch.ElapsedTicks +
                            " mS: " + stopwatch.ElapsedMilliseconds);
            stopwatch.Reset();
            stopwatch.Start();
            /* DG */

            var messagesArray = ThreadHelper.GetPostNodesFromHtmlDoc(htmlDoc);

            if (messagesArray == null)
            {
                return(null);
            }

            var topics = new ObservableCollection <Topic>();

            foreach (var msg in messagesArray)
            {
                var sujetCase10 = ThreadHelper.GetSujetCase10(msg);
                var id          = ThreadHelper.GetIdFromSujetCase10Node(sujetCase10);
                var catId       = ThreadHelper.GetCatIdFromSujetCase10Node(sujetCase10);

                var sujetCase9             = ThreadHelper.GetSujetCase9(msg);
                var threadLastPostDateTime = ThreadHelper.GetDateTimeLastPostFromNode(sujetCase9);
                var lastPoster             = ThreadHelper.ThreadLastPostMemberPseudo(sujetCase9);

                var isNew = ThreadHelper.NewPost(msg);

                var subject = ThreadHelper.ThreadName(msg);
                subject = ThreadNameHelper.Shorten(subject);

                var nbPage = ThreadHelper.GetNbPageFromNode(msg);
                var author = ThreadHelper.ThreadAuthor(msg);

                var threadUrl = msg.Descendants("td").FirstOrDefault(x => x.GetAttributeValue("class", "") == "sujetCase5")?.FirstChild?.GetAttributeValue("href", "")?.CleanFromWeb();
                // For Favorites page where we are already in the last post, the star/flag icon is missing so we go to the last post
                if (string.IsNullOrEmpty(threadUrl))
                {
                    threadUrl = msg.Descendants("td").FirstOrDefault(x => x.GetAttributeValue("class", "").Contains("sujetCase9"))?.FirstChild?.GetAttributeValue("href", "")?.CleanFromWeb();
                }


                var subCatId    = ThreadHelper.GetSubCatId(threadUrl);
                var rep         = ThreadHelper.GetBookmarkId(threadUrl);
                var currentPage = ThreadHelper.GetCurrentPage(threadUrl);

                var topic = new Topic();
                topic.ThreadId                   = id;
                topic.ThreadName                 = subject;
                topic.ThreadUri                  = threadUrl;
                topic.ThreadAuthor               = author;
                topic.ThreadHasNewPost           = isNew;
                topic.ThreadLastPostDate         = threadLastPostDateTime;
                topic.ThreadLastPostMemberPseudo = lastPoster;
                topic.ThreadNbPage               = nbPage;

                topic.ThreadCurrentPage = currentPage;
                topic.ThreadBookmarkId  = rep;
                topic.TopicCatId        = catId;
                topic.TopicSubCatId     = subCatId;

                topics.Add(topic);
            }

            /* DG */
            stopwatch.Stop();
            Debug.WriteLine("Bench End: " + stopwatch.ElapsedTicks + " mS: " + stopwatch.ElapsedMilliseconds);
            /* DG */

            Debug.WriteLine("Drapeaux fetched");
            return(topics);
        }
Пример #12
0
        public static async Task Fetch(Thread currentThread)
        {
            await ThreadUI.Invoke(() =>
            {
                Loc.Thread.IsThreadLoading = true;
            });

            var html = await HttpClientHelper.Get(currentThread.ThreadUri);

            if (string.IsNullOrEmpty(html))
            {
                return;
            }

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);

            //Refresh Current/Number of pages
            var pagesList = htmlDoc.DocumentNode.Descendants("tr")
                            .Where(x => x.GetAttributeValue("class", "") == "cBackHeader fondForum2PagesHaut")
                            .SelectMany(tr => tr.Descendants("div"))
                            .Where(x => x.GetAttributeValue("class", "") == "left")
                            .FirstOrDefault();

            int nbPage      = 1;
            int currentPage = 1;

            if (pagesList != null)
            {
                var nbPageStr = pagesList.Descendants("a")
                                .LastOrDefault().InnerText;
                int.TryParse(nbPageStr, out nbPage);

                var currentPageStr = pagesList.Descendants("b")
                                     .LastOrDefault().InnerText;
                int.TryParse(currentPageStr, out currentPage);

                if (currentPage > nbPage)
                {
                    nbPage = currentPage;
                }
            }

            await ThreadUI.Invoke(() =>
            {
                Loc.Thread.CurrentThread.ThreadNbPage      = nbPage;
                Loc.Thread.CurrentThread.ThreadCurrentPage = currentPage;
            });

            var postNodes =
                htmlDoc.DocumentNode.Descendants("table")
                .Where(x => x.GetAttributeValue("class", "") == "messagetable")
                .ToArray();

            if (postNodes == null || !postNodes.Any())
            {
                return;
            }

            string TempHTMLMessagesList = "";
            string TempHTMLMessage      = "";
            string TempHTMLTopic        = "";

            string BodyTemplate    = "";
            string MessageTemplate = "";

            // This is absolutely quick and dirty code :o
            Assembly asm = typeof(App).GetTypeInfo().Assembly;

            using (Stream stream = asm.GetManifestResourceStream(HFRRessources.Tpl_Topic))
                using (StreamReader reader = new StreamReader(stream))
                {
                    BodyTemplate = reader.ReadToEnd();
                }

            using (Stream stream = asm.GetManifestResourceStream(HFRRessources.Tpl_Message))
                using (StreamReader reader = new StreamReader(stream))
                {
                    MessageTemplate = reader.ReadToEnd();
                }

            var i = 0;

            foreach (var postNode in postNodes)
            {
                TempHTMLMessage = MessageTemplate;

                // Id de la réponse
                var reponseId =
                    postNode.Descendants("a")
                    .FirstOrDefault(x => x.GetAttributeValue("href", "").StartsWith("#t"))
                    .GetAttributeValue("href", "")
                    .Replace("#t", "");

                // Pseudo
                var pseudo = postNode.Descendants("b").FirstOrDefault(x => x.GetAttributeValue("class", "") == "s2").InnerText.CleanFromWeb();
                if (Loc.Settings.IgnoreListMembersList != null && Loc.Settings.IgnoreListMembersList.Contains(pseudo))
                {
                    Debug.WriteLine("Post form member in Ignore list, switching to next post");
                    continue;
                }
                // Mood
                var mood = postNode.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "MoodStatus")?.InnerText.CleanFromWeb();

                // Img
                var avatarUri     = "ms-appx-web:///Assets/HTML/UI/rsz_no_avatar.png";
                var avatarClass   = "no_avatar";
                var divAvatarNode = postNode.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("class", "") == "avatar_center");
                if (divAvatarNode != null && divAvatarNode.ChildNodes.Any())
                {
                    var imgAvatarNode = divAvatarNode.FirstChild;
                    var uri           = imgAvatarNode.GetAttributeValue("src", "");
                    if (!string.IsNullOrEmpty(uri))
                    {
                        avatarUri   = uri;
                        avatarClass = "";
                    }
                }

                var toolbar = postNode.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("class", "") == "toolbar");
                // Date
                var date = toolbar.InnerText.CleanFromWeb();
                date = date.Replace("Posté le ", "");

                // Can edit
                bool canEdit = toolbar.Descendants("img").Any(x => x.GetAttributeValue("alt", "") == "edit" && x.GetAttributeValue("title", "").Contains("Edit"));

                // Content
                var contentHtml = postNode.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("id", "").Contains("para"));

                if (Loc.Settings.TubecastEnabled)
                {
                    var youtubeRegex   = new Regex("youtu(?:\\.be|be\\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)");
                    var youtubeEntries = contentHtml.Descendants("a").Where(x => x.GetAttributeValue("href", "").Contains("www.youtube.com") || x.GetAttributeValue("href", "").Contains("//youtu.be"));
                    foreach (var youtubeEntry in youtubeEntries)
                    {
                        var   videoUrl     = youtubeEntry.GetAttributeValue("href", "");
                        Match youtubeMatch = youtubeRegex.Match(videoUrl);

                        if (youtubeMatch.Success)
                        {
                            videoUrl = "vnd.youtube:" + youtubeMatch.Groups[1].Value;
                            youtubeEntry.SetAttributeValue("href", videoUrl);
                        }
                    }
                }

                var content      = contentHtml.InnerHtml;
                int lastPostText = content.IndexOf("<div style=\"clear: both;\"> </div>", StringComparison.Ordinal);
                if (lastPostText == -1)
                {
                    lastPostText = content.Length;
                }

                content = content.Substring(0, lastPostText);
                content = content.CleanFromWeb();

                TempHTMLMessage = TempHTMLMessage.Replace("%%ID%%", i.ToString());
                TempHTMLMessage = TempHTMLMessage.Replace("%%POSTID%%", reponseId);

                if (pseudo == "Modération")
                {
                    TempHTMLMessage = TempHTMLMessage.Replace("%%moderation%%", "moderation");
                }
                else
                {
                    TempHTMLMessage = TempHTMLMessage.Replace("%%moderation%%", "");
                }

                TempHTMLMessage = TempHTMLMessage.Replace("%%no_avatar_class%%", avatarClass);

                if (Loc.Settings.SquareAvatarStylePreferred)
                {
                    TempHTMLMessage = TempHTMLMessage.Replace("%%round_avatar_class%%", "");
                }
                else
                {
                    TempHTMLMessage = TempHTMLMessage.Replace("%%round_avatar_class%%", "round");
                }

                if (canEdit)
                {
                    // Post is editable
                    TempHTMLMessage = TempHTMLMessage.Replace("%%PERSONALPOST%%", "");
                }
                else
                {
                    // Post is not personal, hide personal actions
                    TempHTMLMessage = TempHTMLMessage.Replace("%%PERSONALPOST%%", "personal_post_button_hidden");
                }

                TempHTMLMessage = TempHTMLMessage.Replace("%%AUTEUR_AVATAR%%", avatarUri);
                TempHTMLMessage = TempHTMLMessage.Replace("%%AUTEUR_PSEUDO%%", pseudo);
                TempHTMLMessage = TempHTMLMessage.Replace("%%MESSAGE_DATE%%", date);

                TempHTMLMessage = TempHTMLMessage.Replace("%%MESSAGE_CONTENT%%", content);

                TempHTMLMessagesList += TempHTMLMessage;
                i++;
            }

            // Get URL of the new post form
            var url = htmlDoc.DocumentNode.Descendants("form").FirstOrDefault(x => x.GetAttributeValue("id", "") == "repondre_form").GetAttributeValue("action", "");

            currentThread.ThreadNewPostUriForm = WebUtility.HtmlDecode(url);

            TempHTMLTopic = BodyTemplate.Replace("%%MESSAGES%%", TempHTMLMessagesList);

            // Get Accent Color
            await ThreadUI.Invoke(() =>
            {
                SolidColorBrush color = (SolidColorBrush)App.Current.Resources["SystemControlHighlightAltListAccentLowBrush"];
                var colorString       = $"{color.Color.R.ToString()}, {color.Color.G.ToString()}, {color.Color.B.ToString()}";

                TempHTMLTopic = TempHTMLTopic.Replace("%%ACCENTCOLOR%%", colorString);
            });

            // Get desired theme
            if (Loc.Settings.IsApplicationThemeDark)
            {
                TempHTMLTopic = TempHTMLTopic.Replace("%%COLOR-FG%%", "white").Replace("%%COLOR-BG%%", "black").Replace("%%COLOR-QUOTE%%", "#252525");
            }
            else
            {
                TempHTMLTopic = TempHTMLTopic.Replace("%%COLOR-FG%%", "black").Replace("%%COLOR-BG%%", "white").Replace("%%COLOR-QUOTE%%", "#E3E3E3");
            }

            // Get user selected font-size
            var fontSize = Loc.Settings.FontSizePreferred;

            TempHTMLTopic = TempHTMLTopic.Replace("%%FONTSIZE%%", fontSize.ToString());

            // Get user selected header transparency setting
            var postHeaderTransparency = Loc.Settings.PostHeaderTransparencyPreferred;

            TempHTMLTopic = TempHTMLTopic.Replace("%%headerPostTransparency%%", (1 - postHeaderTransparency).ToString().Replace(",", "."));

            // Create/Open WebSite-Cache folder
            var subfolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(Strings.WebSiteCacheFolderName, CreationCollisionOption.OpenIfExists);

            var file = await subfolder.CreateFileAsync($"{Strings.WebSiteCacheFileName}", CreationCollisionOption.ReplaceExisting);

            await FileIO.WriteTextAsync(file, TempHTMLTopic);

            await ThreadUI.Invoke(() =>
            {
                Loc.Thread.UpdateThreadWebView(currentThread);

                Loc.Thread.IsThreadLoading = false;
            });
        }