Last active
December 15, 2016 04:37
-
-
Save trungdq88/c41f6932435f0876f3ae9bef10b5f208 to your computer and use it in GitHub Desktop.
SSS Kraken filter
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
(function () { | |
String.prototype.padRight = function(l,c) {return this+Array(l-this.length+1).join(c||" ")}; | |
// intersection | |
const intersect = xs => ys => { | |
const zs = createSet(ys); | |
return filter(x => zs.has(x) | |
? true | |
: false | |
) (xs); | |
}; | |
const $ = document.querySelector.bind(document); | |
$("[href='/archives/snack']").click(); | |
if (!$('#details_toggle').classList.contains('active')) { | |
$('#details_toggle').click() | |
} | |
if (!$('#channel_page_all_members')) { | |
$('#member_count_title').click(); | |
} | |
const kraken = $('#channel_page_all_members').innerText.split('\n'); | |
const changed = $('#channel_topic_text').innerText.split(/[\s+,@]+/); | |
$("[href='/archives/pirate-island']").click() | |
if (!$('#details_toggle').classList.contains('active')) { | |
$('#details_toggle').click() | |
} | |
if (!$('#channel_page_all_members')) { | |
$('#member_count_title').click(); | |
} | |
const people = $('#channel_page_all_members').innerText.split('\n'); | |
const dead = $('#channel_topic_text').innerText.split(/[\s+,@]+/); | |
const getStatus = username => { | |
let role = 'π±'; | |
let status = ''; | |
let name = username.replace('(you)', '(ΔαΊΉp trai)'); | |
if (kraken.indexOf(name) > -1) { | |
role = 'πΎ'; | |
} | |
if (changed.indexOf(name) > -1) { | |
role = 'π'; | |
} | |
if (dead.indexOf(name) > -1) { | |
status = 'π'; | |
} | |
return (role + status + ' ' + name).padRight(25); | |
} | |
const deadKraken = intersect(kraken, dead); | |
const deadPeople = intersect(people, dead); | |
const deadChanged = intersect(changed, dead); | |
const board = people.filter(a => a).map(getStatus); | |
console.log(`%cπΎ Kraken alive: ${kraken.length - deadKraken.length} | \ | |
π± People alive: ${people.length - kraken.length - deadPeople.length} | |
π Changed: ${changed.length} (${deadChanged.length} dead) | \ | |
π Total Dead: ${dead.length}`, | |
'font-weight: bold'); | |
console.log('\n' + board.sort().join('\t')); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment