Untitled
unknown
plain_text
8 months ago
1.4 kB
5
Indexable
// Override console methods
const originalConsole = console;
console = {
log: function (...args) {
originalConsole.log(...args);
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: "log",
data: args.map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : String(arg))),
}),
);
},
warn: function (...args) {
originalConsole.warn(...args);
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: "warn",
data: args.map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : String(arg))),
}),
);
},
error: function (...args) {
originalConsole.error(...args);
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: "error",
data: args.map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : String(arg))),
}),
);
},
info: function (...args) {
originalConsole.info(...args);
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: "info",
data: args.map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : String(arg))),
}),
);
},
debug: function (...args) {
originalConsole.debug(...args);
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: "debug",
data: args.map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : String(arg))),
}),
);
},
};Editor is loading...
Leave a Comment