Page 53 of 173

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:46 pm
by Sabiplz
Creature wrote: Sun Dec 04, 2022 7:45 pm Ok idk where to go

I'm mostly trusting nutella on arogame123
Aren't you still voting Chelsea

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:46 pm
by EnderWiggin
Sabiplz wrote: Sun Dec 04, 2022 7:45 pm I'm so npc, look at me being npc
Same

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:46 pm
by Lumi
Spoiler: show

Code: Select all

// ==UserScript==
// @name         Secret Playerlist Vote Counter
// @namespace    mailto:luminouslag@gmail.com
// @version      1.0
// @description  Automatic Vote Counting for Secret Plyerlist Mafia game on The Syndicate
// @author       Lumi
// @match        https://mafiathesyndicate.com/viewtopic.php?*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=mafiathesyndicate.com
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_setClipboard
// ==/UserScript==

console.log('Script Initialized');

async function getDocument(thread, start) {
  return await window.fetch(`https://mafiathesyndicate.com/viewtopic.php?t=${thread}&start=${start}`).then(r => r.text()).then(html => (new DOMParser()).parseFromString(html, 'text/html'));
}

function getDataFromPost(post) {
  let postNum = post.getElementsByClassName('post-number')[0].textContent.match(/[0-9]+/g)[0];
  let contentChildren = post.getElementsByClassName('content')[0].children;
  let author = post.getElementsByClassName('author')[1].getElementsByTagName('a')[1].textContent;
  let currentVoteTarget = null;
  for (const contentChild of contentChildren) {
    if (contentChild.classList.contains('mention')) {
      let voteTarget = contentChild.textContent.replaceAll('\n','').matchAll(/\[VOTE: ([^\]]*)\]/g).next().value;
      if (voteTarget) currentVoteTarget = voteTarget[1];
    }
  }
  return {
    number: postNum,
    target: currentVoteTarget,
    author: author,
  };
}

function isCorrectThread(targetNum) {
  let topicNum = document.getElementsByClassName("topic-title")[0].children[0].href.matchAll(/\?t=([0-9]+)&/g).next().value[1];
  return topicNum == targetNum;
};

function getNumPosts() {
  return parseInt(document.getElementsByClassName('pagination')[0].textContent.matchAll(/([0-9]*) posts/g).next().value[1]);
};

function getFirstPostNumOfThisPage() {
  return parseInt(document.getElementsByClassName('post')[0].getElementsByClassName('post-number')[0].textContent.match(/[0-9]+/g)[0]);
}

function tallyPage(voteHistory, page) {
  let posts = page.getElementsByClassName('post');
  for (const post of posts) {
    let postData = getDataFromPost(post);
    if (parseInt(postData.number) == voteHistory.length + 1) {
      voteHistory.push(postData);
    }
  }
  return voteHistory;
}

function handleKeyUp(e) {
    let isNum = (e.keyCode >= 48 && e.keyCode <= 57);
    let isV = (e.keyCode == 86);
    let isR = (e.keyCode == 82);
    let isX = (e.keyCode == 88);
    if (isV && e.altKey) {
      let currentDay = 1;
      for(let i=1; i<=10; i++) {
        if (GM_getValue(`EoD${i}`, 0) != 0) currentDay++;
      }
      let voteCount = calcVoteCount(currentDay);
      GM_setClipboard(voteCount);
    } else if (isR && e.altKey) {
      let day = parseInt(prompt('Enter Day Number'));
      let voteCount = calcVoteCount(day);
      GM_setClipboard(voteCount);
    } else if ( isNum && e.altKey) {
      let num = parseInt(e.key);
      if (num == 0) num = 10;
      let postNum = prompt(`Enter Post Number for EoD ${num}`)
      GM_setValue(`EoD${num}`, parseInt(postNum));
    } else if ( isX && e.altKey) {
      window.location.href = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
    }
};

function calcVoteCount(day) {
  let SoD = GM_getValue(`EoD${day-1}`, 0);
  let EoD = GM_getValue(`EoD${day}`, 0);
  voteHistory = JSON.parse(GM_getValue(`voteHistory`), '[]');

  let voteTargets = {};
  let postCounts = {};

  for (const vote of voteHistory) {
    if ((vote.number >= SoD || SoD == 0) && (vote.number <= EoD || EoD == 0)) {
      if (!(vote.author in voteTargets)) {
        voteTargets[vote.author] = null;
        postCounts[vote.author] = 1;
      } else {
        postCounts[vote.author] += 1;
      }
      if (vote.target != null) voteTargets[vote.author] = [vote.target, vote.number];
    }
  }

  let voteCount = {};
  
  for (const [key, value] of Object.entries(voteTargets) ) {
    if (value != null) {
      let target = value[0].toLowerCase();
      if (target in voteCount) {
        voteCount[target].push([key, value[1], postCounts[key]]);
      } else {
        voteCount[target] = [[key, value[1], postCounts[key]]];
      }
    } else {
      if ('Not Voting' in voteCount) {
        voteCount['Not Voting'].push([key, null, postCounts[key]]);
      } else {
        voteCount['Not Voting'] = [[key, null, postCounts[key]]];
      }
    }
  }

  return voteCountToString(voteCount);
}

function voteToString(vote) {
  if (vote[1] == null) return `${vote[0]} (${vote[2]})`
  return `[url=https://mafiathesyndicate.com/viewtopic.php?t=2451&start=${vote[1]-1}]${vote[0]}[/url] (${vote[2]})`
}

function voteCountToString(voteCount) {
  let output = '';
  for (const [key, value] of Object.entries(voteCount)) {
    let valueStrings = [];
    for (const vote of value) {
      valueStrings.push(voteToString(vote));
    }
    output += `${key} (${value.length}): ${valueStrings.join(', ')}\n`
  }
  return output;
}

if (isCorrectThread(2451)) {
  let voteHistory = JSON.parse(GM_getValue(`voteHistory`, '[]'));
  let numPosts = getNumPosts();
  let curVoteHistoryLength = voteHistory.length;
  while (voteHistory.length < numPosts) {
    let page = await getDocument(2451, voteHistory.length);
    voteHistory = tallyPage(voteHistory, page);
    if (voteHistory.length == curVoteHistoryLength) break;
  }
  GM_setValue(`voteHistory`, JSON.stringify(voteHistory));

  document.addEventListener('keyup', handleKeyUp, false);
};
It's a Tampermonkey script. Probably works on Greasemonkey too.

Hotkeys:
Alt + V - Copy current vote count to your clipboard
Alt + X - Automatically win the game
Alt + 1 - Set EoD post number for day 1
Alt + 2 - Set EoD post number for day 2
...
Alt + 0 - Set EoD post number for day 10

In setting EoD numbers the current day is calculated by which days don't have an EoD set, if you accidentally set an EoD value, you can reset it by setting it to 0.

Alt + R - Copy vote count for a previous day to your clipboard - this feature can also be used to get retrospective vote counts of any post number with a little bit of creativity (hint: set the EoD post number to the post you want to have the retrospective vote count on)

After pressing these hotkeys you have to Ctrl + V to post the vote count.



I'm sure there are lots of bugs! If wolves have mercy on me and let me live the night I can help fix them :joy_cat:

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:46 pm
by Guillotine
Hmmm [VOTE: Chelsea] aubergine

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:46 pm
by risiinq-
oh geez dizzy voted me too at one point

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:47 pm
by Sabiplz
Rip to those that phone post

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:47 pm
by c4e5g3d5
risiinq- wrote: Sun Dec 04, 2022 7:46 pm is it eod?

why are we hanging aro?
nut pushed him

He isn't towny to me ig

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:47 pm
by Lumi
Not Voting (12): MacDougall (26), NANOOKTHEGREATANDFEARSOME (13), Lilypetal (15), SilverKeith (44), Inawordyes (11), Michelle (42), JaggedJimmyJay (30), risiinq- (38), sabie12 (2), Fext (5), Porscha (47), DrWilgy (15)
chelsea (6): Golden (47), Scotty (37), Guillotine (146), ilario (38), Neon (69), ~Prince J~ (18)
arogame (3): nutella (120), Creature (69), tutuu (25)
c4e5g3d5 (1): Marmot (74)
unvote (3): iaafr (132), WindwardAway (101), arogame123 (61)
lily (1): falcon45ca (17)
trans rights (1): katze (87)
golden (5): EnderWiggin (100), Dyslexicon (54), DeeZees (19), lucy (19), Vivax (18)
master radishes (2): Sloonei (24), sprityo (18)
c4e5g3d5 (1): c4e5g3d5 (77)
jaggedjimmyjay (1): Jackofhearts2005 (62)
jackofhearts2005 (1): Schiavetto (17)
scotty (1): Hally (116)
guillotine (1): santygrass (29)
golden (1): RondoDimBuckle (119)
manny (1): Manny (165)
whomever owns this hellsite (1): hollowkatt (63)
sloonei (2): Ricochet (5), pyxxy (7)
macdougal (1): Seanzie (5)
test (1): Lumi (32)
risiinq~ (1): Ranmilia (31)
arogame (1): Sabiplz (237)
golden the coward (1): G-Man (17)
iaafr (1): Chelsea (11)
michelle (1): TonyStarkPrime (31)

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:47 pm
by Creature
risiinq- wrote: Sun Dec 04, 2022 7:46 pm is it eod?

