From bcd40d9580bfd1c08708b265e09d05f38659237e Mon Sep 17 00:00:00 2001 From: Kyle K Date: Tue, 28 Mar 2017 12:39:02 -0500 Subject: CL post xhr snip --- cl-get-postingbody.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cl-get-postingbody.js diff --git a/cl-get-postingbody.js b/cl-get-postingbody.js new file mode 100644 index 0000000..26d0ec9 --- /dev/null +++ b/cl-get-postingbody.js @@ -0,0 +1,13 @@ +// use it like this: onmouseover="getCLPostBody(this)" in tag where its href contains URL to CL posting +function getCLPostBody(l) { + var xhr = new XMLHttpRequest(); + xhr.open('get', l.getAttribute('href'), true); + xhr.onload = function () { + var clpost = new DOMParser().parseFromString(xhr.responseText, "text/html"); + clpost.documentElement.innerHTML = xhr.responseText; + + var postbody = clpost.getElementById('postingbody').lastChild.wholeText.toString().trim() + return postbody; + } + xhr.send(); +} \ No newline at end of file -- cgit v1.2.3