Lumia How-to: Bookmarklets

This is hopefully the first in a series of posts, getting back to the sprit of why I originally created this blog: instructions on how to do things a little out the ordinary with tech, written down here primarily for my reference but so they’re also available for all. Although the title is “Lumia” how-to, I guess this could also apply to WP7 in general. Hopefully you’ll find them useful, if there’s a subject you’d like me to cover then fire away in the comments.

Today, bookmarklets.

First, I guess I’ll quickly explain what they are. They’re a bookmark, but it’s not a weblink, it’s code that the browser processes and applies, generally using the current page or URL as input data. A quick google reveals a nice bookmarklet overview here. Why would you want them? Well, I’ll dive into my first example which shows how to do it on the Lumia, and should illustrate the point nicely.

Read Later

I love instapaper, a great cloud service to save pages for later (possibly offline) reading. So I need some means to save pages from the browser on the lumia. Bookmarklets to the rescue! First a quick video to show the bookmarklet in action, which’ll save me writing out those steps later ;-)

The basic idea is that you need to create a favourite where the link is the code for the bookmarklet. For instapaper do it as follows (similar steps for other bookmarklets):

  1. Create a favourite to any page.
  2. Go to instapaper.com then “extras”, you should find the bookmarklet link there, copy the link to get the code.
  3. Go to your favourites, edit the one you just made and change the name to something like “Read Later” and change the URL to the code you just copied.
  4. You’re done!

To use the bookmarklet, when you’re viewing something you want to read later, pop up the favourites, hit “read later” and it’s saved :-)

Find on Page

Windows phone doesn’t seem to have “find in this page” in IE. Shame, but never mind, bookmarklet to the rescue! This is the code you need:

javascript:(function(){function G(){var pf=doc.getElementById('pf')&var qt=doc.getElementById('qt')&if(null==pf){pf=doc.createElement('div')&pf.id='pf'&var s=pf.style&s.position='absolute'&s.zIndex='99'&s.top=(scT||scBT) 'px'&s.left=(scL||scBL) 'px'&s.width='100%'&s.backgroundColor='#FFFF00'&pf.appendChild(doc.createTextNode('Search: '))=&qt=doc.createElement('input')&qt.id='qt'&qt.type='text'&pf.appendChild(qt)=&var sb=doc.createElement('input')&sb.type='button'&sb.value='Find'&sb.onclick=function(){P(qt.value)}&pf.appendChild(sb)=&doc.body.appendChild(pf)=&}else{pf.style.display='inline'&count=0&}}function P(s){document.getElementById('pf').style.display='none'&if(s==='')return&var n=srchNode(document.body,s.toUpperCase(),s.length)&alert("Found " count " occurrence" (count==1?"":"s") " of '" s "'.")&pf.parentNode.removeChild(pf)=&return n=&}function srchNode(node,te,len){var pos,skip,spannode,middlebit,endbit,middleclone=&skip=0&if(node.nodeType==3){pos=node.data.toUpperCase().indexOf(te)&if(pos>=0){spannode=document.createElement("SPAN")&spannode.style.backgroundColor="red"&middlebit=node.splitText(pos)&endbit=middlebit.splitText(len)&middleclone=middlebit.cloneNode(true)&spannode.appendChild(middleclone)=&middlebit.parentNode.replaceChild(spannode,middlebit)=& count=&skip=1&}}else{if(node.nodeType==1&node.childNodes=&node.tagName.toUpperCase()!="SCRIPT"&node.tagName.toUpperCase!="STYLE"){for(var child=0&child<node.childNodes.length=& child){child=child srchNode(node.childNodes[child],te,len)&}}}return skip=&}var count=0,scL=0,scT=0,scBL=0,scBT=0&var w=window,doc=document&if(typeof doc.body!='undefined'&typeof doc.body.scrollLeft!='undefined'){scBL=doc.body.scrollLeft&scBT=doc.body.scrollTop&}if(typeof doc.documentElement!='undefined'&typeof doc.documentElement.scrollLeft!='undefined'){scL=doc.documentElement.scrollLeft&scT=doc.documentElement.scrollTop&}G()=&})()

Sorry but WordPress is messing up me putting it as a link. I can’t remember where I found it, and my google-fu is weak just now. Comment if I should be crediting you!

Create QR code of current page

Now, here’s code for a bookmarklet that I use a lot, mostly on my desktop or iPad browser, to “send” a link to a different device quickly and easily. A video’s worth a thousand words, so here:

and here’s the code (link):

javascript:void(window.open('http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl='+encodeURIComponent(location.href),'Qr%20code','top=100,left=200,width=350,height=350,status=yes'));

Again, not my own so if you know who to credit, fire away below!

You might have your own favourite bookmarklets, if you do, let me know and I’ll add good ones in :-)

Advertisements

3 Responses to “Lumia How-to: Bookmarklets”

  1. My favourite bookmarklet is the undisable one
    javascript:(function(){var x,k,f,j;x=document.forms;for (k=0;k<x.length;++k){f=x[k];for(j=0;j<f.length;++j){f[j].disabled=false; f[j].readOnly=false;}}})()

    However when I tried using javascript injection on my lumia 920 it said "Internet Explorer Mobile doesn't support this type of address"; how did you get around that?

    • Interesting, are you making the bookmark to another page, then editing to change the address?

      I’m trying to remember if I tried it out on my trial 920 or only on my 800.

  2. @I
    Actually, I figured it out; I was getting the error when I tried entering the bookmarklets directly (copy-paste), but they work fine if you set them as bookmarks first then click the bookmark :D

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: