summaryrefslogtreecommitdiffstats
path: root/cl-get-postingbody.js
blob: 26d0ec96d247ad9b0cf38470bfcc5a1f9e968c39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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();
}