Skip to content

Commit

Permalink
Add placeholder support
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmaehl committed Dec 15, 2023
1 parent 141aad7 commit b5886a3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
33 changes: 27 additions & 6 deletions Includes/_URLModifications.au3
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -58,7 +68,7 @@ EndFunc

Func _ChangeNewsProvider($sURL)

Local $sOriginal = $sURL
Local $sOriginal

Local $sRegex = "(?i).*\/(" & _
"autos(\/enthusiasts)?" & _
Expand All @@ -80,6 +90,8 @@ Func _ChangeNewsProvider($sURL)
$sURL = StringRegExpReplace($sURL, $sRegex, "")
$sURL = StringRegExpReplace($sURL, "(?i)(?=)\/.*", "")

$sOriginal = $sURL

Switch _GetSettingValue("News")

Case "DuckDuckGo"
Expand All @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions MSEdgeRedirect_Wrapper.au3
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b5886a3

Please sign in to comment.