Go Back   CodingForums.com > :: Client side development > JavaScript programming > Post a JavaScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-18-2003, 09:20 PM   PM User | #1
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
a few simple bookmarklets

Here's a small collection of bookmarklets for disecting your own (or other people's!) websites. They do things like, show all TABLE elements with a red border, hide non-link images, and so on.

I'm assuming people know what bookmarklets are, and how to install them? Please say if not, and I'll post instructions.

I'm also open to suggestions, and I'd love to see other people's ...
Attached Files
File Type: zip bookmarklets.zip (786 Bytes, 352 views)
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

Last edited by brothercake; 03-18-2003 at 09:24 PM..
brothercake is offline   Reply With Quote
Old 03-18-2003, 10:30 PM   PM User | #2
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
Ya, can you help me install these? I'm kinda new to javascript.


Ok, kidding aside, I didn't write this one, but it's a view-source bookmarklet that does syntax highlighting! Interesting indeed. If it doesn't work after copy-pasting, let me know, I may need to upload it as a text-file.

javascript:document.body.innerHTML=String(document.documentElement.outerHTML).replace(/(<!--[\s\S]*?-->)/g,"$1").replace(/>/g," &gt;").replace(/</g," &lt;").replace(/(&lt;)([\/a-zA-Z]+)/g,"$1$2").replace(/ /g,"&nbsp;").replace(/\n/g,"<br>").replace(//g,"red>").replace(//g,"</font>").replace(/([^;=]+)=/g,"blue>$1=</font>").replace(//g,'"').replace(//g,"=").replace(/ /g,'="teal"><b>').replace(//g,"</b></font>").replace(//g,'<i>').replace(//g,"</i>").replace(//g,"<font color")
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Old 03-18-2003, 10:41 PM   PM User | #3
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
I'm seeing some special characters that are unidentified, eg

"$1"


As for installing them - well the file I posted you can just import with "Bookmarks > Manage Bookmarks > File > Import" in moz, and "File > Import and Export" in IE

To make you new ones you start with an empty bookmark - like "about:blank" and any name, and then edit its properties - change the name, and write the syntax like inline javascript:

javascript:var something=function();void(null);

where void(null) stops it from trying to open a new document. It doesn't have to be null - you can go void('your message here');
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
brothercake is offline   Reply With Quote
Old 03-18-2003, 11:25 PM   PM User | #4
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
Talking about bookmarklets?

Hey - that's my speciality...

ViewStyles: javascript:(function(){var s='http://liorean.web-graphics.com/bookmarklets/viewstyles.js', t='text/javascript',q='\u0022',d=document,n=navigator,e;if(/mac/i.test(n.platform)&amp;&amp;/msie/i.test(n.userAgent))(d.createElement('div')).innerHTML='\u003cscript type='+q+t+q+' src='+q+s+q+'\u003e\u003c/script\u003e';else{(e=d.createElement('script')).src=s;e.type=t;d.getElementsByTagName('head')[0].appendChild(e)}})();void('Coded by liorean');

ViewScripts: javascript:(function(){var s='http://liorean.web-graphics.com/bookmarklets/viewscripts.js', t='text/javascript',q='\u0022',d=document,n=navigator,e;if(/mac/i.test(n.platform)&amp;&amp;/msie/i.test(n.userAgent))(d.createElement('div')).innerHTML='\u003cscript type='+q+t+q+' src='+q+s+q+'\u003e\u003c/script\u003e';else{(e=d.createElement('script')).src=s;e.type=t;d.getElementsByTagName('head')[0].appendChild(e)}})();void('Coded by liorean');

ToggleStyles: javascript:(function(){var s='http://liorean.web-graphics.com/bookmarklets/togglestyles.js', t='text/javascript',q='\u0022',d=document,n=navigator,e;if(/mac/i.test(n.platform)&amp;&amp;/msie/i.test(n.userAgent))(d.createElement('div')).innerHTML='\u003cscript type='+q+t+q+' src='+q+s+q+'\u003e\u003c/script\u003e';else{(e=d.createElement('script')).src=s;e.type=t;d.getElementsByTagName('head')[0].appendChild(e)}})();void('Coded by liorean');

GraphicsInfo: javascript:(function(){var s='http://liorean.web-graphics.com/bookmarklets/graphicsinfo.js', t='text/javascript',q='\u0022',d=document,n=navigator,e;if(/mac/i.test(n.platform)&amp;&amp;/msie/i.test(n.userAgent))(d.createElement('div')).innerHTML='\u003cscript type='+q+t+q+' src='+q+s+q+'\u003e\u003c/script\u003e';else{(e=d.createElement('script')).src=s;e.type=t;d.getElementsByTagName('head')[0].appendChild(e)}})();void('Coded by liorean');


Sources can be found from the link in my sig.
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Old 03-19-2003, 12:01 AM   PM User | #5
Borgtex
Regular Coder

 
Join Date: Aug 2002
Location: Spain
Posts: 420
Thanks: 0
Thanked 0 Times in 0 Posts
Borgtex is an unknown quantity at this point
There is a great table bookmarklet from http://sam-i-am.com/work/bookmarklet...debugging.html that also shows the amount of nested tables with diferent colors
__________________
Don't resist to assimilation. Billions of Borgs can't be wrong!
Borgtex is offline   Reply With Quote
Old 03-19-2003, 12:07 AM   PM User | #6
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
Excellent; those are fantastic, particularly that script and css extractor

I made a simple view-source as well:

javascript:document.body.innerHTML=('<xmp><html>'+document.getElementsByTagName('html')[0].innerHTML+'</html></xmp>');void(null);


And then this one - a Lynx Emulator - try it out on this page

javascript:var db=document.body;var el=['img','object','embed','html','body','table','td','div','span','strong','i','blockquote','abbr','acc ronym','q','em','ol','ul','li','cite','a','p','small','label','legend','input','button','select','te xtarea'];var bgLen=el.length;var e,eleLen,i,j;for(i=0;i<bgLen;i++){e=document.getElementsByTagName(el[i]);for(j=0;j<e.length;j++){if(i<3){e[j].style.display='none';}else{e[j].align='left';e[j].style.backgroundColor='#bbb';e[j].style.fontStyle='normal';e[j].style.textDecoration='none';(el[i]=='a')?e[j].style.color='#900':e[j].style.color='#000';e[j].style.fontSize='16px';if(el[i]=='input'||el[i]=='button'||el[i]=='select'||el[i]=='textarea'){e[j].style.borderStyle='none';e[j].style.borderBottom='1px solid #000';}if(el[i]=='i'||el[i]=='em'||el[i]=='cite'||el[i]=='q'){e[j].style.color='#990099';}e[j].style.fontFamily='courier,monotype';}}}var h=db.innerHTML;h=h.replace(/<\/tr>/ig,'<br>');h=h.replace(/<[bh]([1-6]|ig)[^>]*>/ig,'<b>');h=h.replace(/<\/[bh]([1-6]|ig)>/ig,'</b>');h=h.replace(/<[\/]?[ftc][eobard](nter|ble|ody|nt)?[^>]*>/ig,'');db.innerHTML=h;void('Lynx Emulator by brothercake');


I've noticed that after a certain length in only works in mozilla. So for big ones, presumably it's better to create an element and call a remote script?
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

Last edited by brothercake; 03-19-2003 at 12:58 AM..
brothercake is offline   Reply With Quote
Old 03-19-2003, 02:21 AM   PM User | #7
Borgtex
Regular Coder

 
Join Date: Aug 2002
Location: Spain
Posts: 420
Thanks: 0
Thanked 0 Times in 0 Posts
Borgtex is an unknown quantity at this point
Quote:
Originally posted by brothercake
I've noticed that after a certain length in only works in mozilla. So for big ones, presumably it's better to create an element and call a remote script?
For some reason, IE6 introduced a limit of characters (500 or smthg like that) for bookmarklets, so it literally cuts the script
__________________
Don't resist to assimilation. Billions of Borgs can't be wrong!
Borgtex is offline   Reply With Quote
Old 03-19-2003, 03:03 AM   PM User | #8
joh6nn
wei wu wei


 
joh6nn's Avatar
 
Join Date: Jun 2002
Location: 72° W. 48' 57" , 41° N. 32' 04"
Posts: 1,887
Thanks: 0
Thanked 1 Time in 1 Post
joh6nn is an unknown quantity at this point
figures that when you post this i'd be on vacation and away from all my bookmarklets. i don't even remember what all i've got.
__________________
bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

i am a loser geek, crazy with an evil streak,
yes i do believe there is a violent thing inside of me.
joh6nn is offline   Reply With Quote
Old 03-19-2003, 09:33 AM   PM User | #9
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
ie6w has a 508 character limit in bookmarklets. Not on javascript: links in pages, though.

nn4 has different limits in different versions - 2kb and 4 kb resp.

I'm not aware of any limit in mozilla, but then I've never tried to break it either.

As for Konq/Saf, Opera, IEMac, I have no idea, except I know there was a browser with a 1059 byte limit at some time, that I broke by two bytes.



For a list of good bookmarklet sites, see Webgraphics. on the bottom of the linklist to the right.
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Old 03-19-2003, 02:19 PM   PM User | #10
jalarie
Regular Coder

 
Join Date: Jun 2002
Location: Flint, Michigan, USA
Posts: 593
Thanks: 1
Thanked 19 Times in 19 Posts
jalarie is an unknown quantity at this point
I have a few posted on the "Samples of my work > Bookmarklets" page at:

&nbsp;http://spruce.flint.umich.edu/~jalarie/

And an editor for them linked from that same page.
jalarie is offline   Reply With Quote
Old 03-20-2003, 01:37 AM   PM User | #11
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
Very nice
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
brothercake is offline   Reply With Quote
Old 03-24-2003, 10:55 PM   PM User | #12
joh6nn
wei wu wei


 
joh6nn's Avatar
 
Join Date: Jun 2002
Location: 72° W. 48' 57" , 41° N. 32' 04"
Posts: 1,887
Thanks: 0
Thanked 1 Time in 1 Post
joh6nn is an unknown quantity at this point
most of the ones that i have, are things that most people could put together themselves. Change Text Color, Change Background Color, Remove Background Picture, Whois This Site, Toggle Images' Visibility, things like that.

I'm working on one that will list all the javascript functions on the page, and let you kill any you don't want to run, and one that will translate the page you're looking at.
__________________
bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

i am a loser geek, crazy with an evil streak,
yes i do believe there is a violent thing inside of me.
joh6nn is offline   Reply With Quote
Old 03-28-2003, 02:53 AM   PM User | #13
cg9com
Senior Coder

 
Join Date: Jul 2002
Posts: 1,628
Thanks: 0
Thanked 0 Times in 0 Posts
cg9com is an unknown quantity at this point
Re: a few simple bookmarklets

Quote:
Originally posted by brothercake
Here's a small collection of bookmarklets for disecting your own (or other people's!) websites. They do things like, show all TABLE elements with a red border, hide non-link images, and so on.
couldnt you do that with a user stylesheet? *feeling dumb*
cg9com is offline   Reply With Quote
Old 03-28-2003, 09:32 AM   PM User | #14
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
Re: Re: a few simple bookmarklets

Quote:
Originally posted by cg9com
couldnt you do that with a user stylesheet?
Yeah, just as easily; but this is convenient because it's a link - ergo, a button on the toolbar rather than something I have to go to preferences to change
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
brothercake is offline   Reply With Quote
Old 03-28-2003, 01:48 PM   PM User | #15
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
There's a mozilla add-on that might interest you, called ContextMenu Extensions. With it you can add custom stylesheets and javascripts to the context menu, create local javascripts and stylesheets for single pages or domains, and a lot more. In fact, it's one of the more useful mozilla add-ons, as is the Tabbrowser Extionsions from the same source. Those two, checky and optimoz mouse gestures are the basic must-haves for mozilla.
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:49 AM.


Advertisement
Log in to turn off these ads.