Code prompts

Privacy Focused Local Browser in C++

Privacy-focused local browser in C++.

Example code

C++
// PrivacyBrowser.cpp - Local Windows Privacy Browser
// Blocks all cloud tracking, telemetry, and external connections
// Night soft light mode UI with dark theme optimized for private browsing
// Built with Win32 API + WebView2 for modern rendering without cloud dependencies
// Compile with: cl PrivacyBrowser.cpp /EHsc /link ole32.lib urlmon.lib

#include <windows.h>
#include <webview2.h>
#include <wrl/client.h>
#include <string>
#include <vector>
#include <fstream>
#include <shlobj.h>
#include <shlwapi.h>
#include <iostream>

#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "urlmon.lib")
#pragma comment(lib, "shlwapi.lib")

using namespace Microsoft::WRL;

const wchar_t* APP_NAME = L"ShadowBrowse - Local Privacy Browser";
const wchar_t* USER_DATA_FOLDER = L"ShadowBrowseData";
const COLORREF NIGHT_BG = RGB(15, 18, 25);
const COLORREF NIGHT_SOFT = RGB(35, 42, 55);
const COLORREF TEXT_COLOR = RGB(180, 190, 205);

class PrivacyBrowser {
private:
    HWND hwnd = NULL;
    ICoreWebView2* webview = NULL;
    ICoreWebView2Controller* controller = NULL;
    std::wstring profilePath;

// Hardcoded blocklist - blocks all major tracking domains
    std::vector<std::wstring> blocklist = {
        L"google-analytics.com", L"googletagmanager.com", L"doubleclick.net",
        L"facebook.com", L"fb.com", L"connect.facebook.net",
        L"analytics.", L"tracker.", L"pixel.", L"beacon.",
        L"amazon-adsystem.com", L"adobe.com", L"omtrdc.net",
        L"scorecardresearch.com", L"quantserve.com", L"matomo.",
        L"cloudfront.net", L"akamai.net", L"edgecast.com",
        L"telemetry.", L"metrics.", L"crash.", L"sentry.io",
        L"mixpanel.com", L"segment.com", L"amplitude.com",
        L"hotjar.com", L"intercom.io", L"drift.com"
    };

public:
    PrivacyBrowser() {
        wchar_t path[MAX_PATH];
        SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, path);
        profilePath = std::wstring(path) + L"\\" + USER_DATA_FOLDER;
        CreateDirectoryW(profilePath.c_str(), NULL);
        
        // Create local block rules file
        CreateBlockRules();
    }

~PrivacyBrowser() {
        if (controller) controller->Release();
        if (webview) webview->Release();
    }

void CreateBlockRules() {
        std::wofstream rules(profilePath + L"\\blockrules.txt");
        rules << "# ShadowBrowse - All cloud tracking blocked\n";
        for (const auto& domain : blocklist) {
            rules << "127.0.0.1 " << domain << "\n";
            rules << "127.0.0.1 www." << domain << "\n";
        }
        rules.close();
    }

bool Initialize(HINSTANCE hInstance) {
        WNDCLASSEXW wc = {0};
        wc.cbSize = sizeof(WNDCLASSEXW);
        wc.lpfnWndProc = WndProc;
        wc.hInstance = hInstance;
        wc.lpszClassName = L"ShadowBrowseClass";
        wc.hbrBackground = CreateSolidBrush(NIGHT_BG);
        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        RegisterClassExW(&wc);

hwnd = CreateWindowExW(0, L"ShadowBrowseClass", APP_NAME, 
            WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 
            1280, 800, NULL, NULL, hInstance, this);

if (!hwnd) return false;

// Set night soft light theme
        SetWindowTheme(hwnd, L"DarkMode_Explorer", NULL);
        
        ShowWindow(hwnd, SW_SHOW);
        UpdateWindow(hwnd);

// Initialize WebView2 with strict local profile and no tracking
        return CreateWebView();
    }

