Hey, What you want to do is add a "DOMNodeInserted" event listener to the document, or an element lower down in the tree containing the updated search results, which will check for any results that exist that haven't already been updated by your script. For the last bit I usually add a custom attribute to some tag when I'm done, so that if I have to check again I can easily tell that my work is done.
This http://userscripts.org/scripts/review/56369 is a userscript I wrote for Google Analytics, which adds a "DOMNodeInserted" event listener to the document and checks if a piece of text way at the bottom of the table (which is updated by ajax) has a link by checking for the existence of an attribute on a particular node; it should be similar in outline to what you want to do. Erik On Sep 10, 9:46 am, PhillySaxon <[email protected]> wrote: > I'm having some trouble calling my script after a page makes an AJAX > call to load a new page. > > Basically, I'm trying to create a script forhttp://4walled.org/that > changes a portion of the links on the search page from "edit.php? > filename=" to simply "src/", so the links link straight to the image > instead of the meaningless "edit" page, with the direct link on it. > > The script works just fine on the first set of images, but when you > scroll to the bottom of the page the site makes a jQuery call to load > a new page dynamically. The result, the first set of links are just > fine with "http://4walled.org/src/image.jpg", but the dynamically > loaded links are still linking to "http://4walled.org/edit.php? > filename=image.jpg". I know I need to call the script again after the > AJAX call, but I'm not sure exactly how. > > Here it is so far (sorry if the code's sloppy): > > // ==UserScript== > // @name 4walled Direct Links > // @namespace about:blank > // @description Changes links in the 4walled gallery to direct links. > By PhillySaxon. > // @include http://4walled.org/* > // ==/UserScript== > > function convertLinks() { > var allLinks = document.getElementsByTagName('a') > > for(var i=0; i < allLinks.length; i++) { > if (allLinks[i].href.match('/?edit')){ > allLinks[i].href = > allLinks[i].href.replace('/edit.php?filename=','/ > src/'); > allLinks[i].href = allLinks[i].href += '';} > } > > } > > convertLinks(); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "greasemonkey-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en -~----------~----~----~----~------~----~------~--~---
