Javascript bookmark function to add emojis to website 😀

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:

 

Was this post helpful?
Yes
No
Powered by Devhats

5 thoughts on “Javascript bookmark function to add emojis to website 😀”

  1. I’m really enjoying the deѕign and layout оf your wеbsite.
    It’s a very easy on the eyes which makes it much mоre pleasant for me to come
    here and visit more often. Ⅾid you hire out a designer to create your theme?

    Excellent woгk!

  2. Ԍ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!

Leave a Reply

Your email address will not be published. Required fields are marked *