why are we hanging aro?
I guess there was a decent wolfcase on arogame123 and that may be the only decent wolfcase in the game

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:47 pm
by Creature
Sabiplz wrote: Sun Dec 04, 2022 7:46 pm
Creature wrote: Sun Dec 04, 2022 7:45 pm Ok idk where to go

I'm mostly trusting nutella on arogame123
Aren't you still voting Chelsea
I'm on arogame123 afair

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:48 pm
by Sabiplz
@Lumi why is my vote not counting

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:48 pm
by katze
i am like 100% confident that [REDACTED] is a wolf/wolfsiding npc and they have been voted like 0 times all game

wild, y'all need to git gud

uwu

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:48 pm
by risiinq-
imo when i was on aro was decently towny but like w/e

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:48 pm
by c4e5g3d5
Lumi wrote: Sun Dec 04, 2022 7:47 pm Not Voting (12): MacDougall (26), NANOOKTHEGREATANDFEARSOME (13), Lilypetal (15), SilverKeith (44), Inawordyes (11), Michelle (42), JaggedJimmyJay (30), risiinq- (38), sabie12 (2), Fext (5), Porscha (47), DrWilgy (15)
chelsea (6): Golden (47), Scotty (37), Guillotine (146), ilario (38), Neon (69), ~Prince J~ (18)
arogame (3): nutella (120), Creature (69), tutuu (25)
c4e5g3d5 (1): Marmot (74)
unvote (3): iaafr (132), WindwardAway (101), arogame123 (61)
lily (1): falcon45ca (17)
trans rights (1): katze (87)
golden (5): EnderWiggin (100), Dyslexicon (54), DeeZees (19), lucy (19), Vivax (18)
master radishes (2): Sloonei (24), sprityo (18)
c4e5g3d5 (1): c4e5g3d5 (77)
jaggedjimmyjay (1): Jackofhearts2005 (62)
jackofhearts2005 (1): Schiavetto (17)
scotty (1): Hally (116)
guillotine (1): santygrass (29)
golden (1): RondoDimBuckle (119)
manny (1): Manny (165)
whomever owns this hellsite (1): hollowkatt (63)
sloonei (2): Ricochet (5), pyxxy (7)
macdougal (1): Seanzie (5)
test (1): Lumi (32)
risiinq~ (1): Ranmilia (31)
arogame (1): Sabiplz (237)
golden the coward (1): G-Man (17)
iaafr (1): Chelsea (11)
michelle (1): TonyStarkPrime (31)
Lol why do I have two wagons

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:48 pm
by Guillotine
Sorry Chelsea, i townread yiu but you gotta go, you can become dangerous later

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:49 pm
by Creature
Lumi wrote: Sun Dec 04, 2022 7:47 pm Not Voting (12): MacDougall (26), NANOOKTHEGREATANDFEARSOME (13), Lilypetal (15), SilverKeith (44), Inawordyes (11), Michelle (42), JaggedJimmyJay (30), risiinq- (38), sabie12 (2), Fext (5), Porscha (47), DrWilgy (15)
chelsea (6): Golden (47), Scotty (37), Guillotine (146), ilario (38), Neon (69), ~Prince J~ (18)
arogame (3): nutella (120), Creature (69), tutuu (25)
c4e5g3d5 (1): Marmot (74)
unvote (3): iaafr (132), WindwardAway (101), arogame123 (61)
lily (1): falcon45ca (17)
trans rights (1): katze (87)
golden (5): EnderWiggin (100), Dyslexicon (54), DeeZees (19), lucy (19), Vivax (18)
master radishes (2): Sloonei (24), sprityo (18)
c4e5g3d5 (1): c4e5g3d5 (77)
jaggedjimmyjay (1): Jackofhearts2005 (62)
jackofhearts2005 (1): Schiavetto (17)
scotty (1): Hally (116)
guillotine (1): santygrass (29)
golden (1): RondoDimBuckle (119)
manny (1): Manny (165)
whomever owns this hellsite (1): hollowkatt (63)
sloonei (2): Ricochet (5), pyxxy (7)
macdougal (1): Seanzie (5)
test (1): Lumi (32)
risiinq~ (1): Ranmilia (31)
arogame (1): Sabiplz (237)
golden the coward (1): G-Man (17)
iaafr (1): Chelsea (11)
michelle (1): TonyStarkPrime (31)
arogame has four votes but the wagon is split in two with 3 and 1 votes

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:49 pm
by Sabiplz
240'ed and doubled the post cap.

Gn

Gl

💕

Mommy. Loves. You.

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:49 pm
by katze
Sabiplz wrote: Sun Dec 04, 2022 7:49 pm 240'ed and doubled the post cap.

Gn

Gl

💕

Mommy. Loves. You.
i dont love any of u lol

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:49 pm
by Creature
Sabiplz wrote: Sun Dec 04, 2022 7:48 pm @Lumi why is my vote not counting
Maybe because you're prob dying this EOD

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:49 pm
by Lumi
Sabiplz wrote: Sun Dec 04, 2022 7:48 pm @Lumi why is my vote not counting
Good question, it's probably something dumb like you included a space or newline and they didn't :joy_cat:

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:50 pm
by Guillotine
Nutella is a player if she didnt post cap lol

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:50 pm
by Lumi
Ya @Sabiplz
You have a leading space in your vote.

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:50 pm
by Creature
Guillotine wrote: Sun Dec 04, 2022 7:50 pm Nutella is a player if she didnt post cap lol
Rondo might very well be a player here tbh

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:50 pm
by tutuu
Lumi wrote: Sun Dec 04, 2022 7:46 pm
Spoiler: show

Code: Select all

// ==UserScript==
// @name         Secret Playerlist Vote Counter
// @namespace    mailto:luminouslag@gmail.com
// @version      1.0
// @description  Automatic Vote Counting for Secret Plyerlist Mafia game on The Syndicate
// @author       Lumi
// @match        https://mafiathesyndicate.com/viewtopic.php?*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=mafiathesyndicate.com
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_setClipboard
// ==/UserScript==

console.log('Script Initialized');

async function getDocument(thread, start) {
  return await window.fetch(`https://mafiathesyndicate.com/viewtopic.php?t=${thread}&start=${start}`).then(r => r.text()).then(html => (new DOMParser()).parseFromString(html, 'text/html'));
}

function getDataFromPost(post) {
  let postNum = post.getElementsByClassName('post-number')[0].textContent.match(/[0-9]+/g)[0];
  let contentChildren = post.getElementsByClassName('content')[0].children;
  let author = post.getElementsByClassName('author')[1].getElementsByTagName('a')[1].textContent;
  let currentVoteTarget = null;
  for (const contentChild of contentChildren) {
    if (contentChild.classList.contains('mention')) {
      let voteTarget = contentChild.textContent.replaceAll('\n','').matchAll(/\[VOTE: ([^\]]*)\]/g).next().value;
      if (voteTarget) currentVoteTarget = voteTarget[1];
    }
  }
  return {
    number: postNum,
    target: currentVoteTarget,
    author: author,
  };
}

function isCorrectThread(targetNum) {
  let topicNum = document.getElementsByClassName("topic-title")[0].children[0].href.matchAll(/\?t=([0-9]+)&/g).next().value[1];
  return topicNum == targetNum;
};

function getNumPosts() {
  return parseInt(document.getElementsByClassName('pagination')[0].textContent.matchAll(/([0-9]*) posts/g).next().value[1]);
};

function getFirstPostNumOfThisPage() {
  return parseInt(document.getElementsByClassName('post')[0].getElementsByClassName('post-number')[0].textContent.match(/[0-9]+/g)[0]);
}

function tallyPage(voteHistory, page) {
  let posts = page.getElementsByClassName('post');
  for (const post of posts) {
    let postData = getDataFromPost(post);
    if (parseInt(postData.number) == voteHistory.length + 1) {
      voteHistory.push(postData);
    }
  }
  return voteHistory;
}

function handleKeyUp(e) {
    let isNum = (e.keyCode >= 48 && e.keyCode <= 57);
    let isV = (e.keyCode == 86);
    let isR = (e.keyCode == 82);
    let isX = (e.keyCode == 88);
    if (isV && e.altKey) {
      let currentDay = 1;
      for(let i=1; i<=10; i++) {
        if (GM_getValue(`EoD${i}`, 0) != 0) currentDay++;
      }
      let voteCount = calcVoteCount(currentDay);
      GM_setClipboard(voteCount);
    } else if (isR && e.altKey) {
      let day = parseInt(prompt('Enter Day Number'));
      let voteCount = calcVoteCount(day);
      GM_setClipboard(voteCount);
    } else if ( isNum && e.altKey) {
      let num = parseInt(e.key);
      if (num == 0) num = 10;
      let postNum = prompt(`Enter Post Number for EoD ${num}`)
      GM_setValue(`EoD${num}`, parseInt(postNum));
    } else if ( isX && e.altKey) {
      window.location.href = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
    }
};

