Skip to content

Instantly share code, notes, and snippets.

@pachun
Created June 13, 2023 21:04
Show Gist options
  • Save pachun/8f6e6ae87fb68b6906aa35f89bcaab21 to your computer and use it in GitHub Desktop.
Save pachun/8f6e6ae87fb68b6906aa35f89bcaab21 to your computer and use it in GitHub Desktop.
const injectedJavascript = [
"setTimeout(function() {",
" const metaTag = document.createElement('meta');",
" metaTag.setAttribute('name', 'viewport');",
" metaTag.setAttribute('content', 'width=device-width, initial-scale=1');",
" document.getElementsByTagName('head')[0].appendChild(metaTag);",
" setTimeout(function() {",
" const documentSize = { displayedMessageContentHeight: document.body.scrollHeight };",
" const serializedDocumentSize = JSON.stringify(documentSize);",
" window.ReactNativeWebView.postMessage(serializedDocumentSize);",
" }, 50);",
"}, 50);",
].join("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment