multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.38k stars 424 forks source link

injectBrowserKeyDown injectBrowserKeyUp for YouTube TV #1747

Closed MrSol0 closed 1 year ago

MrSol0 commented 3 years ago

Is your feature request related to a problem? Please describe. Youtube TV has added a feature where you need to click Enter in order to watch a video with resume, however in my TV script, only the person with keys to the house can watch the TV and when Syncing the TV this issue happens as the script triggers a link with resume watch so everyone sees the same thing inside the house or Cinema, and both injectBrowserMouseDown and Up don't work in my case as the only key that works to press yes is Enter

Describe the solution you'd like I want to be able to inject a key pressing for example injectBrowserKeyDown(browser,"Enter") or injectBrowserKeyUp(browser,"Enter")

Describe alternatives you've considered i have tried both injectBrowserMouseDown, InjectBrowserMouseUp, i also tried navigateBrowserForward but it doesn't work.

Additional context dialog

Dutchman101 commented 3 years ago

Such a coincidence.. i've been breaking my head over this today. YouTube/Google really has no idea of what they are doing to certain applications using CEF and such technologies, every time they make some redundant little change.. It's not like you can set up stuff and never look back, it's high maintenance. It will always regularly break.

in this case, it's flagging CEF browser traffic as potentially automated, unusual. "Not a normal web user".

First it happened only to the classic YouTube interface (.com) and using .TV would bypass the dialog. But even more recently (perhaps a week or so?), they added it to .TV as well. Now there is no way to playback without the dialog if you're in CEF.

If we can somehow let MTA automatically submit "Yes", it would be much better, for all servers.

Also, that wouldn't be unusual - keeping YouTube working through all their changes is a pastime for MTA.. examples are e549fec, dd3931e, fa82ee7 so what I meant to say is that through history, MTA team has sort of decided to try and keep YouTube working out of the box.

Back on-topic, and to my intro words "i've been breaking my head over this today" - since I realized that injectBrowser functions weren't going to cut it, i intended to use https://wiki.multitheftauto.com/wiki/ExecuteBrowserJavascript by finding the element (perhaps involving Xpath) which is the "Yes" button in that dialog and crafting auto-submit javascript code. So then you'd have to execute that string every time a player is about to stream a new YT video.

That means it's probably not impossible to work around it with scripting, @MrSol0. But, back to my suggestion to fix it with MTA - how about injecting that javascript string using MTA CEF, so we can keep YouTube working as expected out of the box, the line of action we've already set course to like described.

MrSol0 commented 3 years ago

After checking and testing, i found this solution: local width,height = 854,480 browser:injectMouseMove(width*.851,height*.375) browser:injectMouseUp('left') "The numbers change depending on your browser's dimensions in createBrowser" This works fine for me and solves the issue, i only had to put a 2 second timer before it gets excuted and that solved it. However i still believe this feature to be a great feature.

qaisjp commented 3 years ago

Hacking this to work out of the box seems reasonable to me 👍

AlexTMjugador commented 3 years ago

I agree that we should support this out of the box, but really... I couldn't agree more with @Dutchman101's point about Google making breaking changes like this. It feels like MTA will keep playing a cat and mouse game forever. Would it be possible to get in touch with Google somehow so they stop flagging MTA traffic like "unusual" and potentially related with obscure behaviors?

Woovie commented 3 years ago

No, they don't even trust CEF as a whole, let alone individual CEF projects.

qaisjp commented 3 years ago

I don't think they are specifically flagging MTA traffic. Their YouTube TV service is not intended to be used this way, and I strongly suspect that contacting them could cause problems.

jushar commented 3 years ago

Any idea what conditions need to be met so that the dialog pops up? Perhaps spoofing the useragent is sufficient.

mahlukat5 commented 3 years ago

Im using cinema (cinemaexperience) script.. and i got this error and im changed s-main.lua:16 before: local url = "https://www.youtube.com/tv#/watch?v="..id.."&resume" after: local url = "https://www.youtube.com/embed/"..id.."?modestbranding=1&autohide=1&showinfo=0&controls=0&autoplay=1&volume=0" its working like this.

and you need change c-main.lua:248 like this: loadBrowserURL(Screen,tostring(url).."&start="..atTime)

MrSol0 commented 3 years ago

well this ticket is for https://www.youtube.com/tv#/ not embed, as much as i understand it but i want the original youtube TV view instead of creating a custom one where the player has to insert video id. but thanks

MrSol0 commented 2 years ago

Currently youtube has changed to "Are you watching now?" and i solved it by doing setTimer(function() browser:injectMouseMove(width*0.9,height*0.9) browser:injectMouseUp('left') end,500,1)

moon91210 commented 3 months ago

The account selection screen on YoutubeTV no longer responds to mouse clicks, including the guest button and other buttons on that screen. However, it still responds to arrow keys and the enter key. To make this work, we need to implement the injectKeyDown/Up functions.

Tails (creator of Cinema Experience)