Results 1 to 7 of 7

Thread: JavaScript arrays & Pacfiles

  1. #1
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JavaScript arrays & Pacfiles

    hi all

    don't know if anyone will be able to help with this but i'll ask anyway is it possible use a pacfile to selectively remove elements from a page ???

    would it be possible to write an array that would allow the selective removal of ad related iframes from a page ??

    for instance when i login to hotmail i see an ad banner loaded in an iframe at the top of the page here is the code

    Code:
    <IFRAME 
    FRAMEBORDER=0 
    SCROLLING=NO 
    MARGINHEIGHT=0 
    MARGINWIDTH=0 
    WIDTH=728 
    HEIGHT=90 
    SRC="http://rad.msn.com/ADSAdClient31.dll?GetAd=&PG=HOTJ42&TF=_NEW&AP=1011" tabindex="-1">
    </IFRAME>
    now presently the ad in question is blocked by the host file but I'm left with a large area of white space where the ad should be and I'd like to know if its possible to remove this white space by having the pacfile remove the iframe much the same way the Greasemonkey iframe killer script does ??

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This is thin ice around here as we are not allowed to discuss removing any ad that is required by a TOS* agreement. If it is for your personal use only, I believe there are several browsers that will do this for you.

    Now, so long as this is not for public use, what is a pacfile?



    *TOS - Terms of Service
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Shady huh..

    There is a Firefox addon for what you want. It is called Adblock.
    If it is for private use, use adblock, go to the page, rightclick the image and remove it.

    It is great for dial-up as it stops the advert from loading!

  4. #4
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This is thin ice around here as we are not allowed to discuss removing any ad that is required by a TOS* agreement. If it is for your personal use only, I believe there are several browsers that will do this for you.
    fair enough

    Now, so long as this is not for public use, what is a pacfile?
    have a read of this it should give a reasonable explanation of what a pacfile is

    http://en.wikipedia.org/wiki/Proxy_auto-config

    and this link gives a short Lists of some predefined functions available for use

    http://wp.netscape.com/eng/mozilla/2...roxy-live.html

    now as it happens the pacfile contains a couple of useful functions which allow us to do content filtering in a similar fashion to a host file only a pacfile is more powerful as it can use regular expressions shell expressions and arrays which allows us to be much more selective

    where a host file can only block whole domains a pacfile can be much more specific and block only specific contents such as scripts that might be trying to do questionable things like tracking

    now in this case I'm trying to block the loading of iframes partly for content filtering purposes but also for security purposes as i have been made aware of some security problems with iframes that could be exploited that would allow execution of malicious code on my computer

    now so far as i am aware there is only 2 ways to deal with this disable java which isn't an option or disable the use of iframes now opera offers a function like that but other browsers don't which is why I'm trying to find out if there is some code i could add to my pacfile that can do this across all browsers

    now as for ad block this is a fine tool but problem is that it only works for firefox I'm looking for something that works across browsers which is why I'm using a pacfile coz this will work with any modern browser

    in any event back to the question at hand is it possible to code an array that would allow me to prevent the loading of iframes ?? there by preventing any security problems and also removing white space created by empty iframes

    now the following Greasemonkey user script does precisely this

    Code:
    // ==UserScript==
    // @namespace     http://javascript.about.com
    // @author        Stephen Chapman
    // @name          iframe killer
    // @description   deletes all iframes from a web page
    // @include       http://example.com/
    // ==/UserScript==
    
    while((el=document.getElementsByTagName('iframe')).length){el[0].parentNode.removeChild(el[0]);}
    now what I'm wondering is if this could be made to work inside of a pacfile ?? unfortunately my attempts at this have thus far proven unsuccessful i assume however this is purely due to my lack of javascript knowledge
    Last edited by Bethrezen; 04-21-2007 at 01:13 AM.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    A PAC script has access to only the URL and the host, and can only modify the proxy used to access the resource. In order to alter the page somehow, you would need to have access to the page requested, as well as be able to supply an altered page to the browser. To do that, you'd need not only to be able to specify the proxy, but also to be the proxy: this sort of on-the-fly modification can only be performed by a proxy. Have a look at Privoxy's filtering capabilities.

    Dear gods, it's approaching 0300 again. Pardon me for what sounds in my head (I can't concentrate enough to actually read it) like a ramble.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hi

    if its not possible to actually remove an element from a page would it be possible to at least modify a given element allowing me to perform content hiding the way adblock does ??

    so if there was a large area of white space created by an empty iframe coz i'd blocked its contents would it be possible to resize that iframe to 0x0 pixels

    also just out of curiosity how precisely does that iframe killing script work ??

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No, there is no way to alter the contents of the page at all using a PAC file. You'd need to have either a client-side script running with access to the page or a proxy.

    GreaseMonkey scripts work by altering the page once it has already been downloaded to the user's computer. That particular one simply goes through each <iframe> in the DOM and removes its association with its parent node, effectively deleting it.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •