What's new
Apple iPad Forum 🍎

Welcome to the Apple iPad Forum, your one stop source for all things iPad. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Guide: Creating Safari Bookmarklets

Mickey330

Administrator
Staff member
Joined
Aug 30, 2010
Messages
11,890
Reaction score
2,226
Location
Western NY state (USA)
You can create "bookmarklets" in Safari. Bookmarklets are, essentially, little pieces of script that you can save in Safari so you can do some short cut-like actions. For example, you can create a book mark to scroll to the bottom of the Safari web page, create a QR code of the URL so you can quickly and easily transfer the web site address to your mobile phone or you can create a book mark to get a pop-up to enter search terms for Amazon. I find they make browsing with Safari easier.

(A) Here are the steps to make a bookmarklet
Create a bookmark in Safari. It does not matter what page you choose, just that it is made. Title this bookmark to describe the bookmark (e.g. "Create PDF"). See this picture

ImageUploadedByTapatalk1334351739.217933.jpg

2) Edit the bookmark as shown in this picture

ImageUploadedByTapatalk1334351767.668270.jpg

3) Enter the Java script in the URL field as shown here (the various JavaScripts are given below):

ImageUploadedByTapatalk1334351805.409850.jpg

With JavaScripts as bookmarklets, any time you are on a web page and you want to do an action, press the book mark and Safari will do its "magic."

(B) Here are the bookmarklets I have used/am using.

NOTE: Copy them exactly as shown here - then paste them in the URL field of your bookmark in Safari as shown above.

Scroll to Bottom
javascript:scroll(0,document.getElementsByTagName(%22body%22)%5B0%5D.scrollHeight);

Search Amazon
javascript:q=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt(%22Search%20terms?%20...%20%22,%22%22);if(q!=null)%7Blocation=%22http://www.amazon.com/exec/obidos/external-search?mode=blended&tag=bookmardirect-20&keyword=%22+escape(q).replace(/%20/g,%22+%22);%7Delse%7Blocation=%22http://www.amazon.com/exec/obidos/redirect-home/bookmardirect-20%22;%7Dvoid%200

Open in iCab
javascript:location.href='web'+location.href.substring(4);

Save as PDF
javascript:pdf_url=location.href;location.href='http://pdfmyurl.com?url='+escape(pdf_url)

Send to Evernote
javascript:(function()%7BEN_CLIP_HOST='http://www.evernote.com';try%7Bvar%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=EN_CLIP_HOST+'/public/bookmarkClipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')%5B0%5D.appendChild(x);%7Dcatch(e)%7Blocation.href=EN_CLIP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);%7D%7D)();

Make QR Code (Link)
javascript:location.href='http://chart.apis.google.com/chart?cht=qr&chs=300x250&chl='+encodeURIComponent(location.href);

Add Library Books to Bluefire E-Reading App
javascript:void%28s%3Dprompt%28%27Find%20text%3A%27%2C%27%27%29%29%3Bs%3D%27%28%27+s+%27%29%27%3Bx%3Dnew%20RegExp%28s%2C%27gi%27%29%3Brn%3DMath.floor%28Math.random%28%29*100%29%3Brid%3D%27z%27%20+%20rn%3Bb%20%3D%20document.body.innerHTML%3Bb%3Db.replace%28x%2C%27%3Cspan%20name%3D%27%20+%20rid%20+%20%27%20id%3D%27%20+%20rid%20+%20%27%20style%3D%5C%27color%3A%23000%3Bbackground-color%3Ayellow%3B%20font-weight%3Abold%3B%5C%27%3E%241%3C/span%3E%27%29%3Bvoid%28document.body.innerHTML%3Db%29%3Balert%28%27Found%20%27%20+%20document.getElementsByName%28rid%29.length%20+%20%27%20matches.%27%29%3Bwindow.scrollTo%280%2Cdocument.getElementsByName%28rid%29%5B0%5D.offsetTop%29%3B

CSS Killer
javascript:void(obj=document.getElementsByTagName('style'));for(i=0;i%3Cobj.length;i++){void(obj.disabled='true')}void(obj=document.getElementsByTagName('link'));for(i=0;i%3Cobj.length;i++){void(obj.disabled='true')}void(theTags='a,abbr,acronym,address,applet,area,b,base,basefont,bdo,big,blockquote,body,br,button,caption,center,cite,code,col,colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,hr,html,i,iframe,img,input,ins,isindex,kbd,label,legend,li,link,map,menu,meta,noframes,noscript,object,ol,optgroup,option,p,param,pre,q,s,samp,script,select,small,span,strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,title,tr,tt,u,ul,var');theTags_array=theTags.split(',');for(loop=0;loop%3CtheTags_array.length;loop++){void(theDokk=document.getElementsByTagName(theTags_array[loop]));{for(loopCount=0;loopCount%3CtheDokk.length;loopCount++){void(theDokk[loopCount].removeAttribute('style'))}}};


