
I challenge you to remove the gray ad using Adblock - ryanskidmore
https://0x1b.pw/adblock/
======
otterley
This is a pointless challenge, because it has none of the characteristics of
an actual ad.

For tracking, security, and analytics reasons, ad providers almost always
originate ads from a separate domain than the content provider's.

~~~
ryanskidmore
Correct, it isn't supposed to be used with ad providers that Adblock may (or
may not) already block, it's supposed to work with internal ads that would
come from the same domain as the content providers.

~~~
otterley
Who does that, though? Even the big content providers that have their own ad
platforms (e.g. Yahoo!) serve ads from separate domains.

------
mark242

      var removeGrayImage = function() {
    	$("img").each(function(idx, el) {
    		var canvas = $("<canvas/>")[0];
    		canvas.width = el.width;
    		canvas.height = el.height;
    		canvas.getContext("2d").drawImage(el, 0, 0, el.width, el.height);
    		var pixel = canvas.getContext("2d").getImageData(1, 1, 1, 1);
    		var r = pixel.data[0];
    		var g = pixel.data[1];
    		var b = pixel.data[2];
    		if(r == 183 && g == 183 && b == 183) {
    			$(el).css({opacity: 0});
    		}
    	});
      };

~~~
lukegb
Damn, you went for the same solution as me. I didn't think anyone else would
so obtuse as to use a canvas to access the raw image data.

Here's my equivalent solution:

    
    
      var canvas = document.createElement('canvas');
      canvas.height = 1;
      canvas.width = 1;
      var twodctx = canvas.getContext('2d');
      var blockImg = null;
      var qs = document.querySelectorAll('img');
      for (var i = 0; i < qs.length; i++) {
        var img = qs[i];
        twodctx.drawImage(img, 0, 0, 1, 1);
        var imgd = twodctx.getImageData(0,0,1,1);
        if (imgd.data[0] == imgd.data[1] && imgd.data[0] == imgd.data[2] && imgd.data[3] == 255) {
          var badDiv = document.createElement('div');
          badDiv.style.display = 'none';
          document.body.appendChild(badDiv);
          badDiv.appendChild(img.parentNode.removeChild(img));
          break;
        }
      }

------
themstheones
Why would you even want to block ad blocking? That's like trying to control
what someone else can do with their computer. It seems really unethical.

------
just2n
It still has a style that the other image doesn't:

    
    
        style="height: 250px; width: 250px;"
    

After that, other than positionally blocking them, there's nothing that can be
done short of visually inspecting the element.

You could modify the script to randomly place the ad either first or second,
so you don't need the third <img> tag with no src.

What is the goal of this experiment?

~~~
300bps
_What is the goal of this experiment?_

I'm guessing intern at an ad network pitches he can come up with an
"unblockable ad" to his boss.

Boss wants to go home for the holiday weekend so he says, "OK, whatever kid"
as he's walking out the door just after lunch.

Intern signs up with a one-hour old HN account and posts his masterpiece here
and starts playing whack-a-mole with the dozens of methods to trivially block
the "unblockable ad".

After a couple hours, everyone gets bored and goes back to work. The intern
frets and worries all weekend that he promised his boss an unblockable ad and
won't be able to deliver on Tuesday when everyone is back in the office. Come
Tuesday, he goes into the office, sweating and nervous to discover his boss
wasn't in the slightest bit paying attention to whatever it was he was saying
last Friday.

~~~
ryanskidmore
Thats a nice story, but unfortunately not the truth. This was simply a spur of
the moment idea and I wanted to see if it worked, which to a relative degree
it did, hence why I posted it. The main goal of posting it is to show how easy
it would be for a website to show ads to a user, even with an extension such
as Adblock enabled. In regards to the account, I haven't had a need for a HN
account before now.

Sorry if you didn't like it.

------
someone13
Probably trivial to fix, but:

    
    
        var found = false;
        $('img').each(function(i, elem) {
            var e = $(elem);
            if( e.attr('src') !== '' && !found ) {
                e.attr("style","opacity:0.0;");
                found = true;
            }
        });