function calcVoteCount(day) {
  let SoD = GM_getValue(`EoD${day-1}`, 0);
  let EoD = GM_getValue(`EoD${day}`, 0);
  voteHistory = JSON.parse(GM_getValue(`voteHistory`), '[]');

  let voteTargets = {};
  let postCounts = {};

  for (const vote of voteHistory) {
    if ((vote.number >= SoD || SoD == 0) && (vote.number <= EoD || EoD == 0)) {
      if (!(vote.author in voteTargets)) {
        voteTargets[vote.author] = null;
        postCounts[vote.author] = 1;
      } else {
        postCounts[vote.author] += 1;
      }
      if (vote.target != null) voteTargets[vote.author] = [vote.target, vote.number];
    }
  }

  let voteCount = {};
  
  for (const [key, value] of Object.entries(voteTargets) ) {
    if (value != null) {
      let target = value[0].toLowerCase();
      if (target in voteCount) {
        voteCount[target].push([key, value[1], postCounts[key]]);
      } else {
        voteCount[target] = [[key, value[1], postCounts[key]]];
      }
    } else {
      if ('Not Voting' in voteCount) {
        voteCount['Not Voting'].push([key, null, postCounts[key]]);
      } else {
        voteCount['Not Voting'] = [[key, null, postCounts[key]]];
      }
    }
  }

  return voteCountToString(voteCount);
}

function voteToString(vote) {
  if (vote[1] == null) return `${vote[0]} (${vote[2]})`
  return `[url=https://mafiathesyndicate.com/viewtopic.php?t=2451&start=${vote[1]-1}]${vote[0]}[/url] (${vote[2]})`
}

function voteCountToString(voteCount) {
  let output = '';
  for (const [key, value] of Object.entries(voteCount)) {
    let valueStrings = [];
    for (const vote of value) {
      valueStrings.push(voteToString(vote));
    }
    output += `${key} (${value.length}): ${valueStrings.join(', ')}\n`
  }
  return output;
}

if (isCorrectThread(2451)) {
  let voteHistory = JSON.parse(GM_getValue(`voteHistory`, '[]'));
  let numPosts = getNumPosts();
  let curVoteHistoryLength = voteHistory.length;
  while (voteHistory.length < numPosts) {
    let page = await getDocument(2451, voteHistory.length);
    voteHistory = tallyPage(voteHistory, page);
    if (voteHistory.length == curVoteHistoryLength) break;
  }
  GM_setValue(`voteHistory`, JSON.stringify(voteHistory));

  document.addEventListener('keyup', handleKeyUp, false);
};
It's a Tampermonkey script. Probably works on Greasemonkey too.

Hotkeys:
Alt + V - Copy current vote count to your clipboard
Alt + X - Automatically win the game
Alt + 1 - Set EoD post number for day 1
Alt + 2 - Set EoD post number for day 2
...
Alt + 0 - Set EoD post number for day 10

In setting EoD numbers the current day is calculated by which days don't have an EoD set, if you accidentally set an EoD value, you can reset it by setting it to 0.

Alt + R - Copy vote count for a previous day to your clipboard - this feature can also be used to get retrospective vote counts of any post number with a little bit of creativity (hint: set the EoD post number to the post you want to have the retrospective vote count on)

After pressing these hotkeys you have to Ctrl + V to post the vote count.



I'm sure there are lots of bugs! If wolves have mercy on me and let me live the night I can help fix them :joy_cat:
Very cool, good job!

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:50 pm
by Sabiplz
[VOTE: arogame] aubergine

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:50 pm
by Marmot
ITA Hally

hehe

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:51 pm
by Sabiplz
How about now

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:51 pm
by Lumi
c4e5g3d5 wrote: Sun Dec 04, 2022 7:48 pm
Lumi wrote: Sun Dec 04, 2022 7:47 pm Not Voting (12): MacDougall (26), NANOOKTHEGREATANDFEARSOME (13), Lilypetal (15), SilverKeith (44), Inawordyes (11), Michelle (42), JaggedJimmyJay (30), risiinq- (38), sabie12 (2), Fext (5), Porscha (47), DrWilgy (15)
chelsea (6): Golden (47), Scotty (37), Guillotine (146), ilario (38), Neon (69), ~Prince J~ (18)
arogame (3): nutella (120), Creature (69), tutuu (25)
c4e5g3d5 (1): Marmot (74)
unvote (3): iaafr (132), WindwardAway (101), arogame123 (61)
lily (1): falcon45ca (17)
trans rights (1): katze (87)
golden (5): EnderWiggin (100), Dyslexicon (54), DeeZees (19), lucy (19), Vivax (18)
master radishes (2): Sloonei (24), sprityo (18)
c4e5g3d5 (1): c4e5g3d5 (77)
jaggedjimmyjay (1): Jackofhearts2005 (62)
jackofhearts2005 (1): Schiavetto (17)
scotty (1): Hally (116)
guillotine (1): santygrass (29)
golden (1): RondoDimBuckle (119)
manny (1): Manny (165)
whomever owns this hellsite (1): hollowkatt (63)
sloonei (2): Ricochet (5), pyxxy (7)
macdougal (1): Seanzie (5)
test (1): Lumi (32)
risiinq~ (1): Ranmilia (31)
arogame (1): Sabiplz (237)
golden the coward (1): G-Man (17)
iaafr (1): Chelsea (11)
michelle (1): TonyStarkPrime (31)
Lol why do I have two wagons
One of you did a trailing space

Okay, I need to trim whitespace

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:51 pm
by Guillotine
Creature wrote: Sun Dec 04, 2022 7:50 pm
Guillotine wrote: Sun Dec 04, 2022 7:50 pm Nutella is a player if she didnt post cap lol
Rondo might very well be a player here tbh
Yup. So there you go mafia, you know whom to kill

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:51 pm
by Lumi
Not Voting (12): MacDougall (26), NANOOKTHEGREATANDFEARSOME (13), Lilypetal (15), SilverKeith (44), Inawordyes (11), Michelle (42), JaggedJimmyJay (30), risiinq- (39), sabie12 (2), Fext (5), Porscha (47), DrWilgy (15)
chelsea (6): Golden (47), Scotty (37), Guillotine (148), ilario (38), Neon (69), ~Prince J~ (18)
arogame (4): nutella (120), Creature (74), Sabiplz (242), tutuu (26)
c4e5g3d5 (1): Marmot (75)
unvote (3): iaafr (132), WindwardAway (101), arogame123 (61)
lily (1): falcon45ca (17)
trans rights (1): katze (89)
golden (5): EnderWiggin (100), Dyslexicon (54), DeeZees (19), lucy (19), Vivax (18)
master radishes (2): Sloonei (24), sprityo (18)
c4e5g3d5 (1): c4e5g3d5 (79)
jaggedjimmyjay (1): Jackofhearts2005 (62)
jackofhearts2005 (1): Schiavetto (17)
scotty (1): Hally (116)
guillotine (1): santygrass (29)
golden (1): RondoDimBuckle (119)
manny (1): Manny (165)
whomever owns this hellsite (1): hollowkatt (63)
sloonei (2): Ricochet (5), pyxxy (7)
macdougal (1): Seanzie (5)
test (1): Lumi (36)
risiinq~ (1): Ranmilia (31)
golden the coward (1): G-Man (17)
iaafr (1): Chelsea (11)
michelle (1): TonyStarkPrime (31)

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:51 pm
by Sabiplz
Ita katze

Glglgl

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:51 pm
by Guillotine
I believe in you

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:52 pm
by Lumi
Not Voting (12): MacDougall (26), NANOOKTHEGREATANDFEARSOME (13), Lilypetal (15), SilverKeith (44), Inawordyes (11), Michelle (42), JaggedJimmyJay (30), risiinq- (39), sabie12 (2), Fext (5), Porscha (47), DrWilgy (15)
chelsea (6): Golden (47), Scotty (37), Guillotine (150), ilario (38), Neon (69), ~Prince J~ (18)
arogame (4): nutella (120), Creature (74), Sabiplz (243), tutuu (26)
c4e5g3d5 (2): Marmot (75), c4e5g3d5 (79)
unvote (3): iaafr (132), WindwardAway (101), arogame123 (61)
lily (1): falcon45ca (17)
trans rights (1): katze (89)
golden (6): EnderWiggin (100), Dyslexicon (54), RondoDimBuckle (119), DeeZees (19), lucy (19), Vivax (18)
master radishes (2): Sloonei (24), sprityo (18)
jaggedjimmyjay (1): Jackofhearts2005 (62)
jackofhearts2005 (1): Schiavetto (17)
scotty (1): Hally (116)
guillotine (1): santygrass (29)
manny (1): Manny (165)
whomever owns this hellsite (1): hollowkatt (63)
sloonei (2): Ricochet (5), pyxxy (7)
macdougal (1): Seanzie (5)
test (1): Lumi (37)
risiinq~ (1): Ranmilia (31)
golden the coward (1): G-Man (17)
iaafr (1): Chelsea (11)
michelle (1): TonyStarkPrime (31)

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:53 pm
by Lumi
Ok, trimming whitespace works:

Code: Select all

// ==UserScript==
// @name         Secret Playerlist Vote Counter
// @namespace    mailto:luminouslag@gmail.com
// @version      1.0
// @description  Automatic Vote Counting for Secret Plyerlist Mafia game on The Syndicate
// @author       Lumi
// @match        https://mafiathesyndicate.com/viewtopic.php?*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=mafiathesyndicate.com
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_setClipboard
// ==/UserScript==

console.log('Script Initialized');

async function getDocument(thread, start) {
  return await window.fetch(`https://mafiathesyndicate.com/viewtopic.php?t=${thread}&start=${start}`).then(r => r.text()).then(html => (new DOMParser()).parseFromString(html, 'text/html'));
}

function getDataFromPost(post) {
  let postNum = post.getElementsByClassName('post-number')[0].textContent.match(/[0-9]+/g)[0];
  let contentChildren = post.getElementsByClassName('content')[0].children;
  let author = post.getElementsByClassName('author')[1].getElementsByTagName('a')[1].textContent;
  let currentVoteTarget = null;
  for (const contentChild of contentChildren) {
    if (contentChild.classList.contains('mention')) {
      let voteTarget = contentChild.textContent.replaceAll('\n','').matchAll(/\[VOTE: ([^\]]*)\]/g).next().value;
      if (voteTarget) currentVoteTarget = voteTarget[1];
    }
  }
  return {
    number: postNum,
    target: currentVoteTarget,
    author: author,
  };
}

function isCorrectThread(targetNum) {
  let topicNum = document.getElementsByClassName("topic-title")[0].children[0].href.matchAll(/\?t=([0-9]+)&/g).next().value[1];
  return topicNum == targetNum;
};

function getNumPosts() {
  return parseInt(document.getElementsByClassName('pagination')[0].textContent.matchAll(/([0-9]*) posts/g).next().value[1]);
};

function getFirstPostNumOfThisPage() {
  return parseInt(document.getElementsByClassName('post')[0].getElementsByClassName('post-number')[0].textContent.match(/[0-9]+/g)[0]);
}

function tallyPage(voteHistory, page) {
  let posts = page.getElementsByClassName('post');
  for (const post of posts) {
    let postData = getDataFromPost(post);
    if (parseInt(postData.number) == voteHistory.length + 1) {
      voteHistory.push(postData);
    }
  }
  return voteHistory;
}

function handleKeyUp(e) {
    let isNum = (e.keyCode >= 48 && e.keyCode <= 57);
    let isV = (e.keyCode == 86);
    let isR = (e.keyCode == 82);
    let isX = (e.keyCode == 88);
    if (isV && e.altKey) {
      let currentDay = 1;
      for(let i=1; i<=10; i++) {
        if (GM_getValue(`EoD${i}`, 0) != 0) currentDay++;
      }
      let voteCount = calcVoteCount(currentDay);
      GM_setClipboard(voteCount);
    } else if (isR && e.altKey) {
      let day = parseInt(prompt('Enter Day Number'));
      let voteCount = calcVoteCount(day);
      GM_setClipboard(voteCount);
    } else if ( isNum && e.altKey) {
      let num = parseInt(e.key);
      if (num == 0) num = 10;
      let postNum = prompt(`Enter Post Number for EoD ${num}`)
      GM_setValue(`EoD${num}`, parseInt(postNum));
    } else if ( isX && e.altKey) {
      window.location.href = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
    }
};

function calcVoteCount(day) {
  let SoD = GM_getValue(`EoD${day-1}`, 0);
  let EoD = GM_getValue(`EoD${day}`, 0);
  voteHistory = JSON.parse(GM_getValue(`voteHistory`), '[]');

  let voteTargets = {};
  let postCounts = {};

  for (const vote of voteHistory) {
    if ((vote.number >= SoD || SoD == 0) && (vote.number <= EoD || EoD == 0)) {
      if (!(vote.author in voteTargets)) {
        voteTargets[vote.author] = null;
        postCounts[vote.author] = 1;
      } else {
        postCounts[vote.author] += 1;
      }
      if (vote.target != null) voteTargets[vote.author] = [vote.target, vote.number];
    }
  }

  let voteCount = {};

  for (const [key, value] of Object.entries(voteTargets) ) {
    if (value != null) {
      let target = value[0].toLowerCase().trim();
      if (target in voteCount) {
        voteCount[target].push([key, value[1], postCounts[key]]);
      } else {
        voteCount[target] = [[key, value[1], postCounts[key]]];
      }
    } else {
      if ('Not Voting' in voteCount) {
        voteCount['Not Voting'].push([key, null, postCounts[key]]);
      } else {
        voteCount['Not Voting'] = [[key, null, postCounts[key]]];
      }
    }
  }

  return voteCountToString(voteCount);
}

