osuka's votecounter + modtools

This forum is for discussion related to the game.
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #25 (ISO) » Wed Aug 30, 2023 6:45 am

Post by osuka »

In post 23, Random Nurse wrote: OK, so I don't particularly know what I'm doing here.

I have a Windows laptop and searched and found "Windows PowerShell," and ran it as an Administrator.

It's showing me this screen:

Image

I have no idea how/where to run "Get-ExecutionPolicy."
the image isn't loading here - might have to do with google drive permissions. Can you try imgur?

powershell is a command line utility, so you'd type that command in the window and hit enter. Here's what that would look like:
Spoiler:
Image


Mine's set to Unrestricted - but if yours says Restricted, make sure you copy and run the command in the chocolatey install page there before you move on to step 4. step 3, confusingly, is just telling you again to run the long command right above it


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10743
Joined: April 28, 2011
Pronoun: he/they
Happy Scumday!

Post Post #26 (ISO) » Thu Aug 31, 2023 3:09 am

Post by Psyche »

I've been trying to be careful not to invest in side projects too much again, but it'd be nice to close out my pre-existing work around all this. Should maybe sideline the question of improving the tool further and focus on maximizing accessibility for normal folk. I think we want to avoid a situation where people download things.

If we're committed to not having a persisting backend, a cleaned up colab notebook that anyone with a google account can execute seems like a usable substitute that can be spun up really quickly. At minimum it might give us ideas for what to do going forward. I'll have something before the weekend is over...
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10743
Joined: April 28, 2011
Pronoun: he/they
Happy Scumday!

Post Post #27 (ISO) » Thu Aug 31, 2023 3:27 am

Post by Psyche »

hmm CLI is maybe not ideal for a colab notebook. we want to call functions directly. i think we can simplify setup for this and CLI use case with only a few extra files in the repo.
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #28 (ISO) » Thu Aug 31, 2023 4:43 am

Post by JacksonVirgo »

In post 26, Psyche wrote: I've been trying to be careful not to invest in side projects too much again, but it'd be nice to close out my pre-existing work around all this. Should maybe sideline the question of improving the tool further and focus on maximizing accessibility for normal folk. I think we want to avoid a situation where people download things.

If we're committed to not having a persisting backend, a cleaned up colab notebook that anyone with a google account can execute seems like a usable substitute that can be spun up really quickly. At minimum it might give us ideas for what to do going forward. I'll have something before the weekend is over...
For normal folk it's probably better as a web app, or maybe a tampermonkey script (I found that Tampermonkey can fetch page data from a page you're not on).
As a desktop executable, I agree with Osuka that platform specific apps are probably bad. So why not just use Java or something that doesn't need a specific compilation. Java handles it.
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #29 (ISO) » Thu Aug 31, 2023 4:45 am

Post by JacksonVirgo »

I did do some experimenting with NextJS as a backend for this, have the client keep polling the server for each individual page fetch etc (as to not hit the serverless timeout) but the fetch seemed to take too long for the free-tier of Vercel + cold starts would probably fuck that up too but it was worth a shot.
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10743
Joined: April 28, 2011
Pronoun: he/they
Happy Scumday!

Post Post #30 (ISO) » Thu Aug 31, 2023 5:32 am

Post by Psyche »

Yeah a lot of options. I'm kind of skeptical of fully browser-based solutions like browser extensions because I expect they'd all manage the whole "votes are distributed across pages" thing really awkwardly. I'd love to know if I'm wrong!

On the other hand, the biggest downside of colab notebooks will probably be the fact that the entire execution environment has to be set up at each new use, slowing down performance. Also, UX won't quite be seamless, even if we can technically reduce interaction to filling a textbox or two and pressing "run".

This leaves me preferring a backend solution where we find a really cheap way to host a server that monitors various threads and provides an API for retrieving vote counts. From there, any arbitrary frontend UX becomes doable -- chrome extensions, web pages, etc. And these frontends would in turn be compatible with any votecounter implementation that provides the same API.
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #31 (ISO) » Thu Aug 31, 2023 2:16 pm

Post by JacksonVirgo »

In post 30, Psyche wrote: Yeah a lot of options. I'm kind of skeptical of fully browser-based solutions like browser extensions because I expect they'd all manage the whole "votes are distributed across pages" thing really awkwardly. I'd love to know if I'm wrong!

On the other hand, the biggest downside of colab notebooks will probably be the fact that the entire execution environment has to be set up at each new use, slowing down performance. Also, UX won't quite be seamless, even if we can technically reduce interaction to filling a textbox or two and pressing "run".

This leaves me preferring a backend solution where we find a really cheap way to host a server that monitors various threads and provides an API for retrieving vote counts. From there, any arbitrary frontend UX becomes doable -- chrome extensions, web pages, etc. And these frontends would in turn be compatible with any votecounter implementation that provides the same API.
Considering Tampermonkey allows fetching across the site (which in-page JS rejects), I'm almost certain that it's possible to make a Tampermonkey userscript to integrate it directly into the site itself which would literally be the best user experience we could get here. I'd use a library like Cheerio to parse the data which I'm not sure works in Tampermonkey, but if not a custom browser extension is the next best thing (it's a little awkward for users to set up though).

I am not too experienced with Colab notebooks so I don't have any input on that.

Backend solutions isn't a super long-lasting approach, there's a few issues that come with that including when the site changes and breaks the code etc if the person who manages the server is no longer working on it, the tool is as good as dead.

I do believe we should be focusing on a browser extension (either as a userscript or a whole extension) OR a Java app which users download as both make the user experience simple, and also it should work regardless of the users device or setup
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #32 (ISO) » Thu Aug 31, 2023 3:00 pm

Post by JacksonVirgo »

https://github.com/JacksonVirgo/mafia-engine-browser

I just made an example browser extension (Typescript) to really outline how it would work.

The main script runs jQuery (I know, gives me the shivers) on the main page so it can add buttons and the like *in* the website. But the main script cannot fetch data from other pages, so that's where you use the background script. Send the request there, the BG script gets it all done and sends back the response.

It's pretty straightforward, and is probably the most user friendly way we could handle this entire thing imo (without having a backend server)

EDIT: I've made the extension specifically for Chrome but realistically you'd make it cross-browser to work on all browsers that allow extensions.

EDIT 2: I've made it cross-browser but I haven't tested on anything but Chrome
Last edited by JacksonVirgo on Thu Aug 31, 2023 3:19 pm, edited 1 time in total.
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
yessiree
yessiree
he
Mafia Scum
User avatar
User avatar
yessiree
he
Mafia Scum
Mafia Scum
Posts: 4389
Joined: June 6, 2013
Pronoun: he

Post Post #33 (ISO) » Thu Aug 31, 2023 3:15 pm

Post by yessiree »

In post 30, Psyche wrote: I'm kind of skeptical of fully browser-based solutions like browser extensions because I expect they'd all manage the whole "votes are distributed across pages" thing really awkwardly. I'd love to know if I'm wrong!
It's not awkward at all. You can Fetch any mafiascum.net urls from a browser extension, as long as you are doing it while on a mafiascum webpage.

Edit: yeah, I'm with JacksonVirgo, many advantages of using browser extensions for vote scraping
  • Everyone knows how to add browser extensions -> low barrier to entry
  • Ability to add UI to the web page (buttons, results of vote scraping) -> good UX
  • Everything can be ran on the client, no need to maintain any backends (why do we need any backend at all? we don't need to store any data, we're just pulling data from mafiascum) -> low complexity/maintenance
time to brush up on JavaScript folks!
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #34 (ISO) » Thu Aug 31, 2023 3:21 pm

Post by JacksonVirgo »

In post 33, yessiree wrote: Edit: yeah, I'm with JacksonVirgo, many advantages of using browser extensions for vote scraping
  • Everyone knows how to add browser extensions -> low barrier to entry
  • Ability to add UI to the web page (buttons, results of vote scraping) -> good UX
  • Everything can be ran on the client, no need to maintain any backends (why do we need any backend at all? we don't need to store any data, we're just pulling data from mafiascum) -> low complexity/maintenance
time to brush up on JavaScript folks!
Exactly, it's the most user friendly option and to me that's the most important thing.
Second only to MS implementing their own vote counter solution into the site itself.

Javascript is overrated, use Typescript :cool:
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10743
Joined: April 28, 2011
Pronoun: he/they
Happy Scumday!

Post Post #35 (ISO) » Thu Aug 31, 2023 4:25 pm

Post by Psyche »

okay cool. have always wanted to get good at making extensions
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #36 (ISO) » Thu Aug 31, 2023 4:32 pm

Post by JacksonVirgo »

In post 35, Psyche wrote: okay cool. have always wanted to get good at making extensions
I'm working on fleshing out what I wrote just because I'm hooked on the idea now. If you wanted to help work on that one instead, lemme know. But if you do make your own, I'd be interested to see how you'd do it.
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
Random Nurse
Random Nurse
He/Him
Mafia Scum
User avatar
User avatar
Random Nurse
He/Him
Mafia Scum
Mafia Scum
Posts: 2705
Joined: April 29, 2023
Pronoun: He/Him

Post Post #37 (ISO) » Thu Aug 31, 2023 4:38 pm

Post by Random Nurse »

If costs are involved I am able and willing to donate, if it means Mafiascum gets an easy-to-use automatic votecounter.
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #38 (ISO) » Thu Aug 31, 2023 4:48 pm

Post by JacksonVirgo »

I've updated the code, it now creates a "VC" button on each message. Clicking it fetches the page data for now, but it will start the logic to fetch the vote-count.

Just to make it super clear how you'd do it if you were unsure.
In post 37, Random Nurse wrote: If costs are involved I am able and willing to donate, if it means Mafiascum gets an easy-to-use automatic votecounter.
I doubt we're gonna be dealing with any costs at all.
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #39 (ISO) » Thu Aug 31, 2023 5:58 pm

Post by JacksonVirgo »

I got no idea how to shrink an image here so I've put it in spoilers but a quick visual display that you can very much fetch from other pages using a browser extension.

In the screenshot it demonstrates
  • You can place custom HTML elements in the page (my VC button on the left, ugly rn but design isn't a priority)
  • You can fetch from other pages, as seen in the console on the right.
  • You can't see the "users" value but it's a list of all the usernames to demonstrate fetching data from each post.
  • The extension will only work on "forum.mafiascum.net/*" sites
Take from this what you will, I believe this is the best route to go and I believe it counters all of Osuka's downsides (for servers/executable) and upsides (for CLI). And non-technical users will be able to use this without much issue at all.

EDIT: I think it's fairly easy to get onto the web store of every browser except Safari (I ain't regularly payin' like 99USD for a dev account).


Spoiler:

Image
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10743
Joined: April 28, 2011
Pronoun: he/they
Happy Scumday!

Post Post #40 (ISO) » Fri Sep 01, 2023 1:19 am

Post by Psyche »

In post 36, JacksonVirgo wrote:
In post 35, Psyche wrote: okay cool. have always wanted to get good at making extensions
I'm working on fleshing out what I wrote just because I'm hooked on the idea now. If you wanted to help work on that one instead, lemme know. But if you do make your own, I'd be interested to see how you'd do it.
Nahh I don't have the time to go my own way on this. I do suspect that this should maybe be a different thread since the codebase will probably be mostly distinct.
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #41 (ISO) » Fri Sep 01, 2023 1:22 am

Post by JacksonVirgo »

In post 40, Psyche wrote: Nahh I don't have the time to go my own way on this.
I see I see, that's probably for the best either way. No use wasting time and effort to both do the same thing ahaha
In post 40, Psyche wrote:I do suspect that this should maybe be a different thread since the codebase will probably be mostly distinct.
Hmm, yeah right. Unless Osuka wants otherwise, I'll get the core finished tomorrow and then make it's own thread.
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #42 (ISO) » Fri Sep 01, 2023 12:26 pm

Post by osuka »

i didn't write a browser extension originally because i honestly couldn't be bothered to write and maintain a userscript. i hate javascript and it's just about the last language i'd choose for any personal project, honestly.

for what it's worth, i wonder why this isn't a part of the actual forum in the form of a phpbb extension. would that suck a lot?


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #43 (ISO) » Fri Sep 01, 2023 12:28 pm

Post by osuka »

i wonder if a simple shell script for this would suffice to help with lowering the barrier to entry?


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10743
Joined: April 28, 2011
Pronoun: he/they
Happy Scumday!

Post Post #44 (ISO) » Fri Sep 01, 2023 1:28 pm

Post by Psyche »

as for this project, i think adding a simple setup.py or the link would make possible to reduce most setup to a single pip install statement. i should have a pull request ready for that soon
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #45 (ISO) » Sat Sep 02, 2023 4:12 am

Post by JacksonVirgo »

In post 42, osuka wrote: i didn't write a browser extension originally because i honestly couldn't be bothered to write and maintain a userscript. i hate javascript and it's just about the last language i'd choose for any personal project, honestly.

for what it's worth, i wonder why this isn't a part of the actual forum in the form of a phpbb extension. would that suck a lot?
The sites devs are kinda overloaded aorn with other priorities than a vote-counter that people make scripts for anyway.
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #46 (ISO) » Sat Sep 02, 2023 4:37 am

Post by JacksonVirgo »

Yo Osuka, how does your script deal with hammers and the like?
And also like new days etc.

I don't see anything that would signify that in the game definition file example.
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #47 (ISO) » Sat Sep 02, 2023 4:41 am

Post by JacksonVirgo »

Nevermind, read the README like I probably should have before asking.
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
JacksonVirgo
JacksonVirgo
they/him
Survivor
User avatar
User avatar
JacksonVirgo
they/him
Survivor
Survivor
Posts: 13228
Joined: October 29, 2019
Pronoun: they/him
Location: ɐılɐɹʇsn∀
Contact:

Post Post #48 (ISO) » Sat Sep 02, 2023 5:51 am

Post by JacksonVirgo »

Yo so I made a post about my browser extension based VC. If you wanna peek, here viewtopic.php?t=91528
"Am I a ghost like you, caught between the seams of two intertwining melodies?"


wiki // GTKAS
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10743
Joined: April 28, 2011
Pronoun: he/they
Happy Scumday!

Post Post #49 (ISO) » Sun Sep 03, 2023 1:57 am

Post by Psyche »

Made the pull request.

Also, here's a google colab notebook that demos the tool using my forked repo. The displayed form doesn't actually work (i.e., configure CLI args). Instead running the cell currently does the equivalent of executing `votecounter micro1078.yaml --template osuka.jinja`.

With further changes, the notebook can provide an encapsulated interface for tabulating vote counts without anyone having to install any files. Even now, anyone could make their own copy of the notebook and update the internal `game_definition` variable or other code to demo the votecounter for their own use case.

https://colab.research.google.com/drive ... sp=sharing
Post Reply

Return to “Mafia Discussion”