BOOKMARKLETS!
PYer (3584)

What is a bookmarklet?

A bookmarklet is similar to an extension, but is used by clicking a bookmark. According to wikipedia:

A bookmarklet is a bookmark stored in a web browser that contains JavaScript commands that add new features to the browser. Bookmarklets are unobtrusive JavaScripts stored as the URL of a bookmark in a web browser or as a hyperlink on a web page. Bookmarklets are usually JavaScript programs. Regardless of whether bookmarklet utilities are stored as bookmarks or hyperlinks, they add one-click functions to a browser or web page. When clicked, a bookmarklet performs one of a wide variety of operations, such as running a search query or extracting data from a table. For example, clicking on a bookmarklet after selecting text on a webpage could run an Internet search on the selected text and display a search engine results page.

Create a bookmarklet

Creating a bookmarklet is easy. (If you do know how to create a bookmark. If not read Creating A Bookmark )

Let's create a simple example:

First, create a bookmark. As for the title of the bookmark, name it “Hello World”. Instead of keeping the url of the page as the bookmark type javascript:alert(‘Hello World!’). There! Click save or whatever it is in your search engine. And click the bookmark. You should have an alert message saying “Hello World!” appear!

To run js in a bookmark, you need to have the javascript: prefix before it. You can only type one line so make sure to use your semicolons! In addition, you can not use double quotes. The search engine saves the bookmark in code that looks something like this:

<a href="javascript:alert(‘Hello World!’)">Hello World</a>

If you use double quotes it looks like:

<a href="javascript:alert(“Hello World!”)”>Hello World</a>

And causes an error. If you have multiple lines, create an anonymous function:
javascript:(function(){ var x=prompt(‘Hi say something:’); alert(‘You said: ’ + x); })()

Notice there are NO double quotes.

Let's go over some examples:

Google Search:
javascript:(function(){window.open('https://www.google.com/search?q='+prompt('Google Search:', '').split(' ').join('+'), '', 'width=800,height=500,left=10,top=10,scrollbar=yes');})();

The above example opens up a new window with a search query of your input! Feel free to copy any of these or the ones listed below.

Calculator:
javascript:(function(){var evl,expr=prompt('Formula...','');with(Math)try{evl=parseFloat(eval(expr));if(isNaN(evl)){throw Error('Not a number!');}prompt('Result of '+expr+':',evl)}catch(evl){alert(evl);}})();

@JSer ‘s Rolling Sky: (Thanks for creating such an awesome game!)
javascript:window.open('https://Rolling-Sky--jser.repl.co', '', 'top=15,left=15,scrollbar=yes,width=500,height=600')

Community Creations

@Zavexeon Faces Generator

uhm... it works.... and is also useless...

javascript: const faces = ['OwO ', 'UwU', 'TwT', '>w<', '^w^']; let face = faces[Math.floor(Math.random()*faces.length)]; document.write('<body style=\'background-color: black;\'></body><title>' + face + '</title><p style=\'text-align: center; font-size: 500px; font-family: Arial; color: white;\'>' + face + '</p>');

@AdCharity Offline Editor

It's kind of a spinoff of my original project, an offline editor that saves with local storage.

javascript:(function() {document.body.innerHTML+='<iframe style=\"width: 25%;border: 3px solid black; z-index: 100000000000; position: fixed; bottom: 0; right: 0; height: 50%;\" src=\"https://offline-editor--adcharity.repl.co/optimized.html\">';})();

@DREWNOLT

Here's one that opens a Google Search for whatever you highlight; If you highlight "google" and click it, it will open the search results for "google"

javascript:function getSelectionText() {var text = '';if (window.getSelection) {text = window.getSelection().toString();} else if (document.selection &&document.selection.type != 'Control') {text = document.selection.createRange().text;}return text;}window.open('//google.com/search?q=' + encodeURIComponent(getSelectionText()))

@techgeek680

Here's a bookmarklet I made

javascript:(function(n,g,q,c,f)%7Bvar s=document,l=s.onclick,h="ws_cmbm-"+f,b=s.getElementById(h),d="ws_cmbms-"+f,p=s.getElementById(d),e=null,o,a=%7Btl:%7Bleft:"10px",top:"10px"%7D,tr:%7Bright:"10px",top:"10px"%7D,bl:%7Bleft:"10px",bottom:"10px"%7D,br:%7Bright:"10px",bottom:"10px"%7D%7D,k,m=".ws_cmbmc%7Bposition:fixed;z-index:10123456;width:200px;display:block;visibility:hidden;border:1px solid #b0b0b0;background:#fff;padding:3px 0 3px 3px;text-align:left;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;box-shadow:2px 2px 3px #777;-moz-box-shadow:2px 2px 3px #777;-webkit-box-shadow:2px 2px 3px #777;%7D.ws_cmbmc a%7Bdisplay:block;float:left;margin:0;width:191px;border:none;padding:8px 0 8px 6px;background:#fff;color:black;text-decoration:none;font:normal normal normal 12px/100%25 Verdana,sans-serif;letter-spacing:normal;word-spacing:normal;%7D.ws_cmbmc a:hover%7Bbackground:#a0a0a0;color:white;border:none;text-decoration:none;font:normal normal normal 12px/100%25 Verdana,sans-serif;letter-spacing:normal;word-spacing:normal;%7D";function r()%7Bb.style.visibility="hidden"%7Dfunction j()%7Bb.style.visibility="visible"%7Dif(b)%7Bif(b.style.visibility=="visible")%7Br()%7Delse%7Bj()%7Dreturn%7Dif(!p)%7Bm=m.replace(/.ws_cmbmc/g,"#"+h);p=s.createElement("style");p.type="text/css";p.id=d;p.appendChild(s.createTextNode(m));s.getElementsByTagName("head")%5B0%5D.appendChild(p)%7Db=s.createElement("div");b.setAttribute("id",h);b.className="ws_cmbmc";for(o=0;o<n.length;o++)%7Be=s.createElement("a");e.appendChild(s.createTextNode(n%5Bo%5D.title));e.setAttribute("href",n%5Bo%5D.url);e.onclick=(function(i)%7Bif(q)%7Br()%7D%7D);b.appendChild(e)%7Ds.getElementsByTagName("body")%5B0%5D.appendChild(b);if(a.hasOwnProperty(g))%7Bfor(k in a%5Bg%5D)%7Bb.style%5Bk%5D=a%5Bg%5D%5Bk%5D%7D%7Delse%7Bif(g=="c")%7Bb.style.left=Math.round((window.innerWidth-b.offsetWidth)/2)+"px";b.style.top=Math.round((window.innerHeight-b.offsetHeight)/2)+"px"%7D%7Dif(c)%7Bs.onclick=(function()%7Br();if(typeof l=="function")%7Bl()%7D%7D);b.onclick=(function(i)%7Bi.stopPropagation()%7D)%7Dj()%7D)(%5B%7Btitle:"Clippable",url:"javascript:(function()%7Bx=document.createElement(%5Cx27SCRIPT%5Cx27);x.type=%5Cx27text/javascript%5Cx27;x.src=%5Cx27http://brettterpstra.com/share/readability.js?x=%5Cx27+(Math.random());document.getElementsByTagName(%5Cx27head%5Cx27)%5B0%5D.appendChild(x);y=document.createElement(%5Cx27LINK%5Cx27);y.rel=%5Cx27stylesheet%5Cx27;y.href=%5Cx27http://brettterpstra.com/share/readability.css?x=%5Cx27+(Math.random());y.type=%5Cx27text/css%5Cx27;y.media=%5Cx27screen%5Cx27;document.getElementsByTagName(%5Cx27head%5Cx27)%5B0%5D.appendChild(y);%7D)();"%7D,%7Btitle:"Gmail This",url:"javascript:(function()%7Bpopw=%5Cx27%5Cx27;Q=%5Cx27%5Cx27;d=document;w=window;if(d.selection)%7BQ=d.selection.createRange().text;%7Delse if(w.getSelection)%7BQ=w.getSelection();%7Delse if(d.getSelection)%7BQ=d.getSelection();%7Dpopw=w.open(%5Cx27http://mail.google.com/mail/s?view=cm&fs=1&tf=1&to=&su=%5Cx27+encodeURIComponent(d.title)+%5Cx27&body=%5Cx27+encodeURIComponent(Q)+escape(%5Cx27%255Cn%255Cn%5Cx27)+encodeURIComponent(d.location)+%5Cx27&zx=RANDOMCRAP&shva=1&disablechatbrowsercheck=1&ui=1%5Cx27,%5Cx27gmailForm%5Cx27,%5Cx27scrollbars=yes,width=680,height=575,top=175,left=75,status=no,resizable=yes%5Cx27);if(!d.all)setTimeout(function()%7Bpopw.focus();%7D,50);%7D)();"%7D,%7Btitle:"PageZipper",url:"javascript:(function()%7Bif(window%5B%5Cx27pgzp%5Cx27%5D)%7B_pgzpToggleBookmarklet();%7Delse%7Bwindow._page_zipper_is_bookmarklet=true;window._page_zipper=document.createElement(%5Cx27script%5Cx27);window._page_zipper.type=%5Cx27text/javascript%5Cx27;window._page_zipper.src=%5Cx27//www.printwhatyoulike.com/static/pagezipper/pagezipper_10.js%5Cx27;document.getElementsByTagName(%5Cx27head%5Cx27)%5B0%5D.appendChild(window._page_zipper);%7D%7D)();"%7D,%7Btitle:"Save pw",url:"javascript:(function()%7Bvar ac,c,f,fa,fe,fea,x,y,z;ac=%5Cx22autocomplete%5Cx22;c=0;f=document.forms;for(x=0;x<f.length;x++)%7Bfa=f%5Bx%5D.attributes;for(y=0;y<fa.length;y++)%7Bif(fa%5By%5D.name.toLowerCase()==ac)%7Bfa%5By%5D.value=%5Cx22on%5Cx22;c++;%7D%7Dfe=f%5Bx%5D.elements;for(y=0;y<fe.length;y++)%7Bfea=fe%5By%5D.attributes;for(z=0;z<fea.length;z++)%7Bif(fea%5Bz%5D.name.toLowerCase()==ac)%7Bfea%5Bz%5D.value=%5Cx22on%5Cx22;c++;%7D%7D%7D%7Dalert(%5Cx22Enabled %5Cx27%5Cx22+ac+%5Cx22%5Cx27 on %5Cx22+c+%5Cx22 objects.%5Cx22);%7D)();"%7D,%7Btitle:"Writing",url:"javascript:(function() %7Bdocument.body.innerHTML+=%5Cx27<iframe style=%5C%5C%5Cx22width: 25%25;border: 3px solid black; z-index: 100000000000; position: fixed; bottom: 0; right: 0; height: 50%25;%5C%5C%5Cx22 src=%5C%5C%5Cx22https://offline-editor--adcharity.repl.co/optimized.html%5C%5C%5Cx22>%5Cx27;%7D)();"%7D,%7Btitle:"techgeek680",url:"javascript:window.open(%5Cx27https://techgeek680.techgeek680.repl.co%5Cx27, %5Cx27%5Cx27, %5Cx27top=15,left=15,scrollbar=yes,width=500,height=600%5Cx27)"%7D,%7Btitle:"Edit",url:"http://w-shadow.com/bookmarklet-combiner/?bookmarklet=40388"%7D%5D,"tl",true,true,1591719183687)

Thank you for reading! Please upvote and comment your own bookmarklets, to be added to the community creations section! I hope I get a content creator tag for this 😀

You are viewing a single comment. View All
techgeek680 (72)

does this NOT work for Chrome OS?

PYer (3584)

Really? I'm on a Chrome OS rn. @techgeek680 Any specific error?

techgeek680 (72)

They don't work when I click them. @PYer

PYer (3584)

hmmmm... can you give me the text stored in the URL for the bookmark? @techgeek680

techgeek680 (72)

I was using the Faces Generator @PYer

PYer (3584)

hmmm... that was made by somebody else, so I don't know if it works. I'll check it right now. @techgeek680

PYer (3584)

OK. The bookmarklet should work. Where did you past the code for it? @techgeek680

techgeek680 (72)

thanks. I googled bookmarklets and found a working 'Gmail This' bookmarklet and another. they both worked. @PYer

techgeek680 (72)

:) should i try again? @PYer
what does it do?

PYer (3584)

The Faces generator essentially replaces the page with a face made of characters, ex UwU. Make sure to paste the code into the URL field and not the title of the bookmarklet. @techgeek680

techgeek680 (72)

okay. wait- now it works!!! Thanks PYer! @PYer