Make StackOverflow Explode (bookmarklet)

28

12

Sometimes people get frustrated on the StackExchange network (specifically SO).

stackoverflow logo modified

Your task is to create a bookmarklet that causes StackOverflow to explode/implode/destroy in some fashion. This will provide a nicer way of dispersing our frustrations.

The Rules:

  • it must be in the form of a bookmarklet
  • must work in Chrome and Firefox (latest stable)
  • jQuery is on the site, so you can use it
  • no creating a script tag that pulls explosionThisPage.js or similar

Scoring is the number of characters that need to be copied and pasted, except:

  • -1 if you include an explanation
  • -5 for each upvote
  • -10 if you don't use jQuery
  • -10 if it makes an explosion sound
  • +9e72 if it actually does harm to the site (F5 should repair the damage)

If the gif's distracting, remove it.

Brigand

Posted 2013-08-20T11:52:05.510

Reputation: 1 137

Question was closed 2014-11-01T20:06:14.580

7IMO the spec isn't sharp enough for an objective determination of whether a submission meets it. – Peter Taylor – 2013-08-20T12:33:46.787

in a comment, as it's not mine: javascript: varwww_WHAK_com = 'http://www.is-a-jerk.com/flash/url.asp?flash=10&insult=off&destroy=' + encodeURIComponent(top.location.href.replace('http://', '').replace('https://', '')); top.location.href = www_WHAK_com; void(0); – SeanC – 2013-08-20T13:20:00.603

@PeterTaylor, it's a mix between code golf and a popularity contest. Most of the weight will be on votes, though (perhaps -10 for an up vote?). – Brigand – 2013-08-20T13:50:57.180

1My comment wasn't about the scoring system but about the task specification. – Peter Taylor – 2013-08-20T14:57:11.583

4Really? That should be minus 9*10**72 points if it actually manages to cause harm to the site, and then repair it when the user reloads the page. That would be quite a feat. – Blacklight Shining – 2014-02-10T11:41:47.070

@BlacklightShining, I meant that if F5 repairs the damage, you don't get the 9e72 added to your score :-) But yes, that would be quite impressive! – Brigand – 2014-02-11T15:25:52.337

2@FakeRainBrigand IMO, causing real harm to the site that is somehow repaired upon reloading is far more impressive than simply causing harm to the site. – Blacklight Shining – 2014-02-11T16:43:23.547

I will vote to reopen if you specify more clearly that potentially damaging posts are not allowed. – None – 2014-11-05T22:47:36.313

Answers

27

Chicken!

Score: 46 - 1 (explanation) - 5*17 (votes) = -40

javascript:$('*:not(:has(*))').text('chicken')

It simply takes every element with no children and replaces it with the text 'chicken'.

Sample screenshots:
more chicken
this question chickenified

image

Doorknob

Posted 2013-08-20T11:52:05.510

Reputation: 68 138

Awesome idea :-) It's also interesting to see things like "answered chicken" or the page title, which have non-chicken words... Why? – Brigand – 2013-10-14T20:19:45.063

@FakeRainBrigand Huh? The page title becomes "chicken" for me... – Doorknob – 2013-10-14T20:32:53.123

Longer but more thorough version, partially based on my entry: javascript:void($(':not(iframe,script,style)').contents().each(function(){if(this.nodeType==3)this.nodeValue=this.nodeValue.replace(/\w+/g,'chicken')})) – Ilmari Karonen – 2013-12-13T17:30:44.590

@Doorknob, congrats, you had a score of 15, which was the lowest (sorry it took me so long to accept one). If I could do it over again, though, I'd make a vote worth -15, though. – Brigand – 2014-02-11T15:34:36.527

1Should have been HODOR! – SztupY – 2014-02-15T21:31:41.707

@IlmariKaronen That shows up as "SyntaxError: illegal character" in Firefox for this page. – Timtech – 2014-02-17T14:37:55.210

@Timtech: Hmm, you're right, looks like there's an invisible Unicode zero-width space character inserted in the middle of it. I suspect the SE software did that to break up the long line of code. Let me try that again, this time with some spaces inserted: javascript:void( $( ':not(iframe, script, style)' ).contents().each( function () { if ( this.nodeType == 3 ) this.nodeValue = this.nodeValue.replace( /\w+/g, 'chicken' ) } ) ) – Ilmari Karonen – 2014-02-17T15:19:49.153

@IlmariKaronen Thanks, it worked ;) – Timtech – 2014-02-17T17:49:23.877

27

Here's my entry, which I'll call the drunkenator:

