I don’t know wether somebody has already started on this kind of project. I’m tickled so I tried to give a shot. I read some stuff about KJS, read its methods and found that we can actually execute a(ny) js script with it. I was 100% sure that KHTML (later found as KHTMLPart) will definitely has KJS in it, so this suerscript for Konqueror must be possible to achieve. Fire up KDevelop and test the khtmlpart plugin. I had to remove the original factory part and replace it with the (apparently) new factory code:
typedef KGenericFactory
static const KAboutData aboutdata("konqtest", I18N_NOOP("Konqueror KHTMLPart plugin test") , "0.1" );
K_EXPORT_COMPONENT_FACTORY( libkonqtestplugin, KonqTestFactory( &aboutdata ) )
Testing simple alert(document.getElementsByTagName(”link”).length) was sucessful. Thanks to akregator plugin for the example idea. Later, added a feature to autoload and execute any file under ~/.kde/share/apps/konqueror/userscripts. It wasn’t really easy for me who don’t have much knowledge about Qt and KDE. Simple task such as iterating over a list, reading lines from file had become a terrible torture
. Thank God it’s all over now. Or that waht I thought. next barrier was the UString stuff. After a careful read, I understand what the dev meant with “Happy implementing QString support” which is attched in KJS::UString::UString(QString &) doc. WTF!! Hahahah. Lucky me, we have lxr.kde.org. With some sweat I finally managed to get it working.
So far, the only feature available is autoexecuting every file under ~/.kde/share/apps/konqueror/userscripts as js, within current document context. TODO, of course, a lil bit compatibility with GreaseMonkey. Include, exclude url definitely will be mandatory needed feature. So far, you got to filtered it yourself within your JS
. I’m sure somebody will post a handy js script for this. Also, needed feature would be: enable disable userscript of course.
Okay, I no nothing about security. This code may not be secure at all
. That’s your homework. And if somebody has already start the same kind of thing then you can freely throw this code to your nearest recycle bin. I’m pretty happy already with my experience stroling new stuves :p.
For an example on how this thing work, save this code below to your userscripts folder. Don’t just copy paste! There are nasty quotes! (I should fix GeSHi plugin immediately :p)
var elms = document.getElementsByTagName("a");
//alert(elms.length);
for(var i=0;i
elms[i].style.border="1px solid";
}
The code above should make all links goes red and contained in red box.
Uploaded to kde-apps.org
[...] And about name, I wanna call this plugin as Kuskus (Konqueror User Script. what? Konqueror User Script!). I pick Phalanger ursinus for my Kuskus, among others, as it is the first thing I found from Google. Now, someone must make a logo for me Popularity: 1%These icons link to social bookmarking sites where readers can share and discover new web pages. [...]
hey, nice work, i’ve always felt that konqueror did not get enought attention- always firefox hacks and tweaks, never konqueror. i’m thinking of making a site dedicated to konqueror features e.t.c.
btw, wats with ur menu? its at the bottom of article, is it supposed to be?
@tidiman07
my menu? yep, it’s intended to be there. Though it felt a lil bit weird and hard to use
. Well, it’s all done so that we can stare at this sexy lady on the right , ie: Lust from Fullmetal Alchemist
Maybe I’ll hire someone to fix my menu ^^
I love this idea. But I when I tried it konq crashed even without a userscript installed.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1234970944 (LWP 19590)]
0xb6ef4827 in QGListIterator::QGListIterator () from /usr/lib/libqt-mt.so.3
(gdb) bt
#0 0xb6ef4827 in QGListIterator::QGListIterator () from /usr/lib/libqt-mt.so.3
#1 0xb5b75afd in Pluginkonqtest::slotAction ()
from /usr/lib/kde3/libkonqtestplugin.so
#2 0xb5b761aa in Pluginkonqtest::qt_invoke ()
from /usr/lib/kde3/libkonqtestplugin.so
#3 0xb6bf417e in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#4 0xb6bf4aec in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#5 0xb7a9395c in KParts::ReadOnlyPart::completed ()
from /usr/lib/libkparts.so.2
#6 0xb5e6162a in KHTMLView::timerEvent () from /usr/lib/libkhtml.so.4
#7 0xb6bf1270 in QObject::event () from /usr/lib/libqt-mt.so.3
#8 0xb6c2e742 in QWidget::event () from /usr/lib/libqt-mt.so.3
#9 0xb6b89f3e in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#10 0xb6b8acbe in QApplication::notify () from /usr/lib/libqt-mt.so.3
#11 0xb73331cd in KApplication::notify () from /usr/lib/libkdecore.so.4
#12 0xb6b1b157 in QApplication::sendEvent () from /usr/lib/libqt-mt.so.3
#13 0xb6b7b92b in QEventLoop::activateTimers () from /usr/lib/libqt-mt.so.3
#14 0xb6b2ef67 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#15 0xb6ba2a2f in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#16 0xb6ba2952 in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#17 0xb6b88a4d in QApplication::exec () from /usr/lib/libqt-mt.so.3
#18 0xb7e9617f in kdemain () from /usr/lib/libkdeinit_konqueror.so
#19 0xb7bc0ea2 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
#20 0×080483b5 in ?? ()
Ah, works better if I run it from my home directory. I guess the userscript_dir initialization needs to get the home dir.