From 975891246c3ab61e48b1c74fc88e1fd8f25600f1 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Tue, 4 Apr 2023 21:17:40 +0530 Subject: Added powershell script to automatically install and update the extension. --- scripts/install.sh | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 scripts/install.sh (limited to 'scripts') diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 0000000..66dde7d --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,72 @@ +function Custom-Remove-Item +{ + param + ( + [string]$FileName + ) + + if (test-path $FileName) + { + Remove-Item -Recurse -Force $FileName + } +} + +echo "Downloading extension." + +Custom-Remove-Item $HOME\banglar-bhumi-utils.zip +Invoke-WebRequest -OutFile $HOME\banglar-bhumi-utils.zip "https://drive.google.com/uc?export=download&id=1OmdtVwRsEFrxAQ78gSsrh-qOi5ApUSTB" +Custom-Remove-Item $HOME\banglar-bhumi-utils +Expand-Archive $HOME\banglar-bhumi-utils.zip -DestinationPath $HOME\banglar-bhumi-utils +Custom-Remove-Item $HOME\banglar-bhumi-utils.zip + +function Find-PSFilePathInRegistry +{ + param + ( + [string]$FileName + ) + + $str = reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ /s /f \$FileName | findstr Default + + if ($str -match "[A-Z]\:.+$FileName") { + return @{ + success = $true + path = $Matches[0] + } + } + else { + return @{ + success = $false + path = "" + } + } +} + +function HandleInstall +{ + param + ( + [string]$Browser + ) + + $Res = Find-PSFilePathInRegistry ($Browser + ".exe") + + if ($Res.success) + { + echo ($Browser + " browser found. Installing extension.") + Stop-Process -ErrorAction "silentlycontinue" -Name $Browser + &$Res.path --disable-extensions="$HOME\banglar-bhumi-utils" + Stop-Process -ErrorAction "silentlycontinue" -Name $Browser + &$Res.path --load-extension="$HOME\banglar-bhumi-utils" + echo ("Installed on " + $Browser + ".") + } +} + +echo "Searching for browsers." + +HandleInstall brave +HandleInstall chrome + +echo "Done" + +pause -- cgit v1.2.3