Burnification (I demand this script to run whenever somebody makes a screenshot for meta.d)


  • Winner of the 2016 Presidential Election

    Continuing the discussion from Things Our Customers Have Said About Discourse Thread:

    @mott555 said:

    Feature Request: Automatically use Mr. Burns for all avatars here.

    There you go:

    Firefox-Users need to run the following code in console first:

    var jq = document.createElement('script');
    jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
    document.getElementsByTagName('head')[0].appendChild(jq);
    // ... give time for script to load, then type.
    jQuery.noConflict();
    

    Actual (simple) Code:

    AvatarCollection = new Array("https://meta-discourse.global.ssl.fastly.net/user_avatar/meta.discourse.org/abarker/120/33014.png", "https://meta-discourse.global.ssl.fastly.net/user_avatar/meta.discourse.org/boomzilla/25/33029.png","http://www.jeboavatars.com/images/avatars/293111179066mrburns4.jpg","http://www.glittergraphicsite.com/avatar/cartoons/Mr-Burns.gif","http://www.jeboavatars.com/images/avatars/293222179066mrburns3.jpg","http://www.smileysnetwork.com/avatars-simspons/simpsons43.gif","http://www.jeboavatars.com/images/avatars/270446177066mrburns.gif","http://www.glittergraphicsite.com/avatar/cartoons/Mr-Burns-Mistaken.jpg","http://www.rollertuningpage.de/avatars/elou-55541.gif");
    $(".avatar").each(
          function(){
              newAvatar = AvatarCollection[$(this).get(0).title.charCodeAt(0) % AvatarCollection.length];
              if(newAvatar === undefined) newAvatar = AvatarCollection[0];
              $(this).get(0).src = newAvatar;
          });
    

    AvatarCollection some burns-avatars I could find on the frontpage of the Discourse-Forum and on google. I am too lazy to actually go and look for more.

    This script would work best if somebody would create 26 Burns-avatars (and maybe even more for Unicode :D)

    I also stole half of it from @darkmatter since I never coded in JQuery-Chrome-Console.

    Disclaimer: I know this JS is probably REALLY terrible but to my defense I want to claim that it still works better than Discourse.

    What other people say about this:

    @Arantor said:

    @PJH could probably do that just in CSS.

    @PJH said:

    No. Just no.

    Filed Under: I downloaded Chrome for this! | Please note that none of the quotes are actually about this script and more about the idea itself! | Would somebody host a gallery of Burns-Avatars, please? I would add them to the script!

    Edit: Added Fallback in case no title-Tag exists (the image on the top right for example)



  • I like it. Doing It Wrong™ with style!

    How would I use this with Firefox? Or do I need to finally sell my soul to Google and let Chrome take over my identity?


  • Winner of the 2016 Presidential Election

    var jq = document.createElement('script');
    jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
    document.getElementsByTagName('head')[0].appendChild(jq);
    // ... give time for script to load, then type.
    jQuery.noConflict();
    

    before running the script is what 5 seconds of google and 1 second of SO brought forth.

    Filed Under: It works, I tried!

    Addendum: Added it into the first post!

    Actually: Do you even need that? JQuery exists on this site already.... Oh well.... too lazy to actually put more work into this :D


  • :belt_onion:

    @Kuro said:

    Actually: Do you even need that? JQuery exists on this site already.... Oh well.... too lazy to actually put more work into this

    No, you don't need it. You just need to make sure it runs after it loaded. You could also plug it into an Ember event and render new avatars for each post as it's loaded. Example code, you could just plug this in this pattern with small modifications:


  • Winner of the 2016 Presidential Election

    that would actually make more sense, since my script only affects the current view.
    Actually, Infinite-Scrolling as well as the "[topic.count new or changed topics]-banner kind of ruin the whole magic.

    It's still good for a static image, though.

    As said before: I am too lazy to actually put any real work into it. So if you want to make a better version of this, feel free to do so. I will gladly replace my script in the OP with yours :smiley:

    Filed Under: This script is OpenSource and stuff :D


  • :belt_onion:

    @Kuro said:

    Filed Under: This script is OpenSource and stuff

    Oh, crap, I have in fact forgotten to include a licence with mine.

    It's wtfpl BTW.



  • @Kuro said:

    Firefox-Users need to run the following code in console first:
    No, I didn't.

    In any case, if anyone is failing to run this on Firefox without reinserting jQuery to the page, try adding $ = content.$; instead. Maybe it'll do something, maybe it won't.

    Edit: ah, do you mean it won't survive opening another thread?


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.