Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mrl72

macrumors regular
Original poster
Apr 20, 2008
221
19
In order to reduce memory consumption I am investigating using a service like Readability too parse out images etc. from a web view that im showing from within my app. Before I go down the path of using and coding their API I was wondering if there is a way to simply inject their bookmarklet code into the webview. For example, the bookmarklet code they provide when pasted into the address bar after your page has loaded will call their code and render the page in the current path sans images and ads etc. The code you paste in is:

Code:
javascript:(%28function%28%29%7Bwindow.baseUrl%3D%27https%3A//www.readability.com%27%3Bwindow.readabilityToken%3D%27%27%3Bvar%20s%3Ddocument.createElement%28%27script%27%29%3Bs.setAttribute%28%27type%27%2C%27text/javascript%27%29%3Bs.setAttribute%28%27charset%27%2C%27UTF-8%27%29%3Bs.setAttribute%28%27src%27%2CbaseUrl%2B%27/bookmarklet/read.js%27%29%3Bdocument.documentElement.appendChild%28s%29%3B%7D%29%28%29)

So I tried this by using stringByEvalutingJavascriptFromString and inserting the above code AFTER the URL has been passed to the web view but it didnt work. So before I go off down this path is something like this possible anyway?

Cheers.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.