diff --git a/obs-browser-plugin.cpp b/obs-browser-plugin.cpp index 95a168c6b..3cf6095cd 100644 --- a/obs-browser-plugin.cpp +++ b/obs-browser-plugin.cpp @@ -224,6 +224,15 @@ static obs_properties_t *browser_source_get_properties(void *data) return false; }, bs); +#if CHROME_VERSION_BUILD > 6533 || defined(__APPLE__) || defined(_WIN32) + obs_properties_add_button2( + props, "inspect", obs_module_text("Inspect"), + [](obs_properties_t *, obs_property_t *, void *data) { + static_cast(data)->Inspect(); + return false; + }, + bs); +#endif return props; } diff --git a/obs-browser-source.cpp b/obs-browser-source.cpp index 964e25999..c48440cb2 100644 --- a/obs-browser-source.cpp +++ b/obs-browser-source.cpp @@ -427,6 +427,19 @@ void BrowserSource::Refresh() ExecuteOnBrowser([](CefRefPtr cefBrowser) { cefBrowser->ReloadIgnoreCache(); }, true); } +void BrowserSource::Inspect() +{ + ExecuteOnBrowser( + [](CefRefPtr cefBrowser) { + CefWindowInfo windowInfo; + windowInfo.bounds.width = 900; + windowInfo.bounds.height = 700; + CefRefPtr host = cefBrowser->GetHost(); + host->ShowDevTools(windowInfo, host->GetClient(), CefBrowserSettings(), {}); + }, + true); +} + void BrowserSource::SetBrowser(CefRefPtr b) { std::lock_guard auto_lock(lockBrowser); diff --git a/obs-browser-source.hpp b/obs-browser-source.hpp index 5bf26b5ce..59b247cdd 100644 --- a/obs-browser-source.hpp +++ b/obs-browser-source.hpp @@ -125,6 +125,7 @@ struct BrowserSource { void SetShowing(bool showing); void SetActive(bool active); void Refresh(); + void Inspect(); #if defined(BROWSER_EXTERNAL_BEGIN_FRAME_ENABLED) && defined(ENABLE_BROWSER_SHARED_TEXTURE) inline void SignalBeginFrame();