inherit
210338
0
Nov 21, 2024 20:26:10 GMT -8
RichardInTN
472
June 2014
richardintn
|
Post by RichardInTN on Jul 10, 2017 16:31:29 GMT -8
Virgil Sovereign, I'm not sure about this part --> blockee_id: xxx Do I just assign a random number to each instance of it, just making sure each one is unique? I noticed on one line you had "123" and on the next one you had "2000". I'm not too worried about people doing it "while logged out"... there are holes in every system (they could bypass it even if it was "native" to PB by doing that)... although, I'm betting that with a little finagling something could be done so that guests couldn't see blocked posts, of ANYONE, at all (that's just a guess though) either. like if there's NO "user ID" (or however a guest is identified), then it blocks that blocked poster.
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,324
January 2004
todge
|
Post by Todge on Jul 11, 2017 11:54:57 GMT -8
Sorry I've been missing for a few days.. Had a small op on my neck, so was unavailable.
Good to see Virgil has it in hand... Never even dawned on me to use a template mofification...
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Jul 11, 2017 16:58:00 GMT -8
Virgil Sovereign , I'm not sure about this part --> blockee_id: xxx Do I just assign a random number to each instance of it, just making sure each one is unique? I noticed on one line you had "123" and on the next one you had "2000". "xxx", or in the case of the example, "123" or "2000" would actually be the User ID of the person that is being blocked (blockee). Using Virgil's code: (() => { let block_list = [ { blocker: 'syonidv', blockee: 'richardintn', blockee_id: 123 }, { blocker: 'vegan4ever', blockee: 'meatluvr82', blockee_id: 2000 } ];
function seenoevil() { block_list.forEach( rule => { if( proboards.data('user').username !== rule.blocker ) return;
$(`.mini-profile a.user-link[href$="/${rule.blockee_id}"]`).closest('.post').css( 'display', 'none' ); $(`div.quote[author="@${rule.blockee}"]`).html( '...' ); } ); }
$( seenoevil ); proboards.on( 'afterSearch', seenoevil ); proboards.on( 'pageChange', seenoevil ); })();
"blocker" is the username of the person who is blocking "blockee". So, the blockee_id should be the User ID of the blockee - the usernames that are in red above. With that, from the example, richardintn's User ID should be the number in the blockee_id in the first set, and meatluvr82's User ID should be the number in the blockee_id for the second set. tl;dr - The blockee_id is the User ID of the person being blocked, not just some random number.
|
|
inherit
210338
0
Nov 21, 2024 20:26:10 GMT -8
RichardInTN
472
June 2014
richardintn
|
Post by RichardInTN on Jul 11, 2017 17:09:58 GMT -8
Virgil Sovereign , I'm not sure about this part --> blockee_id: xxx Do I just assign a random number to each instance of it, just making sure each one is unique? I noticed on one line you had "123" and on the next one you had "2000". "xxx", or in the case of the example, "123" or "2000" would actually be the User ID of the person that is being blocked (blockee). Using Virgil's code: (() => { let block_list = [ { blocker: 'syonidv', blockee: 'richardintn', blockee_id: 123 }, { blocker: 'vegan4ever', blockee: 'meatluvr82', blockee_id: 2000 } ];
function seenoevil() { block_list.forEach( rule => { if( proboards.data('user').username !== rule.blocker ) return;
$(`.mini-profile a.user-link[href$="/${rule.blockee_id}"]`).closest('.post').css( 'display', 'none' ); $(`div.quote[author="@${rule.blockee}"]`).html( '...' ); } ); }
$( seenoevil ); proboards.on( 'afterSearch', seenoevil ); proboards.on( 'pageChange', seenoevil ); })();
"blocker" is the username of the person who is blocking "blockee". So, the blockee_id should be the User ID of the blockee - the usernames that are in red above. With that, from the example, richardintn's User ID should be the number in the blockee_id in the first set, and meatluvr82's User ID should be the number in the blockee_id for the second set. tl;dr - The blockee_id is the User ID of the person being blocked, not just some random number. Gotcha! It was the "2000" that was throwing me. I don't even have 100 members! ETA: I'll give it a test run later tonight.
|
|
inherit
210338
0
Nov 21, 2024 20:26:10 GMT -8
RichardInTN
472
June 2014
richardintn
|
Post by RichardInTN on Jul 11, 2017 20:26:04 GMT -8
Gave it a test run... and it looks like it works perfectly... only time will tell however.
|
|
inherit
210338
0
Nov 21, 2024 20:26:10 GMT -8
RichardInTN
472
June 2014
richardintn
|
Post by RichardInTN on Jul 12, 2017 2:14:53 GMT -8
I just had a thought that would take care of the "what if they log out and lurk as a guest?" problem that was mentioned earlier
Is there a way that
if( proboards.data('user').username !== rule.blocker ) could be changed to include something like
if( proboards.data('user').username !== rule.blocker and user.is !== "guest") (I know I probably butchered that, but I think it's understood what I am meaning... and an "and not guest" checker to the "user !==" if statement.)
Barring that, is there a way for me to put "guest" into the "blockee" and "blockee_id" fields? How does "guest" show up in a user_ID lookup?
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Jul 12, 2017 9:05:36 GMT -8
They don't. Guests do not have user IDs.
(cannot answer the js question tho sorry)
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Jul 12, 2017 10:00:06 GMT -8
To implement that, you could try this. Change this line:
if( proboards.data('user').username !== rule.blocker and user.is !== "guest")
to actually be this:
if( proboards.data('user').username !== rule.blocker && proboards.data('user').is_logged_in)
This part:
proboards.data('user').is_logged_in
checks to see if the current user is logged in. If they are logged in (indicating it is a member and not a guest), then this results to TRUE and will then run the code below it (IF they are also NOT a blocker). In this case, the function simply issues a return. In a nutshell, this: if( proboards.data('user').username !== rule.blocker && proboards.data('user').is_logged_in) is basically saying:
"If the current user's username is NOT a blocker AND if the current user IS logged in (not a guest)"
As a note, though: I believe I saw somewhere quite awhile ago that you should be using pb.data instead of proboards.data.
|
|
inherit
210338
0
Nov 21, 2024 20:26:10 GMT -8
RichardInTN
472
June 2014
richardintn
|
Post by RichardInTN on Jul 12, 2017 16:22:27 GMT -8
That's got it licked!
ETA: and "proboards.data" works, as is in this code. Maybe what you are recalling was that "pb.data" will also work?
|
|
inherit
210338
0
Nov 21, 2024 20:26:10 GMT -8
RichardInTN
472
June 2014
richardintn
|
Post by RichardInTN on Jul 13, 2017 18:32:45 GMT -8
Admins/Mods: if you'd like to mark this one as "Completed", please feel free. Also if it needs to be moved to "Headers & Footers" (because that's what the end result turned out to be)... that's cool too!
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Jul 14, 2017 1:03:31 GMT -8
That's got it licked! ETA: and "proboards.data" works, as is in this code. Maybe what you are recalling was that "pb.data" will also work? Just to note: I never said proboards.data wouldn't work. I simply stated that I believe that it's preferred that pb.data is used. I'm thinking (and I could be wrong) that proboards.data may be deprecated. If it is, then it may stop working. Maybe not until after V6, but it may. Tagging Brian - Is proboards.data deprecated? I remember reading something about using pb.data instead, but can't remember why. Thanks!
|
|
inherit
168679
0
Nov 18, 2012 17:03:07 GMT -8
Virgil Sovereign
Latet anguis in herba.
686
July 2011
syonidv
|
Post by Virgil Sovereign on Jul 14, 2017 8:58:40 GMT -8
Thanks for handling things, Lynx. Just to be certain you're aware, Richard: the modified code hides the posts of all blockees from guests. It seems to me this is what you want, but just in case.
|
|
inherit
168679
0
Nov 18, 2012 17:03:07 GMT -8
Virgil Sovereign
Latet anguis in herba.
686
July 2011
syonidv
|
Post by Virgil Sovereign on Jul 14, 2017 9:08:20 GMT -8
That's got it licked! ETA: and "proboards.data" works, as is in this code. Maybe what you are recalling was that "pb.data" will also work? Just to note: I never said proboards.data wouldn't work. I simply stated that I believe that it's preferred that pb.data is used. I'm thinking (and I could be wrong) that proboards.data may be deprecated. If it is, then it may stop working. Maybe not until after V6, but it may. Tagging Brian - Is proboards.data deprecated? I remember reading something about using pb.data instead, but can't remember why. Thanks! I was thinking about that too. RichardInTN : You may want to update the code to: (() => { let block_list = [ { blocker: 'syonidv', blockee: 'richardintn', blockee_id: 123 }, { blocker: 'vegan4ever', blockee: 'meatluvr82', blockee_id: 2000 } ];
function seenoevil() { block_list.forEach( rule => { if( pb.data('user').is_logged_in && pb.data('user').username !== rule.blocker ) return;
$(`.mini-profile a.user-link[href$="/${rule.blockee_id}"]`).closest('.post').css( 'display', 'none' ); $(`div.quote[author="@${rule.blockee}"]`).html( '...' ); } ); }
$( seenoevil ); pb.events.on( 'afterSearch', seenoevil ); pb.events.on( 'pageChange', seenoevil ); })();
Just to make sure the code doesn't break in future.
|
|
inherit
210338
0
Nov 21, 2024 20:26:10 GMT -8
RichardInTN
472
June 2014
richardintn
|
Post by RichardInTN on Jul 14, 2017 17:56:50 GMT -8
Thanks for handling things, Lynx . Just to be certain you're aware, Richard: the modified code hides the posts of all blockees from guests. It seems to me this is what you want, but just in case. I figured as much (kind of expected it, actually, because how could a script determine who a guest is? It can't), and am completely fine with that being the case. Just to note: I never said proboards.data wouldn't work. I simply stated that I believe that it's preferred that pb.data is used. I'm thinking (and I could be wrong) that proboards.data may be deprecated. If it is, then it may stop working. Maybe not until after V6, but it may. Tagging Brian - Is proboards.data deprecated? I remember reading something about using pb.data instead, but can't remember why. Thanks! I was thinking about that too. RichardInTN : You may want to update the code to: (() => { let block_list = [ { blocker: 'syonidv', blockee: 'richardintn', blockee_id: 123 }, { blocker: 'vegan4ever', blockee: 'meatluvr82', blockee_id: 2000 } ];
function seenoevil() { block_list.forEach( rule => { if( pb.data('user').is_logged_in && pb.data('user').username !== rule.blocker ) return;
$(`.mini-profile a.user-link[href$="/${rule.blockee_id}"]`).closest('.post').css( 'display', 'none' ); $(`div.quote[author="@${rule.blockee}"]`).html( '...' ); } ); }
$( seenoevil ); pb.events.on( 'afterSearch', seenoevil ); pb.events.on( 'pageChange', seenoevil ); })();
Just to make sure the code doesn't break in future. If you think it wise. I shall take care of it! Looks like it works that way too!
|
|
#eb7100
33409
0
1
Nov 24, 2024 4:27:37 GMT -8
Brian
48,130
November 2004
smashmaster3
|
Post by Brian on Jul 17, 2017 8:38:16 GMT -8
That's got it licked! ETA: and "proboards.data" works, as is in this code. Maybe what you are recalling was that "pb.data" will also work? Just to note: I never said proboards.data wouldn't work. I simply stated that I believe that it's preferred that pb.data is used. I'm thinking (and I could be wrong) that proboards.data may be deprecated. If it is, then it may stop working. Maybe not until after V6, but it may. Tagging Brian - Is proboards.data deprecated? I remember reading something about using pb.data instead, but can't remember why. Thanks! Our API uses pb.data but both should work. I would recommend using pb.data going forward as proboards.data is likely deprecated.
|
|