Block From Profile and Posts

Block users from on their profile and/or posts

  1. // ==UserScript==
  2. // @name Block From Profile and Posts
  3. // @namespace pxgamer
  4. // @version 1.3
  5. // @description Block users from on their profile and/or posts
  6. // @author pxgamer & Keka
  7. // @include *kat.cr/*
  8. // @require https://greasyfork.org/scripts/19498-get-blocked-users/code/Get%20Blocked%20Users.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. var hideBlocked = false; // true hides blocked users posts / false shows them with a green blocked icon
  13.  
  14. /////////////// Do NOT Edit Below This Line ///////////////
  15. var blockedArray = gbu(); // blocked users list
  16.  
  17. $(window).load(function(){
  18. if (window.location.href.search("\/user\/") != -1){
  19. var who = $.trim($("h1.nickname").html().split('<')[0]);
  20. var bm = $('a.kaButton.smallButton.normalText[href^="/bookmarks/"');
  21. var hash = bm.attr('href').split('/')[4];
  22. if(blockedArray.indexOf(who) !== -1){bm.after(' <span title="unblock user" class="kaButton smallButton greenButton normalText unBlockUser"><i id="unBlockUser" data-whoBlock="'+hash+'" class="ka ka-delete"></i> unblock user</span>');}
  23. else{bm.after(' <span title="block user" class="kaButton smallButton redButton normalText blockUser"><i id="blockUser" data-whoBlock="'+who+'" class="ka ka-delete"></i> block user</span>');}
  24. }
  25. if (window.location.href.search("\/community\/") != -1){
  26. $("div[id^='post']").each(function(){
  27. var thisPost = $(this);
  28. var who;
  29. if($(this).find('.userPic i.ka-message').length){
  30. who = $(this).find('.userPic i.ka-message').parent('a').attr('href').split('/')[3];
  31. //$(this).find('.userPic i.ka-community').parent().after('<span title="block user" class="blockUser"><i id="blockUser" data-whoBlock="'+who+'" class="ka ka-red icon16 ka16 ka-community"></i></span>');
  32. }
  33. if(blockedArray.indexOf(who) == -1){
  34. $(this).find('.userPic i.ka-community').parent().after('<span title="block user" class="blockUser"><i id="blockUser" data-whoBlock="'+who+'" class="ka ka-red icon16 ka16 ka-community"></i></span>');
  35. }
  36. else{
  37. if(hideBlocked === true){
  38. thisPost.hide();
  39. thisPost.prev('div.commentHeadLine').text('Blocked User Post ('+who+')');}
  40. else{
  41. thisPost.find('.rate').hide();
  42. thisPost.find(".commentcontent div:last-child").hide();
  43. $(this).find('.userPic i.ka-community').parent().after('<span title="blocked user"><i data-whoBlock="'+who+'" class="ka ka-green icon16 ka16 ka-community"></i></span>');}
  44. }
  45. });
  46. }
  47. /* Functions */
  48. $('.blockUser').click(function() {
  49. var csrf = $('form input[name="csrf_token"]').val();
  50. var user = $(this).find('i').attr('data-whoblock');
  51. $.ajax({
  52. type: "POST",
  53. url: "/settings/privacy/",
  54. data: { blockuser: user, csrf_token: csrf, block: true },
  55. success: function (data) { location.reload(); },
  56. returnData: "json"
  57. });
  58. });
  59. $('.unBlockUser').click(function() {
  60. var csrf = $('form input[name="csrf_token"]').val();
  61. var hash = $(this).find('i').attr('data-whoblock');
  62. $.ajax({
  63. type: "POST",
  64. url: "/settings/privacy/",
  65. data: { unblock: hash, csrf_token: csrf },
  66. success: function (data) { location.reload(); },
  67. returnData: "json"
  68. });
  69. });
  70. });