javascript:void(setInterval(function(){c='1234567890poiuytrewqasdfghjklmnbvcxzZXCVBNMLKJHGFDSAQWERTYUIOP=)(/&%25$%23"!1';$(':not(iframe,script,style)').contents().each(function(){if(this.nodeType==3&&/\S/.test(this.nodeValue)){a=this.nodeValue.split('');x=0;for(i=0;i<a.length;i++){r=Math.random()*9999;if(r<10){x=1;j=c.indexOf(a[i]);a[i]=(r<4%3F(t=a[i-1],a[i-1]=a[i],t):r<5%3F'':r<6%3Fa[i]+a[i]:j<0%3Fa[i]:c.charAt(j+(r<8%3F1:-1)))}}if(x)this.nodeValue=a.join('')}})},100))

At 474 chars, it's probably not going to win any golf prizes, but I'm hoping to make up for it in upvotes. :)

Here's the same code de-obfuscated:

setInterval(function () {
  var c = '1234567890poiuytrewqasdfghjklmnbvcxzZXCVBNMLKJHGFDSAQWERTYUIOP=)(/&%$#"!1';
  $(':not(iframe,script,style)').contents().each(function () {
    if (this.nodeType==3 && /\S/.test(this.nodeValue)) {
      var a = this.nodeValue.split('');
      var x = 0;
      for (i = 0; i < a.length; i++) {
        r = Math.random() * 9999;
        if (r < 10) {
          x = 1;
          j = c.indexOf(a[i]);
          a[i] = ( r < 4 ? (t = a[i-1], a[i-1] = a[i], t)
                 : r < 5 ? ''
                 : r < 6 ? a[i] + a[i]
                 : j < 0 ? a[i] : c.charAt(j + (r < 8 ? 1 : -1)) ); 
        }
      }
      if (x) this.nodeValue = a.join('');
    }
  });
}, 100);

What it does is randomly mutate the text on the page, swapping adjacent characters, deleting or duplicating characters or replacing them with ones adjacent to them on the keyboard. The effect is kind of subtle at first, but leave it running for a while, and the page content will inevitably decay into a mess of drunken typing:

Go home, SO, you're drunk!

Ps. The code isn't in any way SO-specific, so it'll work on any website that uses jQuery. Try it on Wikipedia for hilarious results. The idea is based on something I wrote years ago as a creative interpretation of the "99 bottles of beer" challenge: my version introduced a slowly increasing number of typos into each verse, until the last ones were all but unrecognizable. If anyone wants to see it, here's the original Perl code.

Ilmari Karonen

Posted 2013-08-20T11:52:05.510

Reputation: 19 513

6More lide the Dyslexinator (sorru, i'm typping while it's ruqning) – TheDoctor – 2014-02-15T23:37:03.140

16

I don't know why this was downvoted, I like it :)

This isn't the shortest, but I think it's pretty:

133 chars -1

javascript:(function(){setInterval(function(){$("div, span").eq(Math.round(Math.random()*$("div, span").length)).hide(500)},90)}());

Ungolfed:

javascript:(function(){  
         window.setInterval(function() {
                 i = Math.round(Math.random() * $("div, span").length);
                 $("div, span").eq(i).hide("slow");
         } , 90);
}());

Explanation: I hope this counts, this script implodes the site instead of exploding it ;) This just picks a random div or span every 90ms and closes it slowly..

Fels

Posted 2013-08-20T11:52:05.510

Reputation: 488

+1 but the random() isn't efficient for a full and controlled destroy, anyway I like it :) – Daniele Vrut – 2013-10-17T12:28:03.140

Just threw it into the URL window, and nothing's happened,,,? – WallyWest – 2013-12-16T00:22:22.243

Sorry Wally, didn't see your comment. You need to save it as a bookmark. – Fels – 2014-02-12T08:44:09.337

12

Because it was not defined if the higher or lower score wins...

javascript:$(".vote-down-off").click()

Base: 38
Bonis:

  • +9e72 Permanent damage.

Final score: 9000000000000000000000000000000000000000000000000000000000000000000000038

Btw, I did not try it.

Johannes Kuhn

Posted 2013-08-20T11:52:05.510

Reputation: 7 122

1haha By the way, if you ask JavaScript: 9e72+38 === 9e72 :-) – Brigand – 2013-08-20T13:48:17.157

3

Who asks javascript? Use jQuery.

– Johannes Kuhn – 2013-08-20T13:52:59.287

16http://i.stack.imgur.com/sGhaO.gif :D – Doorknob – 2013-08-20T16:57:18.533

@Doorknob Exactly. When I saw this pic when I looked for this many-memes-of-meta link... Coincidence? – Johannes Kuhn – 2013-08-20T18:33:55.713

1FYI, if anyone wants to try this out, they can use the less damaging: javascript:($(".vote-up-off").click())(); – Beta Decay – 2017-06-19T15:07:11.253

4Err ... should I vote down or up...? – Friend of Kim – 2014-02-11T19:34:06.180

What exactly does this do? – Nzall – 2014-02-18T13:16:14.470

@NateKerkhofs no comment. it would cost points. – Johannes Kuhn – 2014-02-18T15:31:10.883

1Oh, I get it... it clicks the buttons with class "vote-down-off" if you use it. It's code-challenge tagged, which implies that lowest score wins. – Nzall – 2014-02-18T15:39:28.700

8

My pupose 245 chars.

Mostly not the shorter, but I like it ;-)

javascript:document.body.innerHTML+='<img%20id="bigMsk"%20src="http://i.stack.imgur.com/VWPZg.gif">';document.getElementById('bigMsk').setAttribute('style','z-index:1;opacity:.6;display:block;position:fixed;top:0;left:0;width:100%;height:100%;');

-1: Explanation:

  • I use the nice offered animated gif image from question,
  • With the help of CSS, I put them over the page in full page, with a 60% opacity.

:

document.body.innerHTML+=
   '<img%20id="bigMsk"%20src="http://i.stack.imgur.com/VWPZg.gif">';
document.getElementById('bigMsk').setAttribute('style',
    'z-index:1;
     opacity:.6;
     display:block;
     position:fixed;
     top:0;
     left:0;
     width:100%;
     height:100%;
');

Mostly readable by itself ;-)

-10 No JQuery

Alternative:

There is an alternative:

javascript:document.body.innerHTML+='<img%20id="bigMsk"%20src="http://i.stack.imgur.com/aTtWM.gif">';document.getElementById('bigMsk').setAttribute('style','z-index:1;opacity:.6;display:block;position:fixed;top:0;left:0;width:100%;height:100%;');

Based on unmodified GIF, found at Wikimedia Commons: File:Animated fire by nevit.gif

Image: Image from Wikipedia

Sample:

enter image description here

F. Hauri

Posted 2013-08-20T11:52:05.510

Reputation: 2 654

That's awesome! – Brigand – 2013-11-13T03:16:46.813

5

Ok, I think this should meed the criteria:

javascript:document.write("<h1>Exploded</h1>")

Replaces the current page with "Exploded"

Score: 46
-1 Explaination
-10 No jQuery

35

Johannes Kuhn

Posted 2013-08-20T11:52:05.510

Reputation: 7 122

5

This one's enjoyable, and causes quite a bit of lag too :D

javascript:setInterval(function(){document.body.innerHTML=document.body.innerHTML.replace(/\d+/g,function(){return Math.random()*100|0});},500)

It just sets an interval that replaces all strings of digits with a random number from 0 to 100. Twice per second. It creates a bunch of errors, as you might expect, and I could fix it to stop all the 404s when image URLs are changed, but I think it's more fun this way and it's code golf. :D

Score:

  • 132 base
  • -1 explanation
  • -5 upvote
  • -10 no jQuery

Total score: 116

Doorknob

Posted 2013-08-20T11:52:05.510

Reputation: 68 138

Made this variation on this one: javascript:(function(){s=$('*');setInterval(function(){var r=Math.random();s.eq(Math.round(r*s.length)).css({ transition:'.4s linear', left:(r*window.innerWidth/100)+'px', top:(r*$(document.body).height()/25)+'px', transform:'rotate('+(r*360)+'deg)'})},90)}()); – Tschallacka – 2016-11-01T13:51:23.067

Does not work in firefox. – Johannes Kuhn – 2013-08-20T13:47:33.903

@JohannesKuhn What does it do in FF? It works in Chrome – Doorknob – 2013-08-20T13:48:28.280

Displays a blank page with a number. – Johannes Kuhn – 2013-08-20T13:53:23.337

@JohannesKuhn I think I fixed it; does function x(){document.body.innerHTML=document.body.innerHTML.replace(/\d+/g,function(){return Math.random()*100|0})}setInterval(x,500) work for you now? – Doorknob – 2013-08-20T14:00:47.473

Yes, but a single ; at the end would do the same. – Johannes Kuhn – 2013-08-20T14:02:37.190

@JohannesKuhn Hmm, odd. Is that a Firefox bug or something? Edited answer. – Doorknob – 2013-08-20T14:03:45.470

@Doorknob, either way, you save a few characters passing a string to setInterval. – Brigand – 2013-08-20T15:02:54.037

This one turns Wikipedia into Time Cube. – asmeurer – 2013-08-25T21:08:30.847

If you guys like the answer or others please upvote. This question is largely influenced by votes, and no one's voting :-) – Brigand – 2013-08-27T15:28:02.320

4

165 chars (164 points)

-1 for explaination

Here's my attempt. It's not particularly short, but it's fun.

javascript:r=Math.random;$("a,span,p").each(function(){var a=$(this);a.css({position:"relative"});a.delay(1E4*r()).animate({left:9E3*r()-4E3,top:9E3*r()-4E3},555)});

It slides individual elements off the page in random directions. I specifically included span because of the syntax highlighting (each color has a separate span).

r = Math.random;
$('a,span,p').each(function () {
    var t = $(this);
    t.css({
        position: 'relative'
    });

    t.delay(r()*10000).animate({
        left: r() * 9e3 - 4e3,
        top: r() * 9e3 - 4e3
    }, 555);
});

It of course could be shortened by removing some of the tags, but let me know if there are any ways to shorten it without reducing the performance.

Brigand

Posted 2013-08-20T11:52:05.510

Reputation: 1 137

4

181 151 chars - 1 (explanation) - 10 (no jQuery) = 140 points

javascript:i=setInterval(function(){for(var a=document;0!==a.childNodes.length;)a=a.childNodes[a.childNodes.length-1];a!==document?a.parentNode.removeChild(a):clearInterval(i)},50);

A few more characters can be saved by omiting the function(){ and using a string instead. Also note the extraction of commonly used properties, e.g., c='childNodes allows us to do z[c] instead of z.childNodes.

javascript:h=setInterval('d=z=document;c="childNodes";for(l="length";z[c][l];z=z[c][z[c][l]-1]);z!=d?z.parentNode.removeChild(z):clearInterval(h)',50);

I guess I could make less points by using jQuery and not traversing properties, but oh well.

Ungolfed:

var intervalHandle = setInterval(function() {
    var lastElement = document;
    //get last element
    while (lastElement.childNodes.length !== 0) {
        lastElement = lastElement.childNodes[lastElement.childNodes.length - 1];
    }

    if(lastElement !== document) {
        lastElement.parentNode.removeChild(lastElement);
    } else {
        clearInterval(intervalHandle);
    }
}, 50);

Basically this finds the latest DOM element on the page and removes it. Then keeps doing that for every 50 milliseconds, which I found to be a kind-of-average nice speed to see a page getting ripped from the ground up. It's therapeutic, I swear it.

Disclaimer: I had made this some time ago and decided to share it, since it seems appropriate here. The source is at my GitHub repository.

Alpha

Posted 2013-08-20T11:52:05.510

Reputation: 301

This is great! I edited it to include a more-golfed version that saves a few characters. I hope you don't mind. It's functionally identical. – Brigand – 2013-08-27T15:25:02.887

@FakeRainBrigand Not at all, thanks! In fact, you helped me learn some new cool tricks, which was my original intention when writing it. Thanks again! – Alpha – 2013-08-27T18:11:41.550

3

Javascript, 281

javascript:$('body').html().split('<code>javascript:').forEach(function (a) {if (a.indexOf("location")*a.indexOf("write")*a.indexOf("noscript")==-1) try{exec(a.split("</code>")[0].replace(/&#(\d+)/g, function(match, dec) {return String.fromCharCode(dec);}))} catch (e) {}});void 0;

It gets every response to the question in the form of <code>javascript:(stuff)</code> that doesn't change the location, and runs all of them.

Kuilin Li

Posted 2013-08-20T11:52:05.510

Reputation: 421

Hmm... I can see lots of whitespace that appears to be removable. Perhaps you should remove it. – John Dvorak – 2013-12-11T07:38:27.043

3I am pretty sure this fails the rule: "no creating a script tag that pulls explosionThisPage.js or similar". Also, it doesn't work on every SO page, just this one. Also, it does real damage on questions asking about XSS, so you should add 9e72 to your score. – John Dvorak – 2013-12-11T07:42:12.007

2

I like this effect. It basically toggles a slide effect for every div on the site every 1 millisecond.

javascript:setInterval(function(){$('div').toggle()},1)

Score

56
-1 Explanation
--------------
55 Total

Dan Grahn

Posted 2013-08-20T11:52:05.510

Reputation: 131

Nice, but just toogle would work too:

`javascript:setInterval(function(){$('div').toggle(88)},1)`
 – Fels  – 2013-08-20T19:56:13.503