On Aug 1, 3:43 pm, UI Architect <info %[email protected]> wrote: > I need to build an URL blocker script that would block requests to a > given set of URLs. > > With whatever knowledge I have so far, DOM doesn't have any 'change' > event itself; so practically this seems impossible. So I have changed > the problem statement to - "Remove any element from the DOM as soon as > possible after it makes a request to a blocked URL". > > 1) SCRIPT - since changing the src attribute of a SCRIPT element > doesn't make any difference to the DOM, only the new SCRIPT elements > need to be tracked against blocked URLs. > > 2) IFRAME & IMG - both of these types need to be tracked for existing > as well as new elements being added in the DOM against the blocked > URLs. > > The approach I'm thinking of is to start an interval, collect existing > target elements, check the src attributes and remove those elements > from DOM. > > And may be, innerHTML and appendChild methods can be overwritten to do > a pre-check for blocked URLs. > > Can you please suggest better approaches? I need to have a 'best > possible' solution - need not be perfect and 100% full-proof.
First - wrap XHR#open, XDR#open, WebSocket and EventSource. Second - if browser supports [gs]etters and DOM prototypes - wrap setter HTML[Image|Frame|Script|Embed]Element#src, HTMLObjectEvent#data, also Node#setAttribute method . Else if browser supports onpropertychange event - (poll DOM tree changes or use DOM mutation events), add onpropertychange and wrap setAttribute individually for each element w/ #src/data arttribute but its less effective and may be big overhead. -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
