[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Re: konqeror: "in-memory" page manipulation, same-session form
From:       Koos Vriezen <koos.vriezen () xs4all ! nl>
Date:       2002-11-06 21:04:10
[Download RAW message or body]

On Tue, 5 Nov 2002 h019@ied.com wrote:

>  What I need is to change one javascript function in the page (it's a page
> in a frame), and then display the page as if it came directly from the
> server. Then clicking on "submit" will invoke my modified function
> (instead of the one the server provided), and everything will work.
>
>  Ideally, I could modify anything in the page by modifying the DOM tree -
> there is a DOM tree viewer for the browser, but I didn't find a DOM tree
> editor - where can I find it, or what could I slap together to make myself
> a "DOM tree editor" ? (Even if it was somewhat cumbersome)
>
[..]
>
>  Does Konqueror have a javascript debugger ? Maybe I could tell it "switch
> context to current page, redefine this submit function", and then I would
> submit the form with the new redefined function.

No, there is not a useable debugger yet. But you can change things in a
running page using DCOP on the console:
  dcop konqueror-pid html-widgetx evalJS 'javascript'
(you have to figure out the pid, run 'dcop', and x, run 'dcop konqueror-pid')

Eg. suppose you want to change the 'Log in' button on freshmeat.net to go
to slashdot.org. First figure out which FORM and which INPUT that is:

dcop konqueror-12079 html-widget1 evalJS '
var s = "";
for(var i = 0; i < document.forms.length; i++) {
  var f = document.forms[i];
  s += "form " + i + ":" + f.action + "\n";
  for (var j = 0; j < f.elements.length; j++)
    s += " " + j + ":" + f.elements[j].name + "\n";
}
s'

Now change the FORM ACTION attribute:

dcop konqueror-12079 html-widget1 evalJS '
document.forms[5].action="http://slashdot.org"'

Next change the FORM METHOD attribute (slashdot doesn't like POST's :)

dcop konqueror-12079 html-widget1 evalJS '
document.forms[5].method="GET"'

Press on 'Log in' and you will go to
http://slashdot.org/?url=%2F&username=&password=

With the Javascript DOM bindings (createElement, removeChild,
insertBefore, ...), you can change the DOM tree.
Probably needless to say that you must be carefull with quotes and watch
for script errors in the console where konqueror is started.

Good luck,

Koos Vriezen

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic