state of server-side javascript

Discussion in 'Javascript' started by Jeff, Jan 20, 2007.

  1. Jeff

    Jeff Guest

    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
     
    Jeff, Jan 20, 2007
    #1
    1. Advertising

  2. Jeff

    Hal Rosser Guest

    "Jeff" <> wrote in message
    news:...
    > 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.
     
    Hal Rosser, Jan 20, 2007
    #2
    1. Advertising

  3. Jeff

    Randy Webb Guest

    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/
     
    Randy Webb, Jan 20, 2007
    #3
  4. 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/
     
    Martin Honnen, Jan 21, 2007
    #4
  5. Jeff

    Randy Webb Guest

    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/
     
    Randy Webb, Jan 21, 2007
    #5
  6. Jeff

    VK Guest

    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.
     
    VK, Jan 22, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Qw==?=
    Replies:
    1
    Views:
    3,277
    Hermit Dave
    Jan 16, 2004
  2. Shaul Feldman
    Replies:
    0
    Views:
    872
    Shaul Feldman
    Apr 16, 2004
  3. Guadala Harry
    Replies:
    4
    Views:
    1,545
    =?Utf-8?B?aGFyaSBwcmFzYWQ=?=
    Jun 15, 2004
  4. nick
    Replies:
    3
    Views:
    3,246
    Eliyahu Goldin
    Dec 15, 2004
  5. Alexandre Morgaut

    State of the art: Server-side JavaScript

    Alexandre Morgaut, Sep 5, 2011, in forum: Javascript
    Replies:
    0
    Views:
    518
    Alexandre Morgaut
    Sep 5, 2011
Loading...

Share This Page