35 lines
875 B
TypeScript
35 lines
875 B
TypeScript
// app/webview.tsx
|
|
import React, { useRef } from 'react';
|
|
import { WebView } from 'react-native-webview';
|
|
|
|
const WebViewScreen = () => {
|
|
const webviewRef = useRef(null);
|
|
|
|
const injectedJavaScript = `
|
|
const filterPosts = () => {
|
|
const posts = document.querySelectorAll('div[data-testid="post_message"]');
|
|
posts.forEach(post => {
|
|
if (post.innerText.includes('some keyword')) {
|
|
post.style.display = 'none'; // Hide post
|
|
}
|
|
});
|
|
};
|
|
filterPosts();
|
|
`;
|
|
|
|
return (
|
|
<WebView
|
|
ref={webviewRef}
|
|
source={{ uri: 'https://www.facebook.com' }}
|
|
injectedJavaScript={injectedJavaScript}
|
|
startInLoadingState={true}
|
|
onLoadEnd={() => {
|
|
if (webviewRef.current) {
|
|
webviewRef.current.injectJavaScript(injectedJavaScript);
|
|
}
|
|
}}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default WebViewScreen;
|