Add wxWebView::AddUserScript()

This allows to inject javascript code across multiple pages
This commit is contained in:
Tobias Taschner
2021-02-26 22:52:11 +01:00
committed by Tobias Taschner
parent f2bfa7d446
commit 6f7ac6a934
3 changed files with 74 additions and 0 deletions

View File

@@ -107,6 +107,19 @@ enum wxWebViewNavigationActionFlags
wxWEBVIEW_NAV_ACTION_OTHER
};
/**
Specifies at which place of documents an user script will be inserted.
@since 3.1.5
*/
enum wxWebViewUserScriptInjectionTime
{
/** Insert the code of the user script at the beginning of loaded documents. */
wxWEBVIEW_INJECT_AT_DOCUMENT_START,
/** Insert the code of the user script at the end of the loaded documents. */
wxWEBVIEW_INJECT_AT_DOCUMENT_END
};
/**
Internet Explorer emulation modes for wxWebViewIE.
@@ -737,6 +750,33 @@ public:
*/
virtual bool RemoveScriptMessageHandler(const wxString& name);
/**
Injects the specified script into the webpages content.
@param javascript The java script code to add
@param injectionTime Specifies when the script could will be
executed.
@return Returns true if the script was added successfully
@note Please not that this is unsupported by the IE backend and
the Edge (Chromium) backend does only support wxWEBVIEW_INJECT_AT_DOCUMENT_START.
@see RemoveAllUserScripts()
@since 3.1.5
*/
virtual bool AddUserScript(const wxString& javascript,
wxWebViewUserScriptInjectionTime injectionTime = wxWEBVIEW_INJECT_AT_DOCUMENT_START);
/**
Removes all user scripts from the web view.
@see AddUserScript()
@since 3.1.5
*/
virtual void RemoveAllUserScripts();
/**
@name Clipboard
*/