diff options
-rw-r--r-- | cl-get-postingbody.js | 13 |
1 files changed, 13 insertions, 0 deletions
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 <a> 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 |