From b5886a3a30efa372273ca17e30987803542d6403 Mon Sep 17 00:00:00 2001 From: "Robert C. Maehl" Date: Fri, 15 Dec 2023 09:16:17 -0500 Subject: [PATCH] Add placeholder support --- Includes/_URLModifications.au3 | 33 +++++++++++++++++++++++++++------ MSEdgeRedirect_Wrapper.au3 | 6 +++--- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Includes/_URLModifications.au3 b/Includes/_URLModifications.au3 index 20943e5..7ca5e17 100644 --- a/Includes/_URLModifications.au3 +++ b/Includes/_URLModifications.au3 @@ -7,10 +7,15 @@ Func _ChangeImageProvider($sURL) + Local $sOriginal + If StringInStr($sURL, "bing.com/images/search?q=") Then $sURL = StringRegExpReplace($sURL, "(?i)(.*)(q=)", "") $sURL = StringRegExpReplace($sURL, "(?i)(?=&id=)(.*)", "") $sURL = StringReplace($sURL, " ", "+") + + $sOriginal = $sURL + Switch _GetSettingValue("Images") Case "Baidu" @@ -20,7 +25,12 @@ Func _ChangeImageProvider($sURL) $sURL = "https://search.brave.com/?ia=images&iax=images&q=" & $sURL Case "Custom" - $sURL = _GetSettingValue("ImagePath") & $sURL + $sURL = _GetSettingValue("SearchPath") + If StringInStr($sURL, "%query%") Then + $sURL = StringReplace($sURL, "%query%", $sOriginal) + Else + $sURL = $sURL & $sOriginal + EndIf Case "DuckDuckGo" $sURL = "https://duckduckgo.com/?ia=images&iax=images&q=" & $sURL @@ -58,7 +68,7 @@ EndFunc Func _ChangeNewsProvider($sURL) - Local $sOriginal = $sURL + Local $sOriginal Local $sRegex = "(?i).*\/(" & _ "autos(\/enthusiasts)?" & _ @@ -80,6 +90,8 @@ Func _ChangeNewsProvider($sURL) $sURL = StringRegExpReplace($sURL, $sRegex, "") $sURL = StringRegExpReplace($sURL, "(?i)(?=)\/.*", "") + $sOriginal = $sURL + Switch _GetSettingValue("News") Case "DuckDuckGo" @@ -103,10 +115,14 @@ EndFunc Func _ChangeSearchEngine($sURL) + Local $sOriginal + If StringInStr($sURL, "bing.com/search?q=") Then $sURL = StringRegExpReplace($sURL, "(?i)(.*)((\?|&)q=)", "") If StringInStr($sURL, "&form") Then $sURL = StringRegExpReplace($sURL, "(?i)(?=&form)(.*)", "") + $sOriginal = $sURL + Switch _GetSettingValue("Search") Case "Ask" @@ -119,7 +135,12 @@ Func _ChangeSearchEngine($sURL) $sURL = "https://search.brave.com/search?q=" & $sURL Case "Custom" - $sURL = _GetSettingValue("SearchPath") & $sURL + $sURL = _GetSettingValue("SearchPath") + If StringInStr($sURL, "%query%") Then + $sURL = StringReplace($sURL, "%query%", $sOriginal) + Else + $sURL = $sURL & $sOriginal + EndIf Case "DuckDuckGo" $sURL = "https://duckduckgo.com/?q=" & $sURL @@ -242,8 +263,8 @@ Func _ChangeWeatherProvider($sURL) Case "Custom" $sURL = _GetSettingValue("WeatherPath") $sURL = StringReplace($sURL, "%lat%", $fLat) - $sUrl = StringReplace($sURL, "%long%", $fLong) - $sUrl = StringReplace($sURL, "%locale%", $sLocale) + $sURL = StringReplace($sURL, "%long%", $fLong) + $sURL = StringReplace($sURL, "%locale%", $sLocale) Case "Weather.com" $sURL = "https://weather.com/" & $sLocale & "/weather/today/l/" & $fLat & "," & $fLong @@ -252,7 +273,7 @@ Func _ChangeWeatherProvider($sURL) $sURL = "https://forecast.weather.gov/MapClick.php?lat=" & $fLat & "&lon=" & $fLong Case "Windy" - $sLocale = StringLeft($sLocale,2) + $sLocale = StringLeft($sLocale, 2) $sURL = "https://www.windy.com/" & $sLocale & "/?" & $fLat & "," & $fLong Case "WUnderground" diff --git a/MSEdgeRedirect_Wrapper.au3 b/MSEdgeRedirect_Wrapper.au3 index 1bbb3dd..45f042e 100644 --- a/MSEdgeRedirect_Wrapper.au3 +++ b/MSEdgeRedirect_Wrapper.au3 @@ -822,7 +822,7 @@ Func RunSetup($bUpdate = False, $bSilent = False, $iPage = 0, $hSetupFile = @Scr EndIf Case $hMsg = $hEngine And GUICtrlRead($hEngine) = "Custom" - $sEngine = InputBox("Enter Search Engine URL", "Enter the URL format of the custom Search Engine to use", "https://duckduckgo.com/?q=") + $sEngine = InputBox("Enter Search Engine URL", "Enter the URL format of the custom Search Engine to use, including the %query% placeholder.", "https://duckduckgo.com/?q=%query%") If @error Then GUICtrlSetData($hEngine, "Google") Case $hMsg = $hNoImgs @@ -833,7 +833,7 @@ Func RunSetup($bUpdate = False, $bSilent = False, $iPage = 0, $hSetupFile = @Scr EndIf Case $hMsg = $hImgSRC And GUICtrlRead($hImgSRC) = "Custom" - $sImgEng = InputBox("Enter Image Search Engine URL", "Enter the URL format of the custom Image Search Engine to use", "https://duckduckgo.com/?ia=images&iax=images&q=") + $sImgEng = InputBox("Enter Image Search Engine URL", "Enter the URL format of the custom Image Search Engine to use, including the %query% placeholder.", "https://duckduckgo.com/?ia=images&iax=images&q=%query%") If @error Then GUICtrlSetData($hImgSRC, "Google") Case $hMsg = $hNoMSN @@ -844,7 +844,7 @@ Func RunSetup($bUpdate = False, $bSilent = False, $iPage = 0, $hSetupFile = @Scr EndIf Case $hMsg = $hWeather And GUICtrlRead($hWeather) = "Custom" - $sWeatherEng = InputBox("Enter Weather Engine URL", "Enter the URL format of the custom Weather Engine to use (REQUIRES LAT,LONG SUPPORT!)", "https://www.accuweather.com/en/search-locations?query=") + $sWeatherEng = InputBox("Enter Weather Engine URL", "Enter the URL format of the custom Weather Engine to use, including the %lat%, %long%, and (optionally) %locale% placeholders.", "https://www.accuweather.com/en/search-locations?query=") If @error Then GUICtrlSetData($hImgSRC, "Weather.com") Case $hMsg = $hNoNews