diff --git a/README.RU.md b/README.RU.md index e998cf3..54668f4 100644 --- a/README.RU.md +++ b/README.RU.md @@ -1,7 +1,7 @@ [![EN](https://user-images.githubusercontent.com/9499881/33184537-7be87e86-d096-11e7-89bb-f3286f752bc6.png)](https://github.com/r57zone/ProtonShell/blob/master/README.md) [![RU](https://user-images.githubusercontent.com/9499881/27683795-5b0fbac6-5cd8-11e7-929c-057833e01fb1.png)](https://github.com/r57zone/ProtonShell/blob/master/README.RU.md) # ProtonShell -Легковесная оболочка для веб-сайтов, простых веб-приложений, работающая на базе системного браузера Microsoft Edge. На её основе можно сделать отдельное окно для Google Docs, чата Twitch, клиента инстаграмма для ПК, с пользовательским js скриптом или какое-то веб-приложение в своём окне. +Легковесная оболочка для веб-сайтов, простых веб-приложений, работающая на базе системного браузера Microsoft Edge. На её основе можно сделать отдельное окно для Google Docs, ChatGPT, чата Twitch, клиента инстаграмма для ПК, с пользовательским js скриптом или какое-то веб-приложение в своём окне. ## Скриншоты ![](https://github.com/r57zone/ProtonShell/assets/9499881/ca14a06b-4c3f-420a-8ec8-a742a2ae5f8d) diff --git a/README.md b/README.md index 24dd9f7..b57fd40 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ← Choose language | Выберите язык # ProtonShell -Lightweight shell for websites, simple web applications, built on the Microsoft Edge system browser. Based on it you can make a separate window for Google Docs, Twitch chat, instagram client for PC, with js userscript or some web application in its own window. +Lightweight shell for websites, simple web applications, built on the Microsoft Edge system browser. Based on it you can make a separate window for Google Docs, ChatGPT, Twitch chat, Instagram client for PC, with js userscript or some web application in its own window. ## Screenshots ![](https://github.com/r57zone/ProtonShell/assets/9499881/ca14a06b-4c3f-420a-8ec8-a742a2ae5f8d) diff --git a/Source/Config.ini b/Source/Config.ini index 4c64f12..6329c57 100644 --- a/Source/Config.ini +++ b/Source/Config.ini @@ -1,3 +1,5 @@ +# https://github.com/r57zone/ProtonShell + [Main] Title=Test App # Application folder address - "%FULLPATH%/", clear the value of "File" if you want to load the website. @@ -8,14 +10,19 @@ URL=https://google.ru OpenExternalLinks=1 # Example of the path - "%FULLPATH%/UserScript.js" UserScript= +# Change system proxy while using the app +SystemProxy= +# Return to previous system proxy after closing the app (if you use proxy), 1 - on, 0 - off +ReturnPreviousProxy=0 [Window] -Width=640 -Height=360 +Width=720 +Height=480 SaveSize=0 # None = 0, Sizeable = 1, Single = 2, Dialog = 3, SizeToolWin = 4, ToolWindow = 5 BorderStyle=1 +# 1 - on, 0 - off HideMaximize=0 # Normal = 0, Maximized = 1, FullScreen = 2 diff --git a/Source/Unit1.dfm b/Source/Unit1.dfm index e85be04..71bd114 100644 --- a/Source/Unit1.dfm +++ b/Source/Unit1.dfm @@ -2,8 +2,8 @@ object Main: TMain Left = 0 Top = 0 Caption = 'Main' - ClientHeight = 480 - ClientWidth = 640 + ClientHeight = 479 + ClientWidth = 636 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText @@ -13,19 +13,18 @@ object Main: TMain Position = poDefault OnClose = FormClose OnCreate = FormCreate + OnDestroy = FormDestroy TextHeight = 13 object EdgeBrowser: TEdgeBrowser Left = 0 Top = 0 - Width = 640 - Height = 480 + Width = 636 + Height = 479 Align = alClient TabOrder = 0 UserDataFolder = '%LOCALAPPDATA%\bds.exe.WebView2' OnCreateWebViewCompleted = EdgeBrowserCreateWebViewCompleted OnNavigationCompleted = EdgeBrowserNavigationCompleted OnNewWindowRequested = EdgeBrowserNewWindowRequested - ExplicitWidth = 792 - ExplicitHeight = 467 end end diff --git a/Source/Unit1.pas b/Source/Unit1.pas index a9f53ce..015bd06 100644 --- a/Source/Unit1.pas +++ b/Source/Unit1.pas @@ -4,7 +4,8 @@ interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, - Vcl.Controls, Vcl.Forms, Vcl.Dialogs, WebView2, Winapi.ActiveX, Vcl.Edge, IniFiles, ShellAPI; + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, WebView2, Winapi.ActiveX, Vcl.Edge, IniFiles, ShellAPI, + Registry, WinInet; const // https://stackoverflow.com/questions/66692031/how-to-set-useragent-in-new-delphi-tedgebrowser IID_ICoreWebView2Settings2: TGUID = '{EE9A0F68-F46C-4E32-AC23-EF8CAC224D2A}'; @@ -27,6 +28,7 @@ TMain = class(TForm) Args: TNewWindowRequestedEventArgs); procedure EdgeBrowserNavigationCompleted(Sender: TCustomEdgeBrowser; IsSuccess: Boolean; WebErrorStatus: TOleEnum); + procedure FormDestroy(Sender: TObject); private { Private declarations } public @@ -36,8 +38,8 @@ TMain = class(TForm) var Main: TMain; WinOldWidth, WinOldHeight, WinOldTop, WinOldLeft: integer; - WinSaveSize, WinSavePos: boolean; - EdgeUserAgent: string; + WinSaveSize, WinSavePos, ReturnPrevSystemProxy: boolean; + EdgeUserAgent, SystemProxy, PrevSystemProxy: string; OpenExternalLinks, LoadUserScript: boolean; UserScriptFile: TStringList; @@ -93,6 +95,42 @@ procedure TMain.EdgeBrowserNewWindowRequested(Sender: TCustomEdgeBrowser; end; end; +procedure ProxyActivate(Enable: boolean); +var + Reg: TRegistry; +begin + Reg:=TRegistry.Create; + try + Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Internet Settings', False); + Reg.WriteBool('ProxyEnable', Enable); + Reg.CloseKey; + InternetSetOption(0, INTERNET_OPTION_SETTINGS_CHANGED, 0, 0); + finally + Reg.Free; + end; +end; + +procedure SetProxy(const Server: String); +var + Reg: TRegistry; +begin + Reg:=TRegistry.Create; + try + Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Internet Settings', False); + if ReturnPrevSystemProxy then begin + if Reg.ValueExists('ProxyServer') then + PrevSystemProxy:=Reg.ReadString('ProxyServer') + else + PrevSystemProxy:=''; + ShowMessage(PrevSystemProxy); + end; + Reg.WriteString('ProxyServer', Server); + Reg.CloseKey; + finally + Reg.Free; + end; +end; + procedure TMain.FormClose(Sender: TObject; var Action: TCloseAction); var Ini: TIniFile; @@ -183,7 +221,24 @@ procedure TMain.FormCreate(Sender: TObject); if Ini.ReadBool('Window', 'StayOnTop', false) then FormStyle:=fsStayOnTop; + // System proxy + ReturnPrevSystemProxy:=Ini.ReadBool('Main', 'ReturnPreviousProxy', false); + SystemProxy:=Trim(Ini.ReadString('Main', 'SystemProxy', '')); + if SystemProxy <> '' then begin + SetProxy(SystemProxy); + ProxyActivate(true); + end; + Ini.Free; end; +procedure TMain.FormDestroy(Sender: TObject); +begin + if ReturnPrevSystemProxy then begin + SetProxy(PrevSystemProxy); + ProxyActivate(true); + end else if SystemProxy <> '' then + ProxyActivate(false); +end; + end.