Skip to content

Instantly share code, notes, and snippets.

@xioustic xioustic/tpb_searchjson.js
Last active Jul 25, 2017

Embed
What would you like to do?
qsaArr = (el, query) => Array.prototype.slice.call(el.querySelectorAll(query))
qsArr = (el, query) => Array.prototype.slice.call(el.querySelector(query))
var results = qsaArr(document, '#main-content > #searchResult > tbody > tr');
var resultsJson = results.map((r) => {
let obj = {}
obj.el = r
obj.name = r.querySelector('.detName').textContent.trim()
obj.category = r.querySelector('.vertTh').textContent.trim()
obj.magnet = qsaArr(r, 'td > a').map(e => e.href)[0]
obj.desc = r.querySelector('.detDesc').textContent.trim()
obj.seeders = r.querySelector('td:nth-child(3)').textContent.trim()
obj.leechers = r.querySelector('td:nth-child(3)').textContent.trim()
return obj
})
var bannedStr = ['HD-TS', 'HDTC', 'HD-T', 'TC1080', 'TSRip']
resultsJson.forEach((obj) => {
for (var i = 0; i < bannedStr.length; i++) {
if (obj.name.indexOf(bannedStr[i]) !== -1) {
obj.el.parentNode.removeChild(obj.el);
break;
}
}
})
console.log(resultsJson)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.