Development :  K-Meleon Forum
K-Meleon development related discussions. 
Idea: interface for custom scrippets
Posted by: sven
Date: January 09, 2002 08:38PM

I haven't had time to post my ideas altough I was planning few days ago. It's been quite a busy at work but here we go now.

If the following has been suggested, discussed and dismissed, then kindly point me to the thread so that I'd not waste bandwidth briging it up again smiling smiley

I'm not a application programmer, so I can't help improving K-M as an app. However, in the light of recent new macros that we've seen popping up I do think there is yet uncovered area of K-M development. That would be possibility to write sort of scrippets which can be used just as plugins, when the need arises (the word "scriptlet" is tainted with Microsoft flavour who first(?) brought it up, so I suggest "scrippet" instead, heh-heh).

Basically, what I have in mind, that K-M should implement an interface to some kind of scripting language(s). Since Mozilla already supports and internally relies heavily on Javascript, this seems to be natural choice. Since I'm not familiar with inner workings of neither Mozilla nor K-M I don't have foggiest idea how exactly this support is built in so I can't really say whether following would be easy or hard to implement.

Mozilla has gone all the way there and made it's all interface scriptable but thats not the way to go, I reckon. But what I think could be useful and not having detrimental effect on speed or stability would be mechanism to insert or activate scripts at runtime. For example - I write a script that does something useful (for example fills forms automatically or whatever) - and I'd like to use that script on different web-pages.

The problem with current macro mechanism is that one can't really write anything really useful with it. There are two problems that'd limit me when I'd like to write Javascript scrippets with it:

1) Javascript: pseudo-protocol has some severe limitations (can't execute loops for example, at least I couldn't get it execute them)
2) The code is basically incomprehensible and breaking it into human readable form to add something and then back again is nuisance. How about something like this but like 20 to 40 times bigger:

javascript: function ToggleMode(newMode){bTextMode=newMode;var cont;if (bTextMode){cont=obj.DOM.body.innerHTML;obj.DOM.body.innerText=cont;}else{cont=obj.DOM.body.innerText;obj.DOM.body.innerHTML=cont;}obj.focus();}if(TagStart != 0){var thisary = frag.ary.length;frag.ary[thisary] = new _chardata();if(TagStart == -1){frag.ary[thisary].value = _entity(frag.str);frag.str = "";}else{frag.ary[thisary].value = _entity(frag.str.substring(0,TagStart));frag.str = frag.str.substring(TagStart,frag.str.length);}}

Not very nice, eh? Having macro file allow newlines or something would not solve things because it'd be mess to organize it later on.

What I think we should have is plugin-like interface to scrippets which gives them ability to interact with active web-page. Sesh gave an idea to write script to creat dynamic listing of links or images found in document. While it was not hard to code, I currently don't see any way to implement it seamlessly into K-M. While some may say this is not really so useful, think of the possibilities. You can have scrippets that apply your custom stylesheet (for changing link color of font size when it happens to be unreadable) automatically when you visit your favourite site; you can have scripppets that generate dyncamic TOC or summary of the page for your conveniece; you can have scrippet re-arrange of fix badly built pages for easier reading; you can have scrippets set bookmarks in the middle of long page and to find the very same place for you next time; etc etc. Such possibilities are already there in Mozilla engine DOM and Javascript support. It's just we can't use those elsewhere than our own pages.

It would be nonsense to try to implement all those features into K-M, they should be add-ons. Besides, this would get K-M much wider developer base, this I'm pretty sure of.

So that generally outlines my idea. If something like this is already in works then I'd very much like to know more.

Options: ReplyQuote
Re: Idea: interface for custom scrippets
Posted by: sven
Date: January 09, 2002 08:39PM

oops, sorry for spoiling the scrolling with long line of code sad smiley

Options: ReplyQuote
Re: Idea: interface for custom scrippets
Posted by: po
Date: January 10, 2002 08:15AM

i'm re-pasting it here, so i can read it on my small screen. smiling smiley
------------------------------


