Created
August 24, 2018 14:41
-
-
Save schwittlick/b1c9a316bb763e57a1bff2565fade8f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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