示例网页:
http://m.dianping.com/tuan/deal/moreinfo/11507109
移除该网页的返回按钮, 购买链接, 最底部的友情链接
代码:
NSMutableString *js = [NSMutableString string];
// 删除返回按钮
[js appendString:@"var backBtn = document.getElementsByClassName('back back-gray')[0];"];
[js appendString:@"backBtn.parentNode.removeChild(backBtn);"];
// 删除顶部的购买
[js appendString:@"var box = document.getElementsByClassName('cost-box')[0];"];
[js appendString:@"box.parentNode.removeChild(box);"];
// 删除底部的购买
[js appendString:@"var buyNow = document.getElementsByClassName('buy-now')[0];"];
[js appendString:@"buyNow.parentNode.removeChild(buyNow);"];
// 删除友情链接
[js appendString:@"var footer = document.getElementsByClassName('footer')[0];"];
[js appendString:@"footer.parentNode.removeChild(footer);"];
[webView stringByEvaluatingJavaScriptFromString:js];