Skip to content

Instantly share code, notes, and snippets.

@schwittlick
Created August 24, 2018 14:41
Show Gist options
  • Save schwittlick/b1c9a316bb763e57a1bff2565fade8f2 to your computer and use it in GitHub Desktop.
Save schwittlick/b1c9a316bb763e57a1bff2565fade8f2 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name KG scraper
// @version 0.1
// @grant none
// ==/UserScript==
function contains(selector, text) {
var elements = document.querySelectorAll(selector);
return Array.prototype.filter.call(elements, function(element){
return RegExp(text).test(element.textContent);
});
}
var elements;
var currentIndex = 0;
var currentParent;
elements = document.querySelectorAll('[title="Download this torrent here"]');
function clickLinks() {
setInterval( function() {
currentParent = elements[currentIndex].parentElement;
currentParent.style.backgroundColor = "green";
currentParent.click();
currentIndex += 1;
if(currentIndex >= elements.length)
{
clearInterval();
result = contains('a', '>>');
result[0].style.backgroundColor = "green";
result[0].click();
}
}, 1000);
}
clickLinks();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment