Book Club Notification System Development

With apologies to the ABBC in which the discussion was previously taking place…

7 Likes

Yep, I know. Still needs to be set up though, that’s why I mentioned it. I never used it, but I think you either need your own server or use a service, so some research included. (After the little research I did, Webpushr seemed best in the free tier).

Sounds good!

I was thinking of using the WK API (and authorize usernames) instead of a login/registration system to:

  • Make sure it’s not some other person pretending to be someone else on WK.
  • Not save passwords - I don’t want to be responsible for potential data breaches. (And not having to build a registration system is always nice.)
4 Likes

If you are willing to have a bit of a more complex setup (or a library), then you can use firebase cloud messaging. It’s completely free and works on all major platforms

I also dislike logins, because I would rather have others worry about this, but using the wk api is not enough in my opinion. It’s a bit clunky, you need to store the api key on the client side, etc etc. Instead I want to either authenticate properly or use a regular “sign in with google” or similar thing

2 Likes

One route for people who are able to use UserScripts would be a UserScript something like this:

// ==UserScript==
// @name         Testing
// @namespace    none
// @version      0.1
// @description  pending
// @author       pending
// @match        https://community.wanikani.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Test showing a message:
    if ('ABBC Title' in localStorage) {
        //HandleTitleChange('This is a test of the nomination.')
    }

    // If the stored title is more than a day old, update it.
    let currentDate = new Date()
    let lastUpdatedDate = 'ABBC Title Updated' in localStorage ? new Date(localStorage.getItem('ABBC Title Updated')) : new Date('1/1/2001')
    const daysSinceTitleLastChecked = (currentDate - lastUpdatedDate) / 1000 / 60 / 60 / 24
    if (daysSinceTitleLastChecked < 1) {
        return
    }
    let url = 'https://community.wanikani.com/t/x/34698/1.json'
    fetch(url)
        .then(res => res.json())
        .then(out => HandleTitleChange(out.title))
        .then(out => localStorage.setItem('ABBC Title', out.title))
        .then(out => localStorage.setItem('ABBC Title Updated', new Date()))
        .catch(err => { throw err })

})();


function HandleTitleChange(newTitle) {

    const oldTitle = localStorage.getItem('ABBC Title')
    if (oldTitle === newTitle) {
        return
    }
    if (newTitle.toLowerCase().includes('nomination')) {
        console.log('Seeking nominations!')
    }
    else if (newTitle.toLowerCase().includes('voting')) {
        console.log('Now voting!')
    }

}

This is just a proof of concept. The idea is that once per day, it checks the title of the ABBC thread, and if there is a change, it pushes a message to the Javascript console.

An extended version could:

  • Add something to the user interface of the forum to show there is a call for nomination or voting.
    • This could include a link to the book club thread, but it can’t link to the specific post for voting.
  • Always show that interface item (rather than only when the thread title is found to have changed).
  • Have an option to dismiss/remove the interface item (until there is another title change or X days have passed).
  • Support multiple book clubs.

Advantages

  • Zero maintenance once the script is finalized. The script checks for updates for each user by monitoring each book club thread’s title.
  • If there’s any reason to push out an update to the script, it can be done the same as other UserScripts are handled.

Disadvantages

  • Doesn’t work for situations where you can’t use a UserScript.
2 Likes

I have a few reservations about this approach.

The biggest is that it only works, if you go to the community forums, and I don’t think this could easily be solved.

It also requires one person, the maintainer of the script to manually input the URL of all of the threads, that need attention like this, which isn’t very flexible, if someone for example wanted to start a separate book club suddenly about horror manga, or a specific mangaka, or horror manga from a specific mangaka.

Lastly, if there’s ever a typo in the title, that basically breaks the system. Not likely, but can easily happen.

2 Likes

True.

This only solves the situation of “I want to know when there is a call for nominations or voting, but I don’t want to put the thread on Notification” without consideration of people who otherwise get notifications without visiting the forum.

(That’s why I say this isn’t a complete solution, only a limited one.)

An alternate approach is to have a UI that can add/remove any thread ID to the notification (perhaps with a limit on how many threads can be added). But then it gets fragile if those threads don’t change their title, or don’t use specific words in the title for nomination and vote events.

If someone running a book club has a typo in the thread title, they deserve to have their pay docked for two weeks.

6 Likes

Just to clarify, so I’m understanding what you’re trying to accomplish (apologies if this was previously discussed): you’re just looking to be notified of Nominations / Calls for Voting in the main 4 book club threads?

  • Advanced
  • Intermediate
  • Beginner
  • Absolute Beginner
    (+maybe Visual Novel)

In that case, I think the thread IDs likely won’t change (unless there’s a hard limit to the number of replies allowed forcing a new thread or something, or someone adds a new main category, as happened with Visual Novels).

Alternative would be checking for any new updates on threads in the book club category:

and see if ANY mention nominations or voting, but that might get you false positives.

2 Likes

There may be more potential features being talked about in the overall discussion, but for my script, yes, this is specifically what I targeted.

I like the idea, but there is one issue that comes up.

It looks like the JSON file returns the top 30 threads, three pinned, so it’d be 27 of interest.

As I write this, the list includes both ABBC and ABC, but not BBC. This means the script, were it using the list of recent posts, would miss the BBC thread if it had nominations open or voting, but hadn’t received any recent postings. (Threads tend to be a bit more lively during those times, though.)

1 Like

Gotcha. I feel like if it’s just the main ones you can probably safely just reference the thread ids, since I doubt those would change.

Only risk would be if no one updated the title, or, as @Gorbit99 said, if they typoed it. You could probably check for a close match on words “nominate,” “nomination,” “vote,” “voting” or similar, though, and catch that.

2 Likes

Not sure exactly what you’re talking about, he is referencing the thread ids, though in the form of the thread URL.

Just use the system WK uses for checking how close an answer was we all know that never goes wrong

3 Likes

The real issue with my code comes up when BBC reads the manga adaptation of “My nomination went to vote and I was banished to another world so I’m starting over as a chef overlord.”[1]

[1] Not an actual series.

5 Likes

yet

I actually did look around for a whole 5 seconds for a series that would mess the system up. Ranking of the kings is sadly “ranking” of the kings.

3 Likes

Yup, I just meant that probably hard-coding those 4 ids as-is would likely be fine, since they shouldn’t change!

:rofl:

Hopefully the next really popular series doesn’t contain one of the key words, though that would be amusing in its own way.

… goes to change code

if ( keywordMatchesFunction() && (title != “New super popular Nominating series”) )

2 Likes