bool CreateWebView() {
        auto envOptions = Make<CoreWebView2EnvironmentOptions>();
        envOptions->put_AdditionalBrowserArguments(
            L"--disable-features=OptimizationHints,InterestFeed,MediaRouter,"
            L"WebRTC,AutofillServerCommunication,ChromeBrowserCloudManagement,"
            L"CalculateNativeWinOcclusion --disable-sync --no-first-run "
            L"--disable-background-networking --disable-component-update "
            L"--disable-domain-reliability --disable-metrics --disable-breakpad "
            L"--disable-client-side-phishing-detection --disable-default-apps "
            L"--disable-sync --disable-google-services --disable-logging "
            L"--disable-web-resources --disable-features=AutofillServerCommunication"
        );

HRESULT hr = CreateCoreWebView2EnvironmentWithOptions(
            profilePath.c_str(), nullptr, envOptions.Get(),
            Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
                [this](HRESULT result, ICoreWebView2Environment* env) -> HRESULT {
                    if (FAILED(result)) return result;

env->CreateCoreWebView2Controller(
                        hwnd, 
                        Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
                            [this](HRESULT result, ICoreWebView2Controller* ctrl) -> HRESULT {
                                if (FAILED(result)) return result;
                                
                                controller = ctrl;
                                controller->get_CoreWebView2(&webview);
                                
                                // Apply strict privacy settings
                                ICoreWebView2Settings* settings;
                                webview->get_Settings(&settings);
                                settings->put_IsScriptEnabled(TRUE);
                                settings->put_IsWebMessageEnabled(FALSE);
                                settings->put_IsStatusBarEnabled(FALSE);
                                settings->put_AreDefaultContextMenusEnabled(FALSE);
                                settings->put_AreDevToolsEnabled(TRUE); // For local debugging only
                                settings->put_IsPasswordAutosaveEnabled(FALSE);
                                settings->put_IsGeneralAutofillEnabled(FALSE);
                                
                                // Block all external tracking via navigation handler
                                EventRegistrationToken token;
                                webview->add_NavigationStarting(
                                    Callback<ICoreWebView2NavigationStartingEventHandler>(
                                        [this](ICoreWebView2* sender, ICoreWebView2NavigationStartingEventArgs* args) -> HRESULT {
                                            wil::unique_cotaskmem_string uri;
                                            args->get_Uri(&uri);
                                            std::wstring url(uri.get());
                                            
                                            for (const auto& blocked : blocklist) {
                                                if (url.find(blocked) != std::wstring::npos) {
                                                    args->put_Cancel(TRUE);
                                                    return S_OK;
                                                }
                                            }
                                            return S_OK;
                                        }).Get(), &token);

// Set initial blank page with night soft theme
                                webview->Navigate(L"about:blank");
                                InjectNightModeCSS();
                                
                                RECT bounds;
                                GetClientRect(hwnd, &bounds);
                                controller->put_Bounds(bounds);
                                
                                return S_OK;
                            }).Get());
                    return S_OK;
                }).Get());

return SUCCEEDED(hr);
    }

void InjectNightModeCSS() {
        if (!webview) return;
        
        std::wstring css = L"document.documentElement.style.setProperty('--bg', '#0f1219');"
                          L"document.documentElement.style.setProperty('--soft', '#232a37');"
                          L"document.body.style.backgroundColor = '#0f1219';"
                          L"document.body.style.color = '#b4becd';"
                          L"if (document.head) {"
                          L"  var style = document.createElement('style');"
                          L"  style.innerHTML = 'body { background: #0f1219 !important; color: #b4becd !important; } "
                          L"a { color: #7a9cc9 !important; } input, textarea { background: #232a37 !important; color: #b4becd !important; border-color: #3a4555 !important; }';"
                          L"  document.head.appendChild(style);"
                          L"}";
        
        webview->ExecuteScript(css.c_str(), nullptr);
    }

static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
        PrivacyBrowser* browser = reinterpret_cast<PrivacyBrowser*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
        
        switch (msg) {
            case WM_CREATE: {
                LPCREATESTRUCT pcs = reinterpret_cast<LPCREATESTRUCT>(lParam);
                SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pcs->lpCreateParams));
                return 0;
            }
            case WM_SIZE: {
                if (browser && browser->controller) {
                    RECT bounds;
                    GetClientRect(hwnd, &bounds);
                    browser->controller->put_Bounds(bounds);
                }
                return 0;
            }
            case WM_DESTROY:
                PostQuitMessage(0);
                return 0;
            case WM_PAINT: {
                PAINTSTRUCT ps;
                HDC hdc = BeginPaint(hwnd, &ps);
                RECT rect;
                GetClientRect(hwnd, &rect);
                
                // Soft night glow border effect
                HBRUSH softBrush = CreateSolidBrush(NIGHT_SOFT);
                SelectObject(hdc, softBrush);
                Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
                DeleteObject(softBrush);
                
                SetTextColor(hdc, TEXT_COLOR);
                SetBkMode(hdc, TRANSPARENT);
                DrawTextW(hdc, L"ShadowBrowse - Zero Cloud Tracking • All Local", -1, 
                         &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
                EndPaint(hwnd, &ps);
                return 0;
            }
        }
        return DefWindowProcW(hwnd, msg, wParam, lParam);
    }

void Run() {
        MSG msg;
        while (GetMessage(&msg, NULL, 0, 0)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
};

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR, int) {
    // Force high privacy Windows settings
    SetEnvironmentVariableW(L"WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", 
        L"--disable-features=OptimizationHints,InterestFeed,MediaRouter,WebRTC,"
        L"AutofillServerCommunication --disable-sync --no-first-run --disable-background-networking");
    
    PrivacyBrowser browser;
    if (browser.Initialize(hInstance)) {
        browser.Run();
    }
    return 0;
}

Prompt

Please generate a C++ code to create a Windows locally running privacy browser that can block all cloud tracking. The interface has a night soft light mode, suitable for private browsing.

Generator starting settings

Model
Uncensored Code
Mode
chat
View collection

Questions about this prompt

What is this AI code prompt about?

This prompt focuses on “Privacy Focused Local Browser in C++”: Privacy-focused local browser in C++. It is ready to use for code generation on HackAIGC.

How do I use this prompt on HackAIGC?

Open the prompt, tap Use prompt or Copy prompt, then run it with your preferred model and settings.

What approach does this code prompt use?

The brief for “Privacy Focused Local Browser in C++” includes soft cues. Edit the prompt to change the tone, structure, or level of detail.

Can I edit this prompt before generating?

Yes. Copy the prompt text, modify details, then generate again on HackAIGC.