jspenguin2017 / uBlockProtector

An anti-adblock defuser for Nano Adblocker and uBlock Origin
GNU General Public License v3.0
740 stars 83 forks source link

tvn.pl and related #23

Closed MajkiIT closed 7 years ago

MajkiIT commented 7 years ago

Hi, can you help me with this page?

http://dziendobry.tvn.pl/wideo,2064,n/proste-cwiczenia-na-poprawe-krazenia,3193.html

jspenguin2017 commented 7 years ago

Please click here for updates on this issue: https://github.com/X01X012013/AdBlockProtector/issues/23#issuecomment-258627653

MajkiIT commented 7 years ago

@X01X012013 I have modyfication of your script. http://pastebin.com/dMp1HpP8 It works if you choose quality of video. Can you fix it?

https://cloud.githubusercontent.com/assets/18214146/19934802/41ed2640-a118-11e6-960d-3fca4b73ec5a.PNG

jspenguin2017 commented 7 years ago

Hi, I did try to lock that variable before, but that did not seem to work. I did patch your modification into 1.2.6, I'll so further testings to see what is going wrong here.

xxcriticxx commented 7 years ago

@X01X012013 can you do something to suppress the ads from showing on tvn.pl?

jspenguin2017 commented 7 years ago

@MajkiIT I don't think simply locking that variable will work, did I do something wrong? @xxcriticxx The player.js has over 50 thousand lines, and they seem to be constantly checking what's going on with the ads, it will be really hard to patch that script...

MajkiIT commented 7 years ago

@X01X012013 this script is not my. Someone show me it. Also I'm not a programmer. I show you this script, because you will modify it.

xxcriticxx commented 7 years ago

@X01X012013 we got some instructions please read this over see if it make sense

Sadly I don't have enough time now but I looked quickly and the best way to do would be to replace the player file: http://s1-player5.cdntvn.pl/player.js to edit it and remove the addblock checker inside.

After you would have just to make a Userscript to stop the file from being loaded and replace player.js with the fixed player.js that don't check for addblocker.

This would only work with Firefox since it would be done with the checkForBadJavascripts() function. :octocat:

Here's a post that explain how it work to block a script and change it with another: http://stackoverflow.com/questions/10472569/changing-javascript-on-an-html-page-out-of-my-control.

Good Luck and let me know if you are successful, I'm curious to know :smiley_cat:

jspenguin2017 commented 7 years ago

@xxcriticxx All we really need to to put http://s1-player5.cdntvn.pl/player.js into AdBlocker's blacklist, and load the good one from somewhere. The problem here is who want to modify that 50 thousand lines player.js. The stackoverflow post is about in-line JavaScript, which can only be blocked using beforescriptexecute event that is only implemented into FireFox. However, http://s1-player5.cdntvn.pl/player.js is not in-line and can simply be blocked by blocking the source.

xxcriticxx commented 7 years ago

or you can check for checkForBadJavascripts() function whatever that means

jspenguin2017 commented 7 years ago

@xxcriticxx checkForBadJavascripts() function in that post is a custom function and is not built into any browser. It relies on beforescriptexecute event and therefore only work on FireFox, however, none of that is needed to replace player.js. What we need is the patched version of player.js.

jspenguin2017 commented 7 years ago

@xxcriticxx Maybe I'm lazy, but I really don't want to go over 50983 lines of code just to block some pre-rolls until player.js gets updated... Maybe I'll do it later if I feel like it...

xxcriticxx commented 7 years ago

@X01X012013 got it so we have workaround for right now with short 30 sec commercial

jspenguin2017 commented 7 years ago

@xxcriticxx Yep, the rules in the second post from the top will do that, I will remove this website from the script so the rules will work. Would you really call this a workaround when your experience is almost as bad as when you are not using an AdBlocker...

mikhoul commented 7 years ago

@X01X012013 It was my idea to checkForBadJavascripts()since you can change both INLINE or remote JS script with this function with no need for an external blocker. It's more easy to debug IMO when you have everything in the same script. :money_mouth_face:

I was browsing this thread and I agree with you that 50K lines of code is a lot 😜.

