iOS access to Safari Reader feature through UIWebView

前端 未结 6 704
梦如初夏
梦如初夏 2020-12-23 18:19

I am using iOS 4.3 & was wondering if there is any way that I can access the Safari\'s \"Reader\" feature through which webpages are removed of ads & other riff raff

6条回答
  •  半阙折子戏
    2020-12-23 18:56

    You can even do this by injecting javascript.

    #define readJS @"(function(){window.baseUrl='https://www.readability.com';window.readabilityToken='';var s=document.createElement('script');s.setAttribute('type','text/javascript');s.setAttribute('charset','UTF-8');s.setAttribute('src',baseUrl+'/bookmarklet/read.js');document.documentElement.appendChild(s);})()"
    

    And then when your webpage finishes loading

    - (void)webViewDidFinishLoad:(UIWebView *)webview
    {
        [webview stringByEvaluatingJavaScriptFromString:readJS];
    

提交回复
热议问题