Live data from Hacker News

Comcast injecting JS

gist.github.com

211–220 of 288 posts

Re: Comcast injecting JS

#211
I live in France and I'm a customer of Orange. I was really surprised to see on my mobile, on Facebook (m.facebook.com - I've noticed it only there, but perhaps there are more pages like that) they're injecting a HTML with "Return to Orange World" link in the footer directing to orange.fr. Not sure if anything more though - I have a plain old mobile with Opera Mini.

I'm curious if they have some deal with FB to do it.

Re: Comcast injecting JS

#212

Earlier quoted context omitted.

The block of code they injected here was 7.9 KB (3.7 KB gzipped). jQuery is 93 KB (33 KB gzipped). So no, I don't think that would have been more elegant. Injecting anything into users' pages without permission is insane. Injecting a huge library like jQuery would be even more insane.

As long as you're already injecting something, why not go all the way?

Wasted resources. The difference in size between the two (using the numbers from the above comment) is 85.1 KB. Now think of all the customers Comcast has and you will see quickly the difference it makes with a few KB.

Re: Comcast injecting JS

#213

Earlier quoted context omitted.

T-Mobile is currently doing this and does not allow for opt-out.

I'm pretty sure you can forcefully opt out by using a DNS server that isn't run by scumbags, like 8.8.8.8 and 8.8.4.4 for Google Public DNS. I hear OpenDNS is similarly good.

OpenDNS does the same thing these people are complaining about -- they wrap the missing domain in something like a search page that has their logo and custom ads on it.

Re: Comcast injecting JS

#215

Earlier quoted context omitted.

Comcast can just as easily MITM your SSL connections, for your safety of course. But that ridiculous, right? Since everyone verifies SSL cert signatures...

They would either need the private key of the certificate holder (which they don't have), or a certificate signed by one of the roots installed on the system, which they also won't have. I suppose the logical next step is that Comcast requires you to install a "Comcast Internet Helper" program that also installs a Comcast root certificate into the system so they can mitm anything.. But Firefox and Chrome would probab…

Most people are going to click through any security warning because they just want to get to the site they wanted to go to. If Comcast does this, it would make EVERY SSL site display the warning, making it utterly meaningless.

Alternatively, it's not that outrageous to think that Comcast et al could get certs into the major browsers if they wanted to do so. It's not even implausible to think that at some point, browsers will be legally required to distribute ISP certs to allow for the "safety" of users.

If Comcast makes you install a custom application to keep your certs up, it won't matter if Fx and Chrome block each cert within hours, because Comcast can keep generating and pushing new ones out. And, as above, if the ISP is going to fiddle like this, the actual power held by browsers is greatly diminished -- users aren't going to use a browser that doesn't let them browse without nag screens on every page, even if it is "for their own good".

Re: Comcast injecting JS

#216

Earlier quoted context omitted.

right tool for the right job. a 1 page script written for comcast does not demand jQuery. That's not to say it would have improved it.

It at least would remove this damn ugly browser switching code. Hey, it's 2013, no need to reinvent the wheel...

You're missing the point. You're too focused on the code writing part. It's the extra unnecessary resources loaded from jQuery.

The difference in size is 85.1 KB (according to an above post). 85.1 KB * 100,000,000 (Just an example of the number of times it is loaded) = 7.92555511 terabytes of wastes resources.

Re: Comcast injecting JS

#217
post #177

Earlier quoted context omitted.

Oh, it's just awful. It's worse than just "not knowing JavaScript." This is code from someone who has no idea how to program : function Browser() { var ua, s, i; this.isIE = false; this.isNS = false; this.version = null; ua = navigator.userAgent; s = "MSIE"; if ((i = ua.indexOf(s)) >= 1) { this.isIE = true; this.version = parseFloat(ua.substr(i + s.length)); return; } s = "Netscape6/"; if ((i = ua.indexOf(s)) >= 0) {…

> This is code from someone who has no idea how to program That's a quite strong assertion. What's wrong with your first example? I can think of very few criticisms (s isn't needed for example) but there's lots of things they did well: - It follows the best practices for an OO constructor (doesn't return the object, just sets properties of `this`) - All temporary variables are local. No global pollution (besides the…

I was foaming at the mouth a bit, wasn't I?

All your points are well taken, and a better analysis of the code by far than my hasty reaction.

So what was bothering me about the first example? Probably the repetition of the indexOf() tests, combined with one of the indexOf() tests being >= 1 and the rest >= 0.

But you're right, it's not nearly as bad as I made it out to be.

Since I've put my foot in my mouth, I guess I'll put my money there too and show how I might have done it. If I were doing UA detection at all, that is:

    function Browser() {
        function is( ua, result ) {
            var start = navigator.userAgent.indexOf( ua );
            if( start 
But that fails on one of your points, since it returns an object instead of setting properties of 'this'. It's also less flexible - what if one of the tests needed more than a simple string comparison? At least it's simpler?

So who am I to criticize? :-)

On the second example, it's not just that function - the entire web page is full of similar code. Here's another snippet:

    addressCheckMsg="";
    if(!type)
    {
        iLen = line1.value.length;
        for(i=0; (i
Yikes. I'd better not say more or I'll start foaming again... :-)

Re: Comcast injecting JS

#218
post #177

Earlier quoted context omitted.

> This is code from someone who has no idea how to program That's a quite strong assertion. What's wrong with your first example? I can think of very few criticisms (s isn't needed for example) but there's lots of things they did well: - It follows the best practices for an OO constructor (doesn't return the object, just sets properties of `this`) - All temporary variables are local. No global pollution (besides the…

actually in this code, "this" refers to the window object. it means it's same as window.version.

I thought that for a moment, but it isn't so. They do call the Browser() function as a constructor with 'new Browser()', so 'this' is the object it's constructing.

Re: Comcast injecting JS

#219

Earlier quoted context omitted.

They would either need the private key of the certificate holder (which they don't have), or a certificate signed by one of the roots installed on the system, which they also won't have. I suppose the logical next step is that Comcast requires you to install a "Comcast Internet Helper" program that also installs a Comcast root certificate into the system so they can mitm anything.. But Firefox and Chrome would probab…

Most people are going to click through any security warning because they just want to get to the site they wanted to go to. If Comcast does this, it would make EVERY SSL site display the warning, making it utterly meaningless. Alternatively, it's not that outrageous to think that Comcast et al could get certs into the major browsers if they wanted to do so. It's not even implausible to think that at some point, brows…

I think you're a bit out of touch as those browser warning pages have changed a lot the last few years. It's actually pretty hard to get through those warnings now in most of the browsers.

Re: Comcast injecting JS

#220
post #35

This code is beyond awful - it fails to display, makes endless AJAX requests, and more; here are a few fun tidbits: 1. The code is not encapsulated in an IIFE, so it clobbers any global variables (like 'image_url') in the page, breaking any scripts relying on those variables. 2. The code spends an inordinate time checking if you're running Netscape Navigator 6. 3. Strangely, they include a whole bunch of code allowin…

I wondered why I was seeing `checkBulletin()` in my logs.
Post reply on HN