But I was thinking if we could use a simple player version with less protection against adblocker maybe it will have only the player part of the code, so it would be lot less code... :octocat:

I said to myself let's try to find an old version of the player.js... so Google is my friend I found something interesting, 2 links:

http://playerjs.io/ https://github.com/embedly/player.js

it would be worth just to try to replacing the big bloated player.js with this one, it could be the original without protection against addblockers. 😊

I'm lot less pro-efficient than you with JS but let me know if it's work, I would install the whole files on host somewhere like https://infinityfree.net, I use them to host my JS scripts when I want them to be remote.

Anyway let me know how it turn ! ✌️

jspenguin2017 commented 7 years ago

@mikhoul checkForBadJavascripts() is great but it only work on FireFox, this project is designed for Opera and Chrome so checkForBadJavascripts() and beforescriptexecute cannot be used. I didn't know there is a project called player.js so I thought *.tvn.pl made player.js themselves. If we start from here it is much simpler, but it is still a LOT of work since *.tvn.pl seems to have customized the player.js that they are using quite a bit. I will first find a way to patch Function.prototype.toString() that might be required to fix timesofindia.indiatimes.com when it breaks again, then I will have a look at this issue.

xxcriticxx commented 7 years ago

sound like fun

jspenguin2017 commented 7 years ago

@mikhoul Is that hosting service stable? Every single free dynamic website hosting service I tried is rather useless. I'm currently hosting everything on GitHub.

mikhoul commented 7 years ago

@X01X012013

Is that hosting service stable?

It seem really stable, before using this service I tried over the years 5-6 other "free" hosting service but all had to much limitations for me like: To keep your account you must log-in once a month or your account was deleted, or no support for PHP etc... :computer:

The only limitation I've seen from this one is the upload speed to prevent the sharing of Software/movies etc.. but it's enough for me. It support PHP, FTP and with FTP I use it with WinSCP so I can edit and save my file directly in Notepad++ and everything is updated in real time. :smile_cat:

I use it since a few months and everything is fine till today, the support is VERY good for a free service you got answer within few hours and it's quality support. :octocat:

Have a Great Day :sun_behind_small_cloud:

jspenguin2017 commented 7 years ago

@mikhoul The player.js from your links only have 1187 lines of code... Did I miss something?

mikhoul commented 7 years ago

@X01X012013 No I was surprised myself too but from what I've read it seem that "player.js" is a kind of standard between websites, so the code added seem just to be for advertisement/adblocker.

Even if it was not the same exactly I was telling to myself maybe it would be worth to replace the player completely and connect the new "clean" player directly to the stream of the video.

This way we could bypass the Evil... 😈

xxcriticxx commented 7 years ago

they added 49k lines of code to it wow

jspenguin2017 commented 7 years ago

@mikhoul Their script calls video.player5 to initialize the video, which is not defined in player.js, could it be from some other libraries? Like video.js that has 24471 lines of code? However, video.player5 is not defined in video.js neither...

xxcriticxx commented 7 years ago

different version?

jspenguin2017 commented 7 years ago

@xxcriticxx No, I don't think so, it's most likely that they made the script themselves from scratch.

xxcriticxx commented 7 years ago

@X01X012013 tvn is big company am sure they have some money

jspenguin2017 commented 7 years ago

@xxcriticxx If they are big, then it is likely someone already developed a patch...

mikhoul commented 7 years ago

@X01X012013 Ok I studied/digged a little bit more the "logic" of the code as a whole and I found the the player is spread around 2 main files at least:
GitHub Logo

The player had multiple options inside the code do all kind of things other than playing video... so since I'm not really pro-efficient in JS it's hard for me understand but even if I was good at JS it is REALLY big and rely a lot on external frameworks.

The good news: I found a relatively easy way to bypass the player and skip the all advertisements. 😺

Each HTML page content has the direct link to the video with the token to be able to see the video.

It's easy to find, all their videos are in .MP4 so you just search for data-src= and next to it you have the URL with the token like: http://r.dcs.redcdn.pl/http/o2/tvn/web-content/m/v/7c9d0b1f96aebd7b5eca8c3edaa19ebb/3340c46c-cfb8-11e0-9d8d-0025b511229e-360p.mp4?salt=FD976E7AB898CE93B2DFBBCBE8E51BE7&token=739769450ACE67F2B4D9C01F7486A2E18FAF6D5A9BF08702AEF5C384083248DC34F5DBAEE2FF96EBA060C7DF50274109D7A1D6D8EDD8583CFDDA90F43BBE69314248ED196908B3C4C7048A39C1EEFCB0D3C5E8456EF4192BA3FC09964A1E7DD5299106B675CC3EBA5747E50F06A49C8D608369468400CB79FBD8FDFF09A7D3C3

GitHub Logo

Videos are always on hosted on: http://r.dcs.redcdn.pl

The logic is simple:

  1. Stop the 2 big scripts for the video player from being loaded.
  2. Scrap the web page for the URL of the video via data-src=
  3. Inject the new inline HTML/CSS/JS with the URL for the new Video Player in the web page

That's it ! πŸ˜„

✨Here's a JsBin prototype I've setup with an easy and light JS Video player with all the player code: πŸ’« http://jsbin.com/vigare/edit?html,output πŸ’«

Just copy and paste all the scripts are hosted on CDN.

This way nobody should have to care about future change in the code fromvideo player. 😜 You could even use this code after for any problematic video player that display ads.

Let me know how it turn :octocat:

xxcriticxx commented 7 years ago

@mikhoul nice job! you went bit crazy with the emojis :laughing:

xxcriticxx commented 7 years ago

@mikhoul can you check other tvn websites?

http://www.tvn.pl/ http://www.tvn7.pl/ http://www.tvnstyle.pl/ http://www.tvnturbo.pl/ http://tvnfabula.pl/ http://u.itvn.pl/ http://itvnextra.pl/ http://www.tvn24.pl/ http://tvnwarszawa.tvn24.pl/ http://tvn24bis.pl/ http://tvnmeteo.tvn24.pl/ http://tvnmeteoactive.tvn24.pl/ http://ttv.pl/ http://player.pl/ http://kulinarni.tvn.pl/ http://kontakt24.tvn24.pl/ http://x-news.pl/login

jspenguin2017 commented 7 years ago

@mikhoul WOW thanks a lot, I'll try this out. I knew I wasn't searching at the right place for the key... @xxcriticxx I'll have a look... But first let's make the first one working.

jspenguin2017 commented 7 years ago

GOOD NEWS! This website is fixed in 1.2.16! Thanks to @mikhoul for your precious help!

onEvent("load", function () {
    $(".videoPlayer").parent().after($("<iframe width='100%' height='500'>").attr("src", $(".videoPlayer").data("src"))).remove();
});
jspenguin2017 commented 7 years ago

TVN websites [Script]: It may take a few seconds to replace the player.

.tvn.pl .tvnstyle.pl *.tvnturbo.pl

TVN home pages [List]: Since videos on the home pages are previews or teasers, we simply removed the block screen, the actual video will not be working. This may change in the future.

http://www.tvn.pl/ http://www.tvn7.pl/ http://www.tvnstyle.pl/ http://www.tvnturbo.pl/

Other TVN websites and home pages are currently not blocking AdBlockers, let me know if anything changes.

mikhoul commented 7 years ago

@mikhoul can you check other tvn websites? @X01X012013 @xxcriticxx

Yes it will work on all their websites since they use the same scheme for the structure of the HTML pages.

Some videos don't have TOKENS just a plain URL so IMO it's more simple to play all videos in "our" player than parsing the videos to see if they have or not Tokens. :octocat:

:smile_cat:

jspenguin2017 commented 7 years ago

@mikhoul (Updated) The home page is one structure and inside is another, we need to filter both separately.

xxcriticxx commented 7 years ago

@X01X012013

http://www.tvnturbo.pl/aktualnosci,1850,n/najwiekszy-statek-pasazerski-i-najdluzszy-serial,216184.html http://www.tvnturbo.pl/aktualnosci,1850,n/jak-rozwinac-skrzydla-w-bialymstoku,211664.html

xxcriticxx commented 7 years ago

@X01X012013

http://www.tvnstyle.pl/aktualnosci,1865,n/rusza-casting-do-programu-sekrety-lekarzy,181940.html http://www.tvnstyle.pl/aktualnosci,1865,n/paulina-krupinska-chciala-zjesc-w-peru-swinke-morska,215964.html

jspenguin2017 commented 7 years ago

@xxcriticxx Hi, both are fixed in 1.2.18. I'm still working on home pages.

mikhoul commented 7 years ago

@X01X012013 I tried your userscript but it did not work and pretty sure I miss some part of the "software" since I don't see the code injected in the page for the new player ? 😳

I looked at 3 other pages and they all have the same structure/format !

I will try again to explain more clearly how I see the pseudo-code for the workaround, it was late last night maybe I had some fog in my mind 😏

I found those 2 scripts that seem to have already some useful function inside that could be used: https://greasyfork.org/en/scripts/8684-change-video-player-for-vkmag/code https://greasyfork.org/en/scripts/14476-yahvt/code

Here's one of the video without token (not protected) http://n-4-1.dcs.redcdn.pl/dcs/o2/tvn/web-content/m/p1/v/89f03f7d02720160f1b04cf5b27f5ccb/30e920f0-f54d-408b-aa68-77024404967f-720p.mp4

Another one with a token (protected): http://n-0-19.dcs.redcdn.pl/dcs/o2/tvn/web-content/m/p36/v/10c272d06794d3e5785d5e7c5356e9ff/2481247f-ec55-44d1-badd-561c1b079702-480p.mp4?salt=E0A373C22D9C39475F03B53E7D003C83&token=4D920D80DA86424EF7E16EBAE292147BA1B3FE47C1068F92BB1B6621FF34E7AE71355900D4999B8B22B8DD59BB5E74523F9B59A0D3A560A3E92E9D560067616DD65CB4D19ABC2AE435F2F60D73F52854DB46A539005332EC2F0F0253FB6EB2FD248478CCDF28D104FE8F569A8BB0EDE30087E13BDFDAE5A045B949DF639499D8926B8339BD2BF57ABF863A2862324602

Let me know what you think about it, if it is more clear... 🐸

jspenguin2017 commented 7 years ago

@mikhoul I am using Array.prototype.includes to filter domain, which browser are you using? I tested on Chorme and Opera, it works just fine. I used $(".videoPlayer").data("src") to grab the source and $(".videoPlayer").parent().after(...); to inject the iframe. The new player will be the built-in player of the browser. When we remove the player, we remove its parent with it, otherwise the wrapper will still occupy the space on the screen. Note that the script will run when the page is fully loaded, which mean you will see the block screen for a few seconds. Home pages are still work in progress. screenshot

Thank you for your help πŸ˜„

jspenguin2017 commented 7 years ago

@mikhoul Any clue on how to get started on fixing their home pages?

xxcriticxx commented 7 years ago

user script?

xxcriticxx commented 7 years ago

@X01X012013 why did you change title of this post?

mikhoul commented 7 years ago

@X01X012013 I use Firefox mainly, I was not knowing what Array.prototype.includes was doing lol πŸ™€ After reading quickly at Javascript MDN I understand a little bit more. I will have to follow a basic course in JS to fully understand the basic of JS and I will lose less time than trying to figure all the things by myself.

Firefox can handle fine HTML5 video like Chrome but both don't have fullscreen option and don't handle well the different screensize for the video depending on their original encoding.

Since they are TV show/news to said to myself that the user like me like to see their TV show in full resolution with a better Video player. That's why I tested the MediaElement video player on both Firefox and Chrome to be sure it handle well the different format of screen and also Fullscreen.

I understand it's a little bit more complicated to integrate a new video player than using the builtin but once the code is done it's for all videos for the next years... 😏

If you wrote the code with the way I see it the only thing to change in the future for any other websites would be the REGEX for the URL and the name of the DIV to replace the video player. So on the long run it could make the things more easy to maintain and reuse the same code for other websites.

😊

mikhoul commented 7 years ago

@mikhoul Any clue on how to get started on fixing their home pages?

@X01X012013 Sorry I did not see this post.

Could you give me the URL of the homepage I'm not sure of which homepage we are talking about ?

I will take a look but I'm pretty confident that if we use a REGEX to find the URL with the conditions mentioned in my previous post it will work on any page of TVN. Also the div .videoPlayer to remove the player is always the same on everypage with a player so that's why I would use REGEX and only delete the same DIV to replace it with "our player".

It's alittle bit more coding but once it is done it will work on every pages of all those TVN domains. πŸ“Ί

:octocat:

jspenguin2017 commented 7 years ago

@xxcriticxx Since this post is about all TVN websites, I thought this would be a clearer title.

@mikhoul You are right, making it a library function will make patching other websites easier, but I still don't see the point of using RegExp to find URL when you can just use $(...).data(...) which is much more efficient and easier. For home page, I tried to do the same but the structure is quite different and we need to figure out a new place to inject the video. http://www.tvn.pl/ screenshot

mikhoul commented 7 years ago

@X01X012013 I will look at the code deeper tonight and come back later, in meantime double-check with your scripts it prevent to use this fiddle: http://jsfiddle.net/N8Zs5/18/#run 😊

jspenguin2017 commented 7 years ago

@mikhoul What do you mean by "prevent to use this fiddle"? That fiddle behave the same with or without AdBlock Protector enabled.

mikhoul commented 7 years ago

@X01X012013

What do you mean by "prevent to use this fiddle"? That fiddle behave the same with or without AdBlock Protector enabled.

Try under Firefox: http://screencast-o-matic.com/watch/cDX1nijL6r 😺

I still don't see the point of using RegExp to find URL when you can just use $(...).data(...) which is much more efficient and easier.

Use the method that you think will be the more easy to maintain in the future and the less prone to break later. It's hard for me to tell since I don't understand fully how work Array.prototype.includes .

For the main/home page: http://www.tvn.pl/ they are only small video previews/advertisements/teasers for the TV show, not real episodes. So I would just remove the overlay with simple filter like www.tvn.pl###_videoDriverContent4 (1-2-3-4-5-6-7-8 depending on how much preview they have.).

If they want to see the show they click on the link beside and it bring them to the portal of the show where the full episodes of the show are. Also on all those page it's the same layout.

IMO it would be to much work to try to fix the video players on the main page since they are only short advertisements/teasers to bring users to listen the full episodes with the links.

Maybe we can borrow this? https://github.com/reek/anti-adblock-killer/blob/master/anti-adblock-killer.user.js#L1040

I took a look a the code, most of the code seem to be for flash video which is less and less used today, it seem to have many many fallback in case one video player won't work.

IMO we don't need such fallback the best is to keep it simple, last night I tried numerous video players to see how they work, what advantage they have, the compatibility, from my test MediaElement video player has given the best results for simplicity and compatibility for what we need. Other video players have lot more features (like overlay inside, hidden link, ,Skins, tracking of the users etc etc) but features we will not use here. Also video element is actively maintained.

If you are able to make your own small JS library Video player it will be more easy in the future than rely on REEK script that will become obsolete the more the time pass. Also you if something change or the need change in the future it will be more easy if it is your own code to understand.

But you can look for inspiration if you see good ideas, concept use it no need to reinvent the wheel each time. 😏

Soon I will try to debug Slacker 🎡 completely with a more permanent option and will let you know of my solution and if you want to integrate it in your script.

Have a good night πŸŒ›

jspenguin2017 commented 7 years ago

@mikhoul Sorry, currently, I do not offer support for FireFox, the link works fine on Chrome and Opera. Every website will have different way of storing the "token", it will be case by case, but for TVN, use jQuery's data(...) is the best way to go. I use Array.prototype.includes to see if the domain is in a list, it is supported by both Chrome and Opera. It can cause issues on Edge, but no one uses Edge anyway.

There is another issue that we are facing, that is Content Security Policy, it prevents external and in-line scripts from being injected on the fly, I believe it does not affect iframe, but then we will have issues determining how high the iframe needs to be.

To make delivering rules easier, I created AdBlock Protector List πŸ˜„

Again, thank you for your time and effort πŸ‘

MajkiIT commented 7 years ago

Latest version block films on youtube.