之前玩的一个高级网页转应用APP的笔记
print"功能菜单"
items={}
table.insert(items,"去广告UA")
AlertDialog.Builder(this)
.setTitle("功能菜单")
.setItems(items,{onClick=function(l,v)
if items[v+1]=="去广告UA" then
pop=PopupMenu(activity,view)
menu=pop.Menu
menu.add("万能").onMenuItemClick=function()
webView.settings.setUserAgentString("Mozilla/5.0 Dalvik/2 ( Linux; U; NEM-AL10 Build/HONORNEM-AL10;Youku;7.1.4;) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Safari/537.36 (Baidu; P1 6.0) iPhone/7.1 Android/8.0 baiduboxapp/2.7.0.10")
webView.reload()
end
menu.add("安卓").onMenuItemClick=function()
webView.settings.setUserAgentString("mixiaBrowser/Mozilla/5.0 (Linux; U; Android 7.1.2; zh-cn; Redmi 5 Plus Build/N2G47H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 Mobile Safari/537.36")
webView.reload()
end
menu.add("苹果").onMenuItemClick=function()
webView.settings.setUserAgentString("Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7")
webView.reload()
end
menu.add("塞班").onMenuItemClick=function()
webView.settings.setUserAgentString("Mozilla/5.0 (Symbian/3; Series60/5.2 NokiaN8-00/012.002; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/533.4 (KHTML,like Gecko) NokiaBrowser/7.3.0 Mobile Safari/533.4 3gpp-gba")
webView.reload()
end
pop.show()--显示
end
end})
.show()
网友评论