Preface

In agent development, it is often necessary to interact with external web pages. In the DshDesktop desktop shell, directly embedding web pages can be restricted by iframe policies on target sites. The dsh-web-browse plugin adapts to both WebView2 extensions and general browsers, meeting the needs of web page embedding and browser tab management while maintaining consistent operation.

Plugin Introduction

This is a general-purpose web browsing plugin for DSH. It can open web pages as independent tabs in the DshDesktop desktop shell and in general browsers such as Edge/Chrome.

  • Maintainer: sweven-tears
  • Category: Client
  • License: MIT

Core Features

The plugin provides a unified set of web browsing capabilities, including:

  • Sidebar quick entry: The sidebar “🌐 Web Browsing” button. Left-click to open the default URL; right-click to pop up a floating search box.
  • Floating search box: Enter a URL to visit it directly; enter text to search using the selected engine; after confirmation, open in a new tab; close with Esc or by clicking outside the box.
  • Search selected text: In DshDesktop, adds a “🔍 Search Selected Text” item directly below “Copy” in the native context menu; clicking it searches immediately (DshDesktop only).
  • Open in new tab: In DshDesktop, opens as a desktop web tab; in a general browser, opens as a new browser tab.
  • Web page top bar: In DshDesktop, the address/search bar is injected by the WebView2 extension (DshDesktop only).
  • Web browsing settings: Supports configuration of default URL, auto-open on startup, and search engines (built-in + custom). Settings are saved in localStorage.

Architecture Design

The plugin directory structure is as follows:

dsh-web-browse/
├── lib/          harness 插件:侧边栏按钮、悬浮搜索框、「网页浏览设置」(localStorage)
├── extension/    WebView2 扩展(MV3 内容脚本):网页顶部地址/搜索栏(仅 DshDesktop)
├── dsh.plugin.json
├── cordis.patch.yml
└── package.json

lib/ Directory (Harness Plugin)

  • Sidebar button: Calls window.dshDesktop.openWebTab(url) or window.open(url, '_blank').
  • Context menu search: The DshDesktop host adds a “🔍 Search Selected Text” item directly below “Copy” in the WebView2 native context menu. Clicking it opens the floating search box with the selected text.
  • Web browsing settings: In DshDesktop, settings are synchronized to the desktop host via window.dshDesktop.setWebSettings(); in a general browser, this is a no-op.

extension/ Directory (WebView2 Extension)

  • Automatic loading: When DshDesktop starts, it scans the plugins directory of the harness, identifies extension directories containing manifest.json, and loads them.
  • Top bar injection: Injects a fixed top bar into non-harness pages (excluding local settings pages), including back/forward, address bar, and search engine dropdown operations.

Usage

Depending on the runtime environment, the functionality behaves slightly differently.

DshDesktop Environment

  • Sidebar operations: Left-click the sidebar “🌐 Web Browsing” button to open the default web page; right-click the button to pop up the floating search box.
  • Search selected text: Select text in a web page, right-click, and choose “🔍 Search Selected Text.”
  • Top bar operations: Enter a URL or search terms in the top address bar to visit or search.
  • Settings synchronization: Settings are synchronized to the top bars of all web tabs.

General Browsers (Edge / Chrome, etc.)

  • Sidebar operations: Left-click the sidebar button to open the default web page; right-click the button to pop up the floating search box.
  • Top bar and context menu: Without the window.dshDesktop bridge, top bar injection and context menu search are unavailable.
  • Open method: All open operations use window.open(url, '_blank'). Operations not triggered by a user gesture (e.g., auto-open on startup) may be blocked by the browser popup blocker.

Notes

  • Dependency environment: DshDesktop requires a WebView2 Runtime that supports MV3 extensions.
  • General browser limitations: Top bar injection and context menu search cannot be used.
  • Site limitations: Some sites (e.g., Google) may prohibit third-party injection or have anti-crawling restrictions. Top bar buttons may be unavailable; in that case, you can use the sidebar button or tab bar controls.
  • Installation method: The documentation does not provide specific installation commands.