-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeDupDescs.js
41 lines (40 loc) · 1.28 KB
/
seeDupDescs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Highlight listings, using a red border, that have matching descriptions. */
javascript:
var results = [].slice.call(document.querySelectorAll("div#sortable-results.content ul.rows li"));
var ajax = function(url, onload, onerror) {
var xhr = new XMLHttpRequest();
xhr.onload = onload;
xhr.onerror = onerror;
xhr.open('GET', url);
xhr.responseType = 'document';
xhr.send();
return xhr;
};
var reqs = [];
results.forEach(li=>{
var url = li.querySelector('a').href;
ajax(url, function() {
reqs.push({li: li, desc: this.responseXML.querySelector("section#postingbody").textContent});
doIfDone();
}, function() {
reqs.push({li: li, desc: 'NULL'});
doIfDone();
});
});
function doIfDone() {
if (reqs.length === results.length) {
for (var jx = reqs.length - 1; jx > 0; jx--) {
var li1 = reqs[jx].li;
var desc1 = reqs[jx].desc;
for (var ix = jx - 1; ix > -1; ix--) {
var li2 = reqs[ix].li;
var desc2 = reqs[ix].desc;
if (desc1 === desc2) {
li1.style.border = '1px solid red';
li2.style.border = '1px solid red';
reqs.splice(ix, 1);
}
}
}
}
}