------
pothibo
$("div > img:nth-child(2)").get(0).src = "[http://dev.w3.org/2007/mobileok-
ref/test/data/ROOT/GraphicsF...](http://dev.w3.org/2007/mobileok-
ref/test/data/ROOT/GraphicsForSpacingTest/1/largeTransparent.gif";)

Victory?

------
betterunix
The point of ad blocking is not to block all ads, just to block the most
atrociously annoying and privacy invading ones. If the end game is that
advertisers all calm down and stick to static images that do not double as web
bugs we will all be happy.

------
jlarocco
If I'm going through the effort to block an ad it's safe to assume I'm not
going to click through, so you're doing a lot of work to not get a click.

Not to mention, if I encountered this on a real page I would just leave...

------
phogster
I'm not sure how I feel about helping OP create un-blockable ads.

------
Piskvorrr
Is Adblock a requirement? Opera has built-in element blocking: I clicked
"Block elements", clicked the "ad", clicked "Done," and ... done :)

~~~
ryanskidmore
Hm, tried it with Opera and it is indeed blocking it. However, the image still
shows when the page is reloaded. So eh, kinda works.

~~~
Piskvorrr
Interesting...it indeed shows up on reload.

------
charlieirish
This works assuming assuming OP doesn't change the page again:

    
    
      // First clear the interval assigned to window
      var highestTimeoutId = setTimeout(";");
      for (var i = 0 ; i < highestTimeoutId ; i++) {
          clearTimeout(i); 
      }
      // Then empty the script tag
      $('script').eq(3).empty();
      // Then hide the image;
      $('img[src^="img"]').eq(0).hide();

~~~
ryanskidmore
Very good solution, well done.

------
Pinckney
With the element hiding extension[1] installed:

0x1b.pw##IMG:first-child

But I imagine you could work around this by adding a null IMG element before
the ad. Also, I'm pretty sure this would break any non-toy page.

[1]: [https://addons.mozilla.org/en-
US/firefox/addon/elemhidehelpe...](https://addons.mozilla.org/en-
US/firefox/addon/elemhidehelper/)

~~~
ryanskidmore
Updated, not the cleanest way to do it but indeed adding a dummy image as the
first child should stop it.

~~~
jerf
This is an arms race situation. The winner is simply the last one to move. I'm
not sure exactly what you're trying to implicitly say, but it was already
pretty clear that the whole ad removal thing was an arms race. It's obvious
that neither side can Win Forever.

------
sp332
Can I use other extensions? It's dead simple with Remove It Permanantly.
[https://addons.mozilla.org/en-US/firefox/addon/remove-it-
per...](https://addons.mozilla.org/en-US/firefox/addon/remove-it-permanently)

~~~
ryanskidmore
Updated, try again.

~~~
sp332
Yeah, I have no idea now. Nice job :)

------
nsp
$($("img")[0]).attr("style","position: absolute; left: -10000px;")

~~~
ryanskidmore
Updated, try again ;)

~~~
StavrosK
Sorry, you don't get to work around successes every time someone posts one in
order to claim that nobody can do it. The GP did it, the challenge has been
won.

~~~
larrik
You don't get a prize, he's working WITH HN on an experiment.

~~~
StavrosK
I know you don't get a prize, but a challenge is one specific thing. This is a
new challenge now.

------
krisgee
If a site did this I'd just leave tbh. I turn everything off and opt into
advertising on sites I find I enjoy (if it turns out those sites had bad ads I
just turn them off again).

------
eevee
Block both, wonder why the site has nothing on it, leave.

------
jdc
$('img:first').replaceWith(function() { return $('<div id=' \+ this.id +
'></div>') })

------
_mc
$('img')[1].hidden = true;

------
Morphling
ermm? Just right click the image, adblock -> remove this image.

Of course reloading the page will bring it back due to way it's done, I guess
that's supposed be the challenging part.

~~~
ryanskidmore
Indeed, from a content creator standpoint - I wouldn't care if the image got
removed after you'd seen it since I would of already got the impression.

------
barranger
seems you check for height being zero, but not max-height

$('img[src^="img"]').eq(0).css("max-height", "0");

------
meow12
Easy Greeezy

------
danlash
height: 0;

