Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > state of server-side javascript

Reply
Thread Tools

state of server-side javascript

 
 
Jeff
Guest
Posts: n/a
 
      01-20-2007
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

 
Reply With Quote
 
 
 
 
Hal Rosser
Guest
Posts: n/a
 
      01-20-2007

"Jeff" <> wrote in message
news: ups.com...
> 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.


 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      01-20-2007
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.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      01-21-2007
Randy Webb wrote:

>> 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.


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.



--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      01-21-2007
Martin Honnen said the following on 1/21/2007 7:38 AM:
> Randy Webb wrote:
>
>>> 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.

>
> 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.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      01-22-2007

Jeff wrote:
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript drop down list for state state selection doesn't work JRough Javascript 3 10-07-2009 07:22 PM
javascript drop down list for state state selection doesn't work JRough Javascript 0 10-07-2009 04:14 PM
Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'. Mike Larkin ASP .Net 1 05-23-2005 12:33 PM
What is the state of state machine after power-up without reset conditions Weng Tianxiang VHDL 7 11-25-2003 06:24 PM
State machine: how to stay in a state? David Lamb VHDL 1 09-15-2003 05:24 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57