Skip to content

Commit

Permalink
Set custom useragent
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusTomlinson committed Jun 22, 2024
1 parent 2b95ff7 commit a8ab61a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"preLaunchTask": "Build",
"program": "${workspaceFolder}/build/icloud-for-linux",
"args": ["notes", "Notes"],
"environment": [{"name":"TMPDIR","value":"${workspaceFolder}/build"}],
"cwd": "${workspaceFolder}",
"request": "launch",
"type": "cppdbg",
Expand Down
18 changes: 11 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,32 @@ int main(int, char **argv)
appWin.setVisible(false);
appWin.centreWithSize(1000, 600);
appWin.setVisible(true);
appWin.setWindowTitle( "iCloud " + std::string(argv[2]) );
appWin.setWindowTitle("iCloud " + std::string(argv[2]));
appWin.windowClosed = []()
{ choc::messageloop::stop(); };

choc::ui::WebView webView;
choc::ui::WebView::Options webViewOptions;
webViewOptions.customUserAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0";
choc::ui::WebView webView(webViewOptions);
webView.navigate("https://www.icloud.com/" + std::string(argv[1]));

appWin.setContent(webView.getViewHandle());
appWin.toFront();

webView.onNewWindow( [&](const std::string& url)
webView.onNewWindow([&argv](const std::string& url)
{
choc::ui::DesktopWindow appWin2(choc::ui::Bounds{0, 0, 0, 0});
appWin2.setVisible(false);
appWin2.centreWithSize(1000, 600);
appWin2.setVisible(true);
appWin2.setWindowTitle( "iCloud " + std::string(argv[2]) + "" );
appWin2.setWindowTitle("iCloud " + std::string(argv[2]) + "");

choc::ui::WebView webView;
webView.navigate(url);
choc::ui::WebView::Options webView2Options;
webView2Options.customUserAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0";
choc::ui::WebView webView2(webView2Options);
webView2.navigate(url);

appWin2.setContent(webView.getViewHandle());
appWin2.setContent(webView2.getViewHandle());
appWin2.toFront();

return appWin2.getWindowHandle();
Expand Down
2 changes: 1 addition & 1 deletion subprojects/choc
Submodule choc updated 1 files
+2 −0 gui/choc_WebView.h

0 comments on commit a8ab61a

Please sign in to comment.