From c08fd3191ab38b778bb249401f952c764469a246 Mon Sep 17 00:00:00 2001 From: blurfx Date: Wed, 24 Apr 2024 00:26:40 +0900 Subject: [PATCH] fix to hide daily popup ad (fix #62) --- internal/ad.go | 36 ++++++++++++------------------------ internal/app.go | 2 +- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/internal/ad.go b/internal/ad.go index 19f1e64..4a22b6b 100644 --- a/internal/ad.go +++ b/internal/ad.go @@ -13,30 +13,6 @@ const ( MainViewPadding = 31 ) -func HidePopupAd() { - var popupHandle windows.HWND - for { - popupHandle = winapi.FindWindowEx(0, popupHandle, "", "") - if popupHandle == 0 { - break - } - if winapi.GetParent(popupHandle) != 0 { - continue - } - className := winapi.GetClassName(popupHandle) - if !strings.Contains(className, "RichPopWnd") { - continue - } - rect := new(winapi.Rect) - _ = winapi.GetWindowRect(popupHandle, rect) - width := rect.Right - rect.Left - height := rect.Bottom - rect.Top - if width == 300 && height == 150 { - winapi.SendMessage(popupHandle, winapi.WmClose, 0, 0) - } - } -} - func HideMainWindowAd(windowClass string, handle windows.HWND) { // @deprecated if windowClass == "BannerAdWnd" { @@ -70,3 +46,15 @@ func HideMainViewAdArea(windowText string, rect *winapi.Rect, handle windows.HWN winapi.SetWindowPos(handle, 0, 0, 0, width, height, winapi.SwpNomove) } } + +func HidePopupAd(windowClass string, handle windows.HWND) { + if windowClass == "AdFitWebView" { + parentHandle := winapi.GetParent(handle) + winapi.SendMessage(parentHandle, winapi.WmClose, 0, 0) + winapi.ShowWindow(parentHandle, 0) + winapi.MoveWindow(parentHandle, 0, 0, 0, 0, true) + winapi.SendMessage(handle, winapi.WmClose, 0, 0) + winapi.ShowWindow(handle, 0) + winapi.MoveWindow(handle, 0, 0, 0, 0, true) + } +} diff --git a/internal/app.go b/internal/app.go index 8deda78..3dd9053 100644 --- a/internal/app.go +++ b/internal/app.go @@ -105,6 +105,7 @@ func removeAd() { HideMainWindowAd(className, childHandle) HideMainViewAdArea(windowText, rect, childHandle) HideLockScreenAdArea(windowText, rect, childHandle) + HidePopupAd(className, childHandle) } if mainWindowParentHandle != 0 && len(candidates) > 0 { for _, candidate := range candidates { @@ -116,7 +117,6 @@ func removeAd() { } } } - HidePopupAd() mutex.Unlock() time.Sleep(sleepTime) }