Request: A Likes Timeline?


#1

(Continuing the discussion from :skull_and_crossbones::open_book::skull_and_crossbones: You don't have long… :skull_and_crossbones::open_book::skull_and_crossbones:: )

Is it possible to have a timeline similar to the WaniKani Ultimate Timeline, but for likes used in the forums? Currently, the only information we receive about likes is

  1. When we’re running low on likes, and
  2. When we can like something again.

Implementing something similar to the WaniKani Ultimate Timeline for likes would give us information like how many likes we’ll be able to use at what time of day–way more useful for those of us who are hardcore forum users and run out of likes all the time.


#2

It’s the right thing to do


#3

Hear hear! This is important.

and most likely dependent on discourse…


#4

Y-you’re the right thing to do!


#5

Ya’ll go through likes like crazy to run out like that. Or maybe, I am not liking enough…


#6

Yes, some of us are often out of likes. xD


#7

@glias


#8

waifi xD


#9

As expected it looks like all of the like data is kept server side. There’s some useless notification timer kept in localStorage, but it’s just the time when you’ve last received a notification. Not helpful at all. (Also, this site tracks what emojis you use. Seriously? I’d think if anyone cares enough they’d just learn the phrase to type out…)

Anyway, the other option is track it ourselves. I took a page from rfindley’s book and set some mutation observers to track the appropriate items and refresh whenever post stream was updated (scrolling down long discussion… ect).

Like Observer Script ``` // ==UserScript== // @name Like Observer Test // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://community.wanikani.com/* // @grant none // ==/UserScript==

(function() {
‘use strict’;

// Your code here...
console.log("Observer starting...");
var observer = new MutationObserver((mutations) => {
    mutations.forEach((mutation) => {
        console.log("Mutation: " + mutation.target.className);
    });
});
var postStreamObserver = new MutationObserver((mutations) => {
    watchLikes();
});
postStreamObserver.observe(document.querySelector('.post-stream'), { attribute: true, childList: true, characterData: true });
watchLikes();

function watchLikes() {
    document.querySelectorAll('.toggle-like').forEach((target) => {
        observer.observe(target, { attributes: true });
    });
}

})();

</details>

From here it would be a matter of identifying changes, tracking and storing like usage, and generating a UI to display the data. That sounds complely reason- fuck it.

OH GLORIOUS @rfindley, MASTER OF THE USERSCRIPTS, LORD OF CEASELESS BENEVOLENCE, TALENT, AND UNIMAGINABLE <S>VIRILITY</S>VOLUPTUOUSNESS. I HATH SUMMONED THEE FOR THE FURTHERANCE OF SHITPOSTING...

#10

I’m travelling at the moment, but some thoughts to simplify the code:

Capturing clicks on the Like button is a lot cleaner than mutation-observing. Of course, the problem is that the Like buttons change every time you navigate, so you’d lose the click-listener. But jquery has an easy solution for that: attach the event handler to something higher up the dom tree, and use the built-in filter to filter out all but the clicks that you want to receive. Example:

$(‘body’).on(‘click’, ‘.toggle-like’, like_handler);

function like_handler({
// do something
}

So, whenever anything is clicked (any descendent of ‘body’), it checks if the clicked object is a ‘.toggle-like’. If so, it calls the callback function (in this case, ‘like_handler()’ ). Since body never gets refreshed, you never lose the attached event.

(I hope that makes sense. I’m literally falling asleep as I type. So tired!)


#11

Thanks for the advice! I was actually just being silly with the summoning, but ended up learning something really useful.

Have fun on your trip!


#12

What?! Why?

You guys like things too much. And @rfindley, I’m surprised that you would help them!

(Also, I’m a little disappointed in myself that I’ve liked so many things recently…)

Whatever happened to our Stingy Likes ClubTM?


#13

Heh… It’s code. I see it like that guy on The Matrix. Can’t help but toss out a pointer here and there (heh… pun not intended).

I’m definitely not writing a Likes Timeline, though! :fearful:


#14

Heh, good. You can stay in the club.

(Was that Mouse? Been too long since I watched it… 2 and a half years since my last viewing.)


#15

There are scenes where most of them are looking at the code, but the scene we’re talking about was Cypher.


#16

He was my second guess. I was pretty sure it wasn’t Mouse… but he was the best coder… because “all I see is blonde, brunette, redhead…” XD

Awww… I misquoted it. And had the wrong guy. For some reason, I thought Mouse said that when they came out and he’s all excited about putting in the woman with the red dress. It has been too long. You’ve bested me.

EDIT: Fixed that… ^^;