General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 10, 2003 01:04AM

I just found this page with "Bookmarklets"--

http://www.squarefree.com/bookmarklets/

--some sort of Mozilla sidebar convention or something along those lines; but you can rip the javascript functions out of them (the links are all one line of javascript, perfectly suited to a K-M macro).

For example, they have have a fancier version of the javascript for showing linked images and documents:

Images:

javascriptsad smileyfunction(){function I(u){var t=u.split('.'),e=t[t.length-1].toLowerCase();return {gif:1,jpg:1,jpeg:1,png:1,mng:1}[e]}function hE(s){return s.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;');}var q,h,i,z=open().document;z.write('<p>Images linked to by '+hE(location.href)+':</p><hr>');for(i=0;q=document.links;++i){h=q.href;if(h&&I(h))z.write('<p>'+q.innerHTML+' ('+hE(h)+')<br><img src="'+hE(h)+'">');}z.close();})()


Documents:

javascriptsad smileyfunction(){var dims,dimarray,wid,hei,dimstring,x,i,z,url; function linkIsSafe(u) { if (u.substr(0,7)=='mailto:') return false; if (u.substr(0,11)=='javascript:') return false; return true; } function htmlEscape(s){s=s.replace(/&/g,'&amp;');s=s.replace(/>/g,'&gt;');s=s.replace(/</g,'&lt;');return s;} dims = prompt('width, height for each frame', '760, 500'); if (dims!=null) { dimarray = dims.split(','); wid = parseInt(dimarray[0]); hei = parseInt(dimarray[1]); dimstring = 'width='+wid+' height='+hei; x = document.links; z = window.open().document; for (i = 0; i < x.length; ++i) { url = x.href; if(linkIsSafe(url)) { z.writeln('<p>' + x.innerHTML + ' (' + htmlEscape(url) + ')<br><iframe ' + dimstring + ' src="' + url.replace(/"/g, '&quot;') + '">[broken iframe]</iframe></p>'); } } z.close(); } })();


Those are adapted from:
http://www.squarefree.com/bookmarklets/pagelinks.html

There are a whole bunch, too! Even stuff for form field manipulation. smiling smiley)

It seems like it is an extreemly useful site for making K-M macros using javascript. Just thought I'd pass it along.


Shelumi`El
Jordan

S.D.G


Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 10, 2003 04:05AM

Man, this page has a bunch of goodies!! Lots of stuff people have been asking for around here, too; for example they have one for zooming the page layout (*text and images*), for zooming just the images, etc. smiling smiley)


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 10, 2003 04:11AM

See also:

http://bookmarklets.com


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: jsnj
Date: May 10, 2003 04:17AM

Yeah, I stumbled upon that page a few days ago and tried one of them but not in a macro...maybe it would work that way. I was tryin to get the password keeper for pages like yahoo mail which don't allow browsers to store its password. I'll give it another go.

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: jsnj
Date: May 10, 2003 04:58AM

Got error messages when I tried that version of the image links macro. Something about hE not recognized and expected a certain amount of arguments, found more or something like that.

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: jsnj
Date: May 10, 2003 05:37AM

These work well with doubling or halving all the images on a page. Do you or anyone know how to specify them to a particular image on the page and not all?

zoom_in{
menu=Zoom In
open("javascriptsad smileyfunction(){ function zoomImage(image, amt) { if(image.initialHeight == null) { /* avoid losing height information due to integer rounding while zooming out */ image.initialHeight = image.height; image.initialWidth = image.width; image.scalingFactor = 1; } image.scalingFactor *= amt; image.width = image.scalingFactor * image.initialWidth; image.height = image.scalingFactor * image.initialHeight; } for (i=0; i<document.images.length; ++i) zoomImage(document.images, 2); })();");
}

zoom_out{
menu=Zoom Out
open("javascriptsad smileyfunction(){ function zoomImage(image, amt) { if(image.initialHeight == null) { /* avoid losing height information due to integer rounding while zooming out */ image.initialHeight = image.height; image.initialWidth = image.width; image.scalingFactor = 1; } image.scalingFactor *= amt; image.width = image.scalingFactor * image.initialWidth; image.height = image.scalingFactor * image.initialHeight; } for (i=0; i<document.images.length; ++i) zoomImage(document.images, .5); })();");
}


Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 10, 2003 06:20AM

jsnj:

It would be in this for loop at the end:

for (i=0; i<document.images.length; ++i) zoomImage(document.images[ i ], 2);


Hmm....I think the best way would be to tell it the url of the image you want to zoom, using $ImageURL, then look for that url in the for loop...something like this:

zoom_in{
menu=Zoom In
$loc = $ImageURL;
open("javascriptsad smileyfunction(){ function zoomImage(image, amt) { if(image.initialHeight == null) { /* avoid losing height information due to integer rounding while zooming out */ image.initialHeight = image.height; image.initialWidth = image.width; image.scalingFactor = 1; } image.scalingFactor *= amt; image.width = image.scalingFactor * image.initialWidth; image.height = image.scalingFactor * image.initialHeight; } for (i=0; i<document.images.length; ++i) imgs = document.images[ i ].href.toLowerCase(); if (imgs.indexOf('" .$loc. "') > -1) zoomImage(document.images[ i ], 2); })();");
}

This example is untested, but if it doesn't work, I think that is the right idea at least. It will only be available by right clicking on the image, not from a main menu, too.

The other way I could think of to do it is to use a prompt to set the index value of the image to show (replace the "i" in the variable arrays (in brackets) with the return value of the prompt), but if there are like 20 images it would be about impossible to guess the index number of the image you're looking at currently on the screen.


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 10, 2003 06:23AM

Actually, I forgot a set of squiggly braces:

zoom_in{
menu=Zoom In
$loc = $ImageURL;
open("javascriptsad smileyfunction(){ function zoomImage(image, amt) { if(image.initialHeight == null) { /* avoid losing height information due to integer rounding while zooming out */ image.initialHeight = image.height; image.initialWidth = image.width; image.scalingFactor = 1; } image.scalingFactor *= amt; image.width = image.scalingFactor * image.initialWidth; image.height = image.scalingFactor * image.initialHeight; } for (i=0; i<document.images.length; ++i) { imgs = document.images[ i ].href.toLowerCase(); if (imgs.indexOf('" .$loc. "') > -1) zoomImage(document.images[ i ], 2); } } )();");
}

I think that will work...


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 10, 2003 06:42AM

Here is the working one (just tested it):

zoom_in {
menu="&Zoom In";
$loc = $ImageURL;
open("javascriptsad smileyfunction(){ function zoomImage(image, amt) { if(image.initialHeight == null) { /* avoid losing height information due to integer rounding while zooming out */ image.initialHeight = image.height; image.initialWidth = image.width; image.scalingFactor = 1; } image.scalingFactor *= amt; image.width = image.scalingFactor * image.initialWidth; image.height = image.scalingFactor * image.initialHeight; } for (i=0; i<document.images.length; ++i) { imgs = document.images[ i ].src; if (imgs.indexOf('" .$loc. "') > -1) zoomImage(document.images[ i ], 2); } } )();");
}


The document.images[index_number] array doesn't have a member called href, it has a member called src. So now it checks the image under the mouse pointer when the right click was triggered ( which is $ImageURL ) agaist the array of all the images on the current page, finds the one whose src="" tag matches the targeted image, then executes the zoom operation on that image (only) and returns. smiling smiley


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 10, 2003 06:48AM

That last bit can be done a little bit simpler:

zoom_in {
menu="&Zoom In";
$loc = $ImageURL;
open("javascriptsad smileyfunction(){ function zoomImage(image, amt) { if(image.initialHeight == null) { /* avoid losing height information due to integer rounding while zooming out */ image.initialHeight = image.height; image.initialWidth = image.width; image.scalingFactor = 1; } image.scalingFactor *= amt; image.width = image.scalingFactor * image.initialWidth; image.height = image.scalingFactor * image.initialHeight; } for (i=0; i<document.images.length; ++i) if (document.images[ i ].src.indexOf('" .$loc. "') > -1) zoomImage(document.images[ i ], 2); } )();");
}


So all you need to add to your original macros is this bit:

$loc = $ImageURL;
// ...
... if (document.images[ i ].src.indexOf('" .$loc. "') > -1) ...


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: jsnj
Date: May 10, 2003 08:59AM

Cool, thanks. Works great. Added to macros section.

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 10, 2003 10:23AM

Here are a couple for testing:

Gets rid of flash / quicktime content from the current page (or anything else with the embed or object tag) and replaces it with the crossed out text of whatever type of element it was:

flash_killer {
menu="Deflash";
open(" javascript: (function(){var d=document; function K(N,t) { var b = d.createElement("div"); b.style.width=N.width; b.style.height=N.height; b.innerHTML="<del>" + t + "</del>"; N.parentNode.replaceChild(b,N); } function Z(t) { var T = d.getElementsByTagName(t), i; for (i=T.length-1;i+1;--i) K(T,t); } Z("object"); Z("embed");})(); ");
}


Same for Java applets (or anything else with the applet tag):

app_killer {
menu="Decaffe";
open(" javascript: (function(){var d=document; function K(N,t) { var b = d.createElement("div"); b.style.width=N.width; b.style.height=N.height; b.innerHTML="<del>" + t + "</del>"; N.parentNode.replaceChild(b,N); } function Z(t) { var T = d.getElementsByTagName(t), i; for (i=T.length-1;i+1;--i) K(T,t); } Z("applet");})(); ");
}


Shelumi`El
Jordan

S.D.G


Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 10, 2003 10:23AM

Here are a couple for testing:

Gets rid of flash / quicktime content from the current page (or anything else with the embed or object tag) and replaces it with the crossed out text of whatever type of element it was:

flash_killer {
menu="Deflash";
open(" javascript: (function(){var d=document; function K(N,t) { var b = d.createElement("div"); b.style.width=N.width; b.style.height=N.height; b.innerHTML="<del>" + t + "</del>"; N.parentNode.replaceChild(b,N); } function Z(t) { var T = d.getElementsByTagName(t), i; for (i=T.length-1;i+1;--i) K(T[ i ],t); } Z("object"); Z("embed");})(); ");
}


Same for Java applets (or anything else with the applet tag):

app_killer {
menu="Decaffe";
open(" javascript: (function(){var d=document; function K(N,t) { var b = d.createElement("div"); b.style.width=N.width; b.style.height=N.height; b.innerHTML="<del>" + t + "</del>"; N.parentNode.replaceChild(b,N); } function Z(t) { var T = d.getElementsByTagName(t), i; for (i=T.length-1;i+1;--i) K(T[ i ],t); } Z("applet");})(); ");
}


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 11, 2003 12:01AM

Here is one for forced wrapping, it is especially nice for these forums, only caevet is that it has to open a new window to do its copy stuff, but seeing as only a few individual threads need to be forcibly wrapped, it is not really an issue:

fwrap {
menu="Force Wrap";
open(" javascriptsad smileyfunction(){var D=document; F(D.body); function F(n){var u,r,c,x; if(n.nodeType==3){ u=n.data.search(/\S{45}/); if(u>=0) { r=n.splitText(u+45); n.parentNode.insertBefore(D.createElement('WBR'),r); } }else if(n.tagName!='STYLE' && n.tagName!='SCRIPT'){for (c=0;x=n.childNodes[c];++c){F(x);}} } })(); (function(){var i,nd; function copyChildren(a,b){for(i=0;i<a.childNodes.length;++i) b.appendChild(a.childNodes[ i ].cloneNode(true));}; nd=open().document; nd.open(); nd.close(); copyChildren(document.getElementsByTagName('head')[0], nd.getElementsByTagName('head')[0]); copyChildren(document.body, nd.body);})(); ");
}


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 11, 2003 02:22AM

These two work:

flash_killer {
menu="Deflash";
open(" javascript: (function(){var d=document; function K(N,t) { var b = d.createElement('div'); b.style.width=N.width; b.style.height=N.height; b.innerHTML='<del>' + t + '</del>'; N.parentNode.replaceChild(b,N); } function Z(t) { var T = d.getElementsByTagName(t), i; for (i=T.length-1;i+1;--i) K(T[ i ],t); } Z('object'); Z('embed');})(); (function(){document.close();})(); ");
}

Tested on emusic.com (lots of flash ads).


app_killer {
menu="Decaffe";
open(" javascript: (function(){var d=document; function K(N,t) { var b = d.createElement('div'); b.style.width=N.width; b.style.height=N.height; b.innerHTML='<del>' + t + '</del>'; N.parentNode.replaceChild(b,N); } function Z(t) { var T = d.getElementsByTagName(t), i; for (i=T.length-1;i+1;--i) K(T[ i ],t); } Z('applet');})(); (function(){document.close();})(); ");
}

Tested on http://gemal.dk/browserspy/java.html


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 11, 2003 03:52AM

It is prolly easiest just to store the bookmarklets as bookmarks (and assign them nicks), then use a macro to access them, e.g., something like this:

bookmarklet_macro {
$loc = "";
$nick = prompt("Nick or Macro Name:", "Bookmarklets & Macros", "");
$nick == "" ? 0 : $loc = nick($nick);
$nick == "" ? 0 : $loc == $nick ? macros($loc) : pluginmsg("layers", "OpenURL", $loc);
}

If the return value of nick() is the same thing as the input (which means that there was no bookmarks nick found by that name), then we assume it is a macro name; else we open the return of nick() (which is the bookmark URL) in the current layer.


Ps. For those not using the layers plugin, that last line in the macro would be:

$nick == "" ? 0 : $loc == $nick ? macros($loc) : open($loc);


Then macros(bookmarklet_macro) can be bound to an accel (e.g., CTRL SHIFT cool smiley.


Ps. http://monkeesage.d2g.com/bookmarks.dll is updated so that quotes are now supported in bookmark URLs (it used to chop the URL at the first '"' (quote) it found -- now it chops it at the first '" ' (quote-space), that way you can have bookmarklets with stuff like this 'style="align:center;"' in their URL field, just make sure not to leave any spaces after the '"'--also most of the time the '"' can be switched to ''' (single quote) and the javascript still works fine).


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 13, 2003 02:50AM

Here is a rather nice bookmarklet I just made for use on forums (including these)!!!

What is does is look in all the textareas of the current page (like what I'm typing in right now) for a "
" and if it finds one it assumes the rest of the text after it is code unless it finds a closing "
" in which case it only operates on the text between the two tags.

As for the operation, it replaces " " with the HTML equivelant (non-breaking space), forcing the initial spaces (and all others) in code to be preserved; then it looks for common forums tags ("[L]" where "L" is either "i", "b" or "u") and puts spaces after the initial bracket and before the closing one (which 99% of the time will have no affect at all on the code, and fools most forum software into leaving it alone).

The code (as-is) can be stored in a bookmark and called by nick to work on the current page, or be transposed into a macro using open() since it uses no ""'s.

Here is an example of what happens when you use the
 block and this bookmarklet / macro (Ps. You will not see the "
" tags because it removes them after processing):

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;*dot&nbsp;=&nbsp;strrchr(wfd.cFileName,&nbsp;'.');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(dot&nbsp;&&&nbsp;(dot&nbsp;!=&nbsp;wfd.cFileName)&nbsp;&&&nbsp;stricmp(dot,&nbsp;".url")&nbsp;==&nbsp;0)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;filenameLen&nbsp;=&nbsp;(dot&nbsp;-&nbsp;wfd.cFileName)&nbsp;+&nbsp;4;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;urlFile&nbsp;=&nbsp;new&nbsp;char[pathLen&nbsp;+&nbsp;filenameLen&nbsp;+&nbsp;1];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strcpy(urlFile,&nbsp;szPath);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strcat(urlFile,&nbsp;wfd.cFileName);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;format&nbsp;for&nbsp;display&nbsp;in&nbsp;the&nbsp;menu
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;chop&nbsp;off&nbsp;the&nbsp;.url
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*dot&nbsp;=&nbsp;0;


The bookmarklet is here:

.bookmarklet.txt]http://gratisDei.com/
.bookmarklet.txt



Shelumi`El
Jordan

S.D.G


Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 13, 2003 03:07AM

Ps. It works with more than one tag, like you can do stuff like this:

random code from ie_file.cpp:

&nbsp;&nbsp;&nbsp;//&nbsp;first&nbsp;try&nbsp;the&nbsp;correct&nbsp;way
&nbsp;&nbsp;&nbsp;if&nbsp;(SHGetSpecialFolderLocation(NULL,&nbsp;CSIDL_FAVORITES,&nbsp;&idl)&nbsp;==&nbsp;NOERROR)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IMalloc&nbsp;*malloc;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SHGetPathFromIDList(idl,&nbsp;sz);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SHGetMalloc(&malloc);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;malloc->Free(idl);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;malloc->Release();
&nbsp;&nbsp;&nbsp;}


more:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(RegOpenKey(HKEY_CURRENT_USER,&nbsp;REG_USER_SHELL_FOLDERS,&nbsp;&hKey)&nbsp;==&nbsp;ERROR_SUCCESS)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dwSize&nbsp;=&nbsp;MAX_PATH;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rslt&nbsp;=&nbsp;RegQueryValueEx(hKey,&nbsp;REG_FAVORITES_KEY,&nbsp;NULL,&nbsp;NULL,&nbsp;(LPBYTE)sz,&nbsp;&dwSize);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RegCloseKey(hKey);


even more:

&nbsp;&nbsp;&nbsp;if&nbsp;(rslt&nbsp;==&nbsp;ERROR_SUCCESS)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExpandEnvironmentStrings(sz,&nbsp;gFavoritesPath,&nbsp;MAX_PATH);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strcat(gFavoritesPath,&nbsp;"\\");
&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gFavoritesPath[0]&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;}


&nbsp;&nbsp;&nbsp;kPlugin.kFuncs->GetPreference(PREF_STRING,&nbsp;PREFERENCE_FAVORITES_PATH,&nbsp;gFavoritesPath,&nbsp;gFavoritesPath);

&nbsp;&nbsp;&nbsp;return&nbsp;1;
}


&c.


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
javascript macros
Posted by: gsm
Date: May 14, 2003 01:56PM

Hi.
A lot of users are used to bookmarks - and not to macros, first of all because bookmarks or favorites are "cross browser".

About a month ago I tried to port some bookmarklets to KM that I've made myself - and I've found that url's in bookmarks are limited to 1023 bytes.

I use a lot of browsers simultaneously (mainly fb at home, nn7/moz1.3/ie5.5 at work and op7) so it eats some time for me to port all those macros/scriptlets/favelets/bookmarklets across the browsers and learn how to overcome their limitations.

I see a great work done already for KM to support usual bookmarklets (especially inside macros), so I think it would be very nice that the limitation of bookmark url's length would be increased, as an average bookmarklet on the net exceeds 1k bytes in length.

thanx -
gsm.

Options: ReplyQuote
javascript macros
Posted by: gsm
Date: May 14, 2003 01:58PM

Hi.
A lot of users are used to bookmarks - and not to macros, first of all because bookmarks or favorites are "cross browser".

About a month ago I tried to port some bookmarklets to KM that I've made myself - and I've found that url's in bookmarks are limited to 1023 bytes.

I use a lot of browsers simultaneously (mainly fb at home, nn7/moz1.3/ie5.5 at work and op7) so it eats some time for me to port all those macros/scriptlets/favelets/bookmarklets across the browsers and learn how to overcome their limitations.

I see a great work done already for KM to support usual bookmarklets (especially inside macros), so I think it would be very nice that the limitation of bookmark url's length would be increased, as an average bookmarklet on the net exceeds 1k bytes in length.

thanx -
gsm.

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 17, 2003 07:23AM

gsm:

I agree!

I think the max length for urls stored in a bookmark should at least match the max length that you type in the URL bar, which is INTERNET_MAX_URL_LENGTH (wininet.h), which is 2048, not 1024. I updated the bookmarks and hotlist plugins accordingly.

Updated builds are here:
http://monkeesage.d2g.com/bookmarks.dll
http://monkeesage.d2g.com/hotlist.dll


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 17, 2003 07:34AM

Here is a bookmarklet for a little notepad that lets you store and load notes from cookies:
javascript:W6=open('','Notes','width=410,height=340,resizable');W6.focus();with(W6.document){write('<script&nbsp;language="Javascript">function&nbsp;RCe(Nm){var&nbsp;sCH=Nm+"=";if(document.cookie.length>0){Oset=document.cookie.indexOf(sCH);if(Oset!=-1){Oset+=sCH.length;eNd=document.cookie.indexOf(";",Oset);if(eNd==-1)eNd=document.cookie.length;return(document.cookie.substring(Oset,eNd));}else&nbsp;return&nbsp;null;}else&nbsp;return&nbsp;null;}function&nbsp;WCe(cNm,cVl,eXpiry){var&nbsp;expD=new&nbsp;Date();expD.setTime(expD.getTime()+eXpiry);document.cookie=cNm+"="+escape(cVl)+";&nbsp;expires="+expD.toGMTString()+";&nbsp;path=/";}function&nbsp;lNa(){var&nbsp;nNm=prompt("Load&nbsp;Note:");return&nbsp;unescape(RCe(nNm));}function&nbsp;sNa(){var&nbsp;nNm=prompt("Save&nbsp;Note:");WCe(nNm,X.value,2678400000);}</script><center><form><textarea&nbsp;id=X&nbsp;name=X&nbsp;value=ABC&nbsp;rows=15&nbsp;cols=30&nbsp;wrap=physical></textarea><p><input&nbsp;type=button&nbsp;value=Load&nbsp;onclick=X.value=lNa();&nbsp;/><input&nbsp;type=button&nbsp;value=Save&nbsp;onclick=sNa();&nbsp;/><input&nbsp;type=button&nbsp;value=Clear&nbsp;onclick=X.value=null;&nbsp;/></p>');void(close());}

Kinda rough, but it is a cobbling together of a few different bookmarklets...kinda nice for keeping notes across sessions...just type in a name to save the note as at the save prompt and then load the same name next time via the load prompt.


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Attn: jsnj; javascript macros
Posted by: MonkeeSage
Date: May 17, 2003 01:33PM

Oops...the save button wasn't working right, this should fix it...

javascript:W6=open('','Notes','width=410,height=340,resizable');W6.focus();with(W6.document){write('<script&nbsp;language="Javascript">function&nbsp;RCe(Nm){var&nbsp;sCH=Nm+"=";if(document.cookie.length>0){Oset=document.cookie.indexOf(sCH);if(Oset!=-1){Oset+=sCH.length;eNd=document.cookie.indexOf(";",Oset);if(eNd==-1)eNd=document.cookie.length;return(document.cookie.substring(Oset,eNd));}else&nbsp;return&nbsp;null;}else&nbsp;return&nbsp;null;}function&nbsp;WCe(cNm,cVl,eXpiry){var&nbsp;expD=new&nbsp;Date();expD.setTime(expD.getTime()+eXpiry);document.cookie=cNm+"="+escape(cVl)+";&nbsp;expires="+expD.toGMTString()+";&nbsp;path=/";}function&nbsp;lNa(){var&nbsp;nNm=prompt("Load&nbsp;Note:");return&nbsp;unescape(RCe(nNm));}function&nbsp;sNa(){var&nbsp;nNm=prompt("Save&nbsp;Note:");WCe(nNm,document.getElementById("X").value,2678400000);}</script><center><form><textarea&nbsp;id=X&nbsp;name=X&nbsp;value=ABC&nbsp;rows=15&nbsp;cols=30&nbsp;wrap=physical></textarea><p><input&nbsp;type=button&nbsp;value=Load&nbsp;onclick=X.value=lNa();&nbsp;/><input&nbsp;type=button&nbsp;value=Save&nbsp;onclick=sNa();&nbsp;/><input&nbsp;type=button&nbsp;value=Clear&nbsp;onclick=X.value=null;&nbsp;/></p>');void(close());}


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote


K-Meleon forum is powered by Phorum.