Prevent Google Adsense Ads to appear in react native webview

Viewed 267

I'm working on a mobile app with react native. I've implemented a webview with the "react-native-webview" package. Everything is working fine but google ads are appearing even in webview. As far as I know, google ad should not appear on mobile apps and that's why I wanna remove them from webview. Iinspected the page and found that ads are using "ins" tags so i tried to use injectJavascript prop like this -

<WebView
      style={globalStyles.container}
      source={{ uri: websiteUrl }}
      onError={(error) => console.log(error)}
      injectJavascript={`
      var ad = document.querySelectorAll("ins");
      ad.remove();
      `}
    />

But it didn't work. Do you have any idea how to remove google ads in webview ? OR Can you help me how can I identify if any webview is sending request to website so that I'll show ads conditionally

0 Answers
Related