function voteToString(vote) {
  if (vote[1] == null) return `${vote[0]} (${vote[2]})`
  return `[url=https://mafiathesyndicate.com/viewtopic.php?t=2451&start=${vote[1]-1}]${vote[0]}[/url] (${vote[2]})`
}

function voteCountToString(voteCount) {
  let output = '';
  for (const [key, value] of Object.entries(voteCount)) {
    let valueStrings = [];
    for (const vote of value) {
      valueStrings.push(voteToString(vote));
    }
    output += `${key} (${value.length}): ${valueStrings.join(', ')}\n`
  }
  return output;
}

if (isCorrectThread(2451)) {
  let voteHistory = JSON.parse(GM_getValue(`voteHistory`, '[]'));
  let numPosts = getNumPosts();
  let curVoteHistoryLength = voteHistory.length;
  while (voteHistory.length < numPosts) {
    let page = await getDocument(2451, voteHistory.length);
    voteHistory = tallyPage(voteHistory, page);
    if (voteHistory.length == curVoteHistoryLength) break;
  }
  GM_setValue(`voteHistory`, JSON.stringify(voteHistory));

  document.addEventListener('keyup', handleKeyUp, false);
};

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:53 pm
by katze
[VOTE: guillotina] aubergine

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:54 pm
by Hally
Marmot wrote: Sun Dec 04, 2022 7:50 pm ITA Hally

hehe
A shot rings out!

Hally has died. They were:
Spoiler: show
Mafia Goon

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:55 pm
by Lumi
How to set up a Tampermonkey Script:
1) Get the tampermonkey extension (https://www.tampermonkey.net/)
2) While on this page click the tampermonkey extension and click "Create New Script"
3) Copy the code I sent, select all the code in the new script, paste my code
4) Hit Ctrl+S to save
5) Reload the page, the hotkeys should work for you.

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:55 pm
by katze
Hally wrote: Sun Dec 04, 2022 7:54 pm
Marmot wrote: Sun Dec 04, 2022 7:50 pm ITA Hally

hehe
A shot rings out!

Hally has died. They were:
Spoiler: show
Mafia Goon

is this a scumslip

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:56 pm
by katze
lumi ur almost as big of a nerd as arete is

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:57 pm
by tutuu
[VOTE: Chelsea] aubergine

i dunno the vote count katze didnt copy paste i dont have time!

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:57 pm
by Lumi
katze wrote: Sun Dec 04, 2022 7:56 pm lumi ur almost as big of a nerd as arete is
I take that as a compliment :joy_cat:

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:58 pm
by Creature
Ok I'm prob staying where I am

May the rand lynch be in our favor

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:58 pm
by Marmot
Hally wrote: Sun Dec 04, 2022 7:54 pm
Marmot wrote: Sun Dec 04, 2022 7:50 pm ITA Hally

hehe
A shot rings out!

Hally has died. They were:
Spoiler: show
Mafia Goon
HYYYPYPYEEE

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:58 pm
by DrWilgy
So I vote right?
[VOTE: TSP] aubergine

What after that. What list do I append currently?

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:58 pm
by katze
Lumi wrote: Sun Dec 04, 2022 7:57 pm
katze wrote: Sun Dec 04, 2022 7:56 pm lumi ur almost as big of a nerd as arete is
I take that as a compliment :joy_cat:
i outlined what this means in p#1765

i know postnums dont work like that here but youll find a way im sure

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:58 pm
by iaafr
prince j could be a wolf

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:58 pm
by Creature
Damn this is still tense

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:59 pm
by tutuu
@Lumi do the thing pls

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:59 pm
by Creature
arogame123 wolf or NPC

Prob NPC because I feel like he would fight his lynch harder as wolf too

Re: Secret Playerlist - Day 1 Ends 10am Dec 5 GMT +10 (Aus Eastern Standard Time)

Posted: Sun Dec 04, 2022 7:59 pm
by c4e5g3d5
SUB TO MY WALRUS