Created
October 21, 2016 09:55
-
-
Save TimBroddin/5f58ac1f7c8812cc70f521662b687149 to your computer and use it in GitHub Desktop.
This file contains 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
function pressButton() { | |
var btn = document.querySelector('[class="_l086v _ifrvy"]'); | |
if (btn) { | |
console.log('Found a button, clicking'); | |
var event = document.createEvent("HTMLEvents"); | |
event.initEvent("click", true, true); | |
btn.dispatchEvent(event); | |
setTimeout(function () { | |
pressButton(); | |
}, 1000); | |
} else { | |
console.log('No button found, outputting names:') | |
var elements = document.querySelectorAll('article li'); | |
var results = []; | |
elements.forEach((el) => { | |
var a = el.querySelector('a'); | |
var span = el.querySelector('span'); | |
var double = false; | |
results.forEach((res) => { | |
if (res.name === a.innerHTML) { | |
double = true | |
} | |
}); | |
if (a.innerHTML.indexOf('#') === -1 && a.innerHTML.indexOf('@') === -1 && !double) { | |
results.push({name: a.innerHTML, comment: span.innerText}); | |
} | |
}); | |
console.log('Found ' + results.length + ' names'); | |
render(results); | |
} | |
} | |
function render(results) { | |
let divs = []; | |
results.forEach((res, k) => { | |
divs.push(` | |
<div> | |
<p><strong>${res.name}</strong></p> | |
<p>${res.comment}</p> | |
</div> | |
`) | |
if (k % 9 === 8) { | |
divs.push('<hr />'); | |
} | |
}); | |
let html = `<html> | |
<head> | |
<style> | |
body { | |
font-family: Verdana; | |
} | |
div { | |
font-size: 12px; | |
float: left; | |
margin: 5px; | |
border: 2px solid #333; | |
padding: 10px; | |
width: 200px; | |
height: 300px; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
flex-direction: column; | |
} | |
hr { | |
clear: both; | |
visibility: hidden; | |
height: 0px; | |
page-break-after: always; | |
} | |
</style> | |
</head> | |
<body> | |
${divs.join("\n")} | |
</body> | |
</html> | |
`; | |
document.write(html); | |
} | |
pressButton(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment