local tBrowserId
on mouseUp
closeBrowsers
set the httpHeaders to "Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>"
put revBrowserOpen(the windowId of this stack, "http://www.youtube.com") into tBrowserId
if tBrowserId is not an integer then
answer "Failed to open browser"
end if
revbrowserSet tBrowserId, "rect" , the rect of grc "tBrowser"
end mouseUp
on closeBrowsers
local tInstances, tInstance
put revBrowserInstances() into tInstances
repeat for each item tInstance in tInstances
revBrowserClose tInstance
end repeat
end closeBrowsers
any particular reason this dosent work? is there a way to change the headers to get the mobile version of the websites?
EDIT: • useragent - MAC ONLY. If propertyValue is non-empty the browser instance uses that string instead of the default for the User-Agent header transmitted to the web server. If propertyValue is empty the browser instance uses the default user agent string (which is determined by the browser the URL that is being requested).
Found this but it says MAC ONLY...
I would recommend using the new CEF browser as this is the new browsers implementation in LiveCode. I have also adjusted your header to reflect an actual device and then set this via revBrowserSet. This results in the correct mobile page showing. The Mac only useragent clause seem to be due to out of date documentation as I tried the script and it works on both windows and mac. Could you try the following script to see if it works for you.
put revBrowserOpencef(the windowId of this stack) into tBrowserId
if tBrowserId is not an integer then
answer "Failed to open browser"
end if
revbrowserSet tBrowserId, "rect" , the rect of grc "tBrowser"
revBrowserSet tBrowserID, "useragent", "Mozilla/5.0 ;iPhone; CPU iPhone OS 7_1_2 like Mac OS X; AppleWebKit/537.51.2 ;KHTML, like Gecko; Version/7.0 Mobile/11D257 Safari/9537.53"
revBrowserSet tBrowserID, "url", "http://www.youtube.com"
Hey there runrevneil, thank you for your time answering, your code worked as expected and the browser opened mobile version of youtube, only thing is that no videos could be played, while on desktop version of youtube videos are working well. I also get this in debug.log
[1219/055645:ERROR:renderer_main.cc(227)] Running without renderer sandbox
[1219/055646:INFO:CONSOLE(9)] "The key "target-densitydpi" is not supported.", source: http://m.youtube.com/? (9)
[1219/055646:INFO:CONSOLE(0)] "Refused to display 'https://accounts.google.com/ServiceLogi ... ssive=true' in a frame because it set 'X-Frame-Options' to 'DENY'.", source: (0)
after just a little searching i found out that target-densitydpi is no longer used by chrome. is this the case? if it is is there a way to overcome it?
Thank you for your time.
using different user agents gives different results by the way, on some you cant even click the video, on others you click and video stays blank, none of them worked tho.