state of server-side javascript

J

Jeff

Hello,

I'd like to adapt some Greasemonkey scripts that I've written and have
them applied to html files on the server side before the files are sent
to users. I'm only looking at adapting scripts that make static
changes to pages. For instance, consider a script that removes from
the DOM any img that has "ad" in its src.

I'm sure there are better ways to do this and I'm not even necessarily
looking for an extremely efficient solution. Mostly, I just want to
know if there's an existing product that could do this or with
reasonable effort could be made to do this.

Thanks!
Jeff
 
H

Hal Rosser

Jeff said:
Hello,

I'd like to adapt some Greasemonkey scripts that I've written and have
them applied to html files on the server side before the files are sent
to users. I'm only looking at adapting scripts that make static
changes to pages. For instance, consider a script that removes from
the DOM any img that has "ad" in its src.

I'm sure there are better ways to do this and I'm not even necessarily
looking for an extremely efficient solution. Mostly, I just want to
know if there's an existing product that could do this or with
reasonable effort could be made to do this.

Thanks!
Jeff

You may want to look into ASP and using IIS.
As I understand it, you can use 'J-Script' as server-side language with IIS.
I have never used JScript for Server-Side programming, so beyond here, I
couldn't help.
 
R

Randy Webb

Jeff said the following on 1/20/2007 12:52 PM:
Hello,

I'd like to adapt some Greasemonkey scripts that I've written and have
them applied to html files on the server side before the files are sent
to users. I'm only looking at adapting scripts that make static
changes to pages. For instance, consider a script that removes from
the DOM any img that has "ad" in its src.

If all your script is doing in the client is modifying the DOM then
converting it to a server side script should be trivial. However, if the
offending code is added via client side scripting then the only two ways
to do it are client side and having a JS parser execute it on the
server, correct it, then send it to the client. Option 2 is a *very
messy* proposition.
 
M

Martin Honnen

Randy said:
If all your script is doing in the client is modifying the DOM then
converting it to a server side script should be trivial.

Why is that trivial? A client-side Greasemonkey script has full access
to the DOM of the HTML document that the browser builds but on the
server you do not have a DOM available, you have objects to deal with
HTTP requests and create responses but no DOM implementation. It depends
on the server-side framework you use what is available but I don't know
of a server side framework that allows you to read in a HTML document to
build a DOM to manipulate it before you serialize and send the
manipulated DOM to the client.
 
R

Randy Webb

Martin Honnen said the following on 1/21/2007 7:38 AM:
Why is that trivial?

Because of the last line I quoted, mostly. If all a script is doing is
removing "any img that has 'ad' in its src" then it would indeed be
trivial to remove it on the server.

As for modifying the rest of the DOM, you are correct as I chose poor
wording for my response.
 
V

VK

Jeff said:
I'd like to adapt some Greasemonkey scripts that I've written and have
them applied to html files on the server side before the files are sent
to users. I'm only looking at adapting scripts that make static
changes to pages. For instance, consider a script that removes from
the DOM any img that has "ad" in its src.

As it was already pointed by others, you can hardly remove anything
from DOM server-side, as there is no DOM yet, just raw source text. You
may of course create a virtual browser using server-side language (like
LWP and Perl) but it will make a terrible and absolutely unnecessary
overheat. A regexp parser on Perl or PHP would do the job much more
efficiently.

I have a bit OT question though: if you need to remove "any img that
has "ad" in its src" then why would you put such images into source on
the first place. And it you have a content grabber refactoring 3rd
party pages then did you come into agreement with the respective page
owners?

Now feel free to send me to hell, but I had to ask.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top