Loading...

Top
PFQ Banner

This is PokéFarm Q, a free online Pokémon collectables game.

Already a user? New to PFQ?

Single post in Implementing A 'Block' Feature

Forum Index > Core > Suggestions > Under Consideration > Implementing A 'Block' Feature >

Niet [Adam]'s AvatarNiet [Adam]
Niet [Adam]'s Avatar
See, one of the cool things about making a userscript "official" is that it means I can start doing things like add fancy hooks into PFQ's code. Today I've added the first of these hooks: $.pfqHook.notifications
/** * @typedef {{ * count: string, * currency: number[], * html: string, * nice: string[], * ok: true * }} NotificationResponse * "count" is a string because staff get "1-2" where the numbers are user and staff notifications respectively. It may also be "!!" if something went wrong. * "nice" is an array of usernames that sent a Nice */ if( !$.pfqHook) $.pfqHook = {}; const oldhook = $.pfqHook.notifications; /** * Hook into notifications before they are shown to the user * @param {NotificationResponse} r */ $.pfqHook.notifications = r=>{ oldhook && oldhook(r); // your code here };
I'm not sure if Tampermonkey userscripts can access this, since those generally can't access functions from the site they're run on, I think. I don't know, I've never actually used it. But sanctioned ones most certainly can since they're run in PFQ's context directly. So what's this all for? Well I've just made it so that the Block Users script also blocks notifications, filtering out names of people you've blocked and also removing PMs from them from the total count. So if your only notification is a blocked person PMing you, you'll see "0" and "Someone sent you a PM." Unless I outright say I'm done with something, I'm not done with it! I'm not making promises, mind, but piece by piece I'm sure we'll find something we can all be satisfied with.
Clip from Pokémon anime, re-lined by me
-- OMNOMNOM!
Featured story: Injustice Feedback welcome!
© PokéFarm 2009-2024 (Full details)Contact | Rules | Privacy | Reviews 4.6★Get shortlink for this page