Calculator
javascript:expr=prompt('Formula...(eg:%20%202*3%20+%207/8%20)','');if(expr){with(Math){evl=parseFloat(eval(expr))};if(isNaN(evl)){alert('Not%20a%20number!')}else{void(prompt('Result:',evl))}}else{void(null)}

Dictionary & Thesaurus
javascript:var%20q=escape(window.getSelection()),i,ii;if(!q){for(i=0;i%3Cframes.length;i++){var%20fr=frames;try{q=escape(fr.getSelection())}catch(e){};if(q)break;else{for(ii=0;ii%3Cfr.frames.length;ii++){try{q=escape(fr.frames[ii].getSelection())}catch(e){};if(q)break;}}}}if(!q)void(q=prompt('Enter%20word%20to%20define%3A',''));if(q)void(location.href='http://www.dictionary.com/cgi-bin/dict.pl?term='+q);


Find in Page
javascript:void%28s%3Dprompt%28%27Find%20text%3A%27%2C%27%27%29%29%3Bs%3D%27%28%27+s+%27%29%27%3Bx%3Dnew%20RegExp%28s%2C%27gi%27%29%3Brn%3DMath.floor%28Math.random%28%29*100%29%3Brid%3D%27z%27%20+%20rn%3Bb%20%3D%20document.body.innerHTML%3Bb%3Db.replace%28x%2C%27%3Cspan%20name%3D%27%20+%20rid%20+%20%27%20id%3D%27%20+%20rid%20+%20%27%20style%3D%5C%27color%3A%23000%3Bbackground-color%3Ayellow%3B%20font-weight%3Abold%3B%5C%27%3E%241%3C/span%3E%27%29%3Bvoid%28document.body.innerHTML%3Db%29%3Balert%28%27Found%20%27%20+%20document.getElementsByName%28rid%29.length%20+%20%27%20matches.%27%29%3Bwindow.scrollTo%280%2Cdocument.getElementsByName%28rid%29%5B0%5D.offsetTop%29%3B

Improve Readability
javascript:(function(){readStyle='style-newspaper';readSize='size-medium';readMargin='margin-medium';_readability_script=document.createElement('SCRIPT');_readability_script.type='text/javascript';_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(_readability_script);_readability_css=document.createElement('LINK');_readability_css.rel='stylesheet';_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';_readability_css.type='text/css';_readability_css.media='all';document.getElementsByTagName('head')[0].appendChild(_readability_css);_readability_print_css=document.createElement('LINK');_readability_print_css.rel='stylesheet';_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_print_css);})();

Look Up in 1Password
javascript:window.location=%27onepassword://%27+window.location

Open in Atomic Web Browser
javascript:window.location='atomic://'+location.href

Open in iCab Web Browser
javascript:location.href='web'+location.href.substring(4);

Send to Instapaper
javascript:function%20iprl5()%7Bvar%20d=document,z=d.createElement('scr'+'ipt'),b=d.body,l=d.location;try%7Bif(!b)throw(0);d.title='(Saving...)%20'+d.title;z.setAttribute('src',l.protocol+'//www.instapaper.com/j/SrztHioaPNq1?u='+encodeURIComponent(l.href)+'&t='+(new%20Date().getTime()));b.appendChild(z);%7Dcatch(e)%7Balert('Please%20wait%20until%20the%20page%20has%20loaded.');%7D%7Diprl5();void(0)

Save Webpage to Goodreader App
javascript:window.location='g'+location.href

Subscribe to RSS feed
javascript:var%20b=document.body;var%20GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/subscribe-bookmarklet.js');void(b.appendChild(z));}else{location='http://www.google.com/reader/view/feed/'+encodeURIComponent(location.href)}

Split Page in Two
javascript:document.write('%3CHTML%3E%3CHEAD%3E%3C/HEAD%3E%3CFRAMESET%20COLS=\'50%25,*\'%3E%3CFRAME%20SRC='%20+%20location.href%20+%20'%3E%3CFRAME%20SRC='%20+%20location.href%20+%20'%3E%3C/FRAMESET%3E%3C/HTML%3E')

Translate (to English)
javascript:void(0);void(0);void(0);void(0);void('Add%20this%20text%20into%20the%20code%20to%20suppress%20the%20tooltip%20with%20long%20script');void(0);void(0);void(0);void(0);void(0);void(0);void(0);q=location.href;void(location.href='http://translate.google.com/translate?u='+q);

Wikipedia
javascript:Qr=prompt('Search%20Wikipedia%20for','');if(Qr)location.href='http://en.wikipedia.org/wiki/Special:Search?search='+escape(Qr)+'&fulltext=Search'

Open in Skyfire web browser
javascript:location.href='skyfire'+location.href.substring(4);

Open in Skyfire VideoQ app
javascript:window.location='skyfire://'+location.href

Note that I've not tried this (I don't own VideoQ). However, it will open the Skyfire browser, so it may work for videoQ. Good luck.

Increase Font Size (With Reflow)
javascript:var%20p=document.getElementsByTagName('*');for(i=0;i%3Cp.length;i++)%7Bif(p%5Bi%5D.style.fontSize)%7Bvar%20s=parseInt(p%5Bi%5D.style.fontSize.replace(%22px%22,%22%22));%7Delse%7Bvar%20s=12;%7Ds+=2;p%5Bi%5D.style.fontSize=s+%22px%22%7D

Decrease Font Size (With Reflow)
javascript:var%20p=document.getElementsByTagName('*');for(i=0;i%3Cp.length;i++)%7Bif(p%5Bi%5D.style.fontSize)%7Bvar%20s=parseInt(p%5Bi%5D.style.fontSize.replace(%22px%22,%22%22));%7Delse%7Bvar%20s=12;%7Ds-=2;p%5Bi%5D.style.fontSize=s+%22px%22%7D

Open in Photon Browser
javascript:(function()%7Bif(document.location.href.indexOf('http')===0)document.location.href=document.location.href.replace(/%5Ehttp/,'photon');%7D)();

Page Zipper (automatically activates "Next Page" button)
javascript:(function(){if(window['pgzp']){_pgzpToggleBookmarklet();}else{window._page_zipper_is_bookmarklet=true;window._page_zipper=document.createElement('script');window._page_zipper.type='text/javascript';window._page_zipper.src='http://www.printwhatyoulike.com/static/pagezipper/pagezipper_10.js';document.getElementsByTagName('head')[0].appendChild(window._page_zipper);}})();

View Page Source
javascript:(function(){var a=window.open('about:blank').document;a.write('Source of '+location.href+'');a.close();var b=a.body.appendChild(a.createElement('pre'));b.style.overflow='auto';b.style.whiteSpace='pre-wrap';b.appendChild(a.createTextNode(document.documentElement.innerHTML))})();

This are the ones I've used at some point in the past, or am using now. If you have one you are using that's not in this list, please send me a PM and I'll get it added here.

If I have made an error in MY copying and pasting and a JavaScript doesn't work for you, please let me know and I'll get it fixed.

Have fun!

Marilyn
 
Last edited:
Since I kind of railroaded you into it, I'd better say thanks too. :D

And it's way better and more complete than I thought ti would be. Super job!

Oh yeah, Thanks.
 
I'm just replying to this thread so I'm subscribed to it. I'm not clever enough to do that myself. I can unsubscribe, but I can't find a link in the app to subscribe.
 
I'm just replying to this thread so I'm subscribed to it. I'm not clever enough to do that myself. I can unsubscribe, but I can't find a link in the app to subscribe.

When reading the thread, tap the box arrow icon at the top right of screen and chose Subscribe. If you are already subscribed it will say Unsubscribe.
 
Thanks for the bookmarklets Marilyn :thumbs:
Anyway, this is only works for iOS devices right???
 
Thanks for the bookmarklets Marilyn :thumbs:
Anyway, this is only works for iOS devices right???

You're welcome.

And no, these bookmarklets are for most browsers, not just iOS or Safari. Or, at least I know they work in the Firefox browser ... well, some of them. For example, I've made a folder on my Windows 7 PC for shortcuts and some of them are the bookmarklets to search in Amazon and open in split screen. All I can suggest is to try them and see how they work.

Marilyn
 
Mickey330 said:
Yeah, there is one, but it's for Skyfire VideoQ, not the actual web browser. I can put it in if you want...

Marilyn

Yes please I'll see if it works!
 
Okay. I've added the script for Skyfire VideoQ.

Please note that I've not tried it with VideoQ as I don't own that app. However, it does open the Skyfire browser (though a Flash video does not play and the web site does not open). But, if it works for VideoQ, then hurray!

Oh, and if it does work with Skyfire VideoQ, could you post back and let us know? Thanks.

Marilyn
 
Mickey330 said:
Okay. I've added the script for Skyfire VideoQ.

Please note that I've not tried it with VideoQ as I don't own that app. However, it does open the Skyfire browser (though a Flash video does not play and the web site does not open). But, if it works for VideoQ, then hurray!

Oh, and if it does work with Skyfire VideoQ, could you post back and let us know? Thanks.

Marilyn

I amended it and now it works:

javascript:location.href='skyfire'+location.href.substring(4);

This opens up the web page in Skyfire, not sure about videoq though as I also don't own the app.

People have asked the developer for this for 2 years!

Thanks for the original!

Note: also works for puffin! Just replace skyfire with puffin and it does essentially the same thing. Awesome!
 
Last edited:
Great mod and it works with the browser. I just watched a Flash video (after easily opening up the Skyfire browser from Safari)! Man, I loves me some bookmarklets... :)

I've edited the first post to show your new and improved script.

Thanks for this.

Marilyn
 

Most reactions

Latest posts

Back
Top