Javascript bookmark function to add emojis to website 😀

Posted on 26.10.17   Browser Emoji Humor Javascript

After fiddling around with some DOM manipulation I figured an emoji generator would be fun…

Add a new bookmark to your browser and paste the following code into the URL target:

javascript:(function(){
    const c='😀';
    let domh= document.getElementsByTagName('h1');
    let domp= document.getElementsByTagName('p');
    for(let i=0; i<domh.length; i++) {
        domh[i].innerHTML+=c
    }
    for(let i=0; i<domp.length; i++) {
       const s='<span style="font-size:'+Math.random()*1000/5+'px;">';
       const se='</span>';
       domp[i].innerHTML=s+c+se+domp[i].innerHTML+c.repeat(i);
    }
})();

 

Quick explanation:

First of we define the emoji (&#128512;) in the c variable.

Then we scan the website for every h1 and p tags.

For every h1 tag we append the smiley.

For every p tag, we prepend the smiley in a random size by using inline span and styling, then we append a few more smileys at the end.

 

This is really stupid, but it’s just a quick demonstration that Javascript functions in bookmarks can be used for many useful things. For instance I have one shortcut which opens a prompt() where I enter a Dell servicetag, then it redirects me to the Dell website to check ProSupport warranty.

 

Here’s a pic of this website destroyed by stupid emojis:

 

More on ITDB

Telnet alternative to check if port is open on host


Finding the source for locked AD account from Event Viewer log on Domain controller


Change Resize Mode for all VMs in RoyalTS 4


How to debug a non starting application with ProcMon


Create a cmd alias/shortcut for issuing commands on remote computer




  1. หนังโป๊ญี่ปุ่น says:

    Ԍreetings! Very helpful advice in tһis particulаr artiϲle!
    It is the little changes which will make the greatest chаnges.
    Thanks a lot for sharing!

  2. nuvid says:

    Thanks very interesting bⅼog!