@mikael See here if only one tab and if I correctly understand the request 😀
from objc_util import *
# open tab with url, then swipe to right and run this script
@on_main_thread
def searchTabURL():
win = ObjCClass('UIApplication').sharedApplication().keyWindow()
main_view = win.rootViewController().view()
ret = ''
def analyze(v,indent):
ret = None
for sv in v.subviews():
#print(indent,sv._get_objc_classname())
if 'UIWebBrowserView' in str(sv._get_objc_classname()):
return sv.webView().mainFrameURL()
ret = analyze(sv,indent+' ')
if ret:
return ret
ret = analyze(main_view,'')
return ret
if __name__ == "__main__":
url = searchTabURL()
print(url)