I haven't had time to post my ideas altough I was planning few days
ago. It's been quite a busy at work but here we go now. If the
following has been suggested, discussed and dismissed, then kindly
point me to the thread so that I'd not waste bandwidth briging it up
again smiling smiley I'm not a application programmer, so I can't help improving
K-M as an app. However, in the light of recent new macros that we've
seen popping up I do think there is yet uncovered area of K-M
development. That would be possibility to write sort of scrippets
which can be used just as plugins, when the need arises (the word
"scriptlet" is tainted with Microsoft flavour who first(?) brought it
up, so I suggest "scrippet" instead, heh-heh). Basically, what I have
in mind, that K-M should implement an interface to some kind of
scripting language(s). Since Mozilla already supports and internally
relies heavily on Javascript, this seems to be natural choice. Since
I'm not familiar with inner workings of neither Mozilla nor K-M I
don't have foggiest idea how exactly this support is built in so I
can't really say whether following would be easy or hard to
implement. Mozilla has gone all the way there and made it's all
interface scriptable but thats not the way to go, I reckon. But what
I think could be useful and not having detrimental effect on speed or
stability would be mechanism to insert or activate scripts at
runtime. For example - I write a script that does something useful
(for example fills forms automatically or whatever) - and I'd like to
use that script on different web-pages. The problem with current
macro mechanism is that one can't really write anything really useful
with it. There are two problems that'd limit me when I'd like to
write Javascript scrippets with it: 1) Javascript: pseudo-protocol
has some severe limitations (can't execute loops for example, at
least I couldn't get it execute them) 2) The code is basically
incomprehensible and breaking it into human readable form to add
something and then back again is nuisance. How about something like
this but like 20 to 40 times bigger: javascript: function
ToggleMode(newMode){bTextMode=newMode;var cont;if
(bTextMode){cont=obj.DOM.body.innerHTML;obj.DOM.body.innerText=
cont;}else{cont=obj.DOM.body.innerText;obj.DOM.body.innerHTML=
cont;}obj.focus();}if(TagStart
!= 0){var thisary = frag.ary.length;frag.ary[thisary] = new
_chardata();if(TagStart == -1){frag.ary[thisary].value =
_entity(frag.str);frag.str = "";}else{frag.ary[thisary].value =
_entity(frag.str.substring(0,TagStart));frag.str =
frag.str.substring(TagStart,frag.str.length);}} Not very nice, eh?
Having macro file allow newlines or something would not solve things
because it'd be mess to organize it later on. What I think we should
have is plugin-like interface to scrippets which gives them ability
to interact with active web-page. Sesh gave an idea to write script
to creat dynamic listing of links or images found in document. While
it was not hard to code, I currently don't see any way to implement
it seamlessly into K-M. While some may say this is not really so
useful, think of the possibilities. You can have scrippets that apply
your custom stylesheet (for changing link color of font size when it
happens to be unreadable) automatically when you visit your favourite
site; you can have scripppets that generate dyncamic TOC or summary
of the page for your conveniece; you can have scrippet re-arrange of
fix badly built pages for easier reading; you can have scrippets set
bookmarks in the middle of long page and to find the very same place
for you next time; etc etc. Such possibilities are already there in
Mozilla engine DOM and Javascript support. It's just we can't use
those elsewhere than our own pages. It would be nonsense to try to
implement all those features into K-M, they should be add-ons.
Besides, this would get K-M much wider developer base, this I'm
pretty sure of. So that generally outlines my idea. If something like
this is already in works then I'd very much like to know more.

Options: ReplyQuote
Re: Idea: interface for custom scrippets
Posted by: po
Date: January 11, 2002 02:14AM

ok... sorry for wasting all that space with redundancy.

are you subscribed to the developers list?

there's been some talk:

http://www.geocrawler.com/lists/3/SourceForge/9632/0/7467858/

Options: ReplyQuote


K-Meleon forum is powered by Phorum.