Skip to content

Instantly share code, notes, and snippets.

@altilunium
Created November 20, 2022 03:50
Show Gist options
  • Save altilunium/e55d0492c4729de23700d3a948ef6903 to your computer and use it in GitHub Desktop.
Save altilunium/e55d0492c4729de23700d3a948ef6903 to your computer and use it in GitHub Desktop.
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="nyaa"></div>
</body>
<script type='text/javascript' src='tweets.js'></script>
<script>
var friends = []
function blah(i){
var t = i.tweet.full_text
var r = /(^|[^@\w])@(\w{1,15})\b/g
var m = t.matchAll(r)
for (var mm of m){
console.log(mm[2])
friends.push(mm[2])
}
}
nya.forEach(blah)
let counter = {};
for (element of friends.flat()) {
if (counter[element]) {
counter[element] += 1;
} else {
counter[element] = 1;
}
};
console.log(counter);
var items = Object.keys(counter).map(function(key) {
return [key, counter[key]];
});
items.sort(function(first, second) {
return second[1] - first[1];
});
console.log(items)
var theStr = "<table style='table-layout:fixed;width:900px'><tr style='font-weight:800'><td style='width:15%'>Username</td><td style='width:95%;'>Number of mentions</td></tr>"
function puri(i) {
theStr = theStr + "<tr><td>"+i[0]+"</td><td>"+i[1]+"</td></tr>"
}
items.forEach(puri)
theStr = theStr + "</table>"
var t = document.getElementById("nyaa")
t.innerHTML = theStr
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment