LongURL Mobile Expander

By Sean Murphy Last update Jun 2, 2009 — Installed 12,479 times.

Patch for AJAX Loaded Content

in
Subscribe to Patch for AJAX Loaded Content 2 posts, 2 voices



kleingeist Scriptwright

With this patch LongURL Mobile Expander will handle AJAXA Loaded Content like the new posts you get when you click "more" on twitter.


--- 32115.user.js	2009-05-13 13:25:25.015625000 +0200
+++ longurl_mobile_expander.user.js	2009-05-13 13:30:08.843750000 +0200
@@ -45,6 +45,7 @@
 			onload: function(response) {
 				saveSupportedServices(response);
 				modifyShortLinks();
+				document.addEventListener("DOMNodeInserted", function(e) {modifyShortLinks(e.relatedNode);}, false);
 			}
 		});
 	};
@@ -78,8 +79,12 @@
 		setValue('longurl_expire_services', date.toUTCString());
 	};
 	
-	modifyShortLinks = function() {
-		var links = document.evaluate("//a[@href]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+	modifyShortLinks = function(context) {
+		if (typeof context == 'undefined') {
+			context = document
+		}
+		
+		var links = document.evaluate("//a[@href]", context, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
 		
 		for (var x = 0; x < links.snapshotLength; x++) {
 		    var a = links.snapshotItem(x);
@@ -275,6 +280,7 @@
 	if (serialized_services && services_expire > now.getTime()) {
 		this.known_services = eval('(' + serialized_services + ')');
 		modifyShortLinks();
+		document.addEventListener("DOMNodeInserted", function(e) {modifyShortLinks(e.relatedNode);}, false);
 	} else {
 		getServicesFromAPI();
 	}

 
Sean Murphy Script's Author

Thanks! I have a new version of the script I'm currently working on which adds support for this. I should be releasing it within the next week.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel