KAT - Block From Profile

Block users from on their profile and/or posts

当前为 2016-05-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name KAT - Block From Profile
  3. // @namespace PXgamer
  4. // @version 1.0
  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. // If viewing blocked users posts (hideBlocked = false)
  15. // You cannot unhide rates and reply/quote buttons
  16. // from blocked users.
  17. // You should not be replying to
  18. // Or rating posts from blocked users
  19. // As per KAT rules
  20.  
  21. /////////////// Do NOT Edit Below This Line ///////////////
  22. var blockedArray = gbu(); // blocked users list
  23.  
  24. $(window).load(function(){
  25. // User Pages
  26. if (window.location.href.search("\/user\/") != -1){
  27. var who = $.trim($("h1.nickname").html().split('<')[0]);
  28. var bm = $('a.postLink.kaButton.smallButton.normalText[href^="/bookmarks/"');
  29. var hash = bm.attr('href').split('/')[4];
  30. // Unblock button
  31. 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>');}
  32. // Block button
  33. 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>');}
  34. }
  35. // Post Boxes
  36. if (window.location.href.search("\/community\/") != -1){
  37. $("div[id^='post']").each(function(){
  38. var thisPost = $(this);
  39. var who;
  40. if($(this).find('.userPic i.ka-message').length){
  41. who = $(this).find('.userPic i.ka-message').parent('a').attr('href').split('/')[3];
  42. //$(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>');
  43. }
  44. if(blockedArray.indexOf(who) == -1){
  45. // Not Blocked
  46. $(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>');
  47. }
  48. else{
  49. // Hide post if hideBlocked is true
  50. if(hideBlocked === true){
  51. thisPost.hide();
  52. thisPost.prev('div.commentHeadLine').text('Blocked User Post ('+who+')');}
  53. // Or Show Blocked Button
  54. else{
  55. thisPost.find('.rate').hide(); // hides +/- and ratings
  56. thisPost.find(".commentcontent div:last-child").hide(); // hide quote/reply buttons
  57. $(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>');}
  58. }
  59. // Done Loop
  60. });
  61. }
  62. /////////////// Functions ///////////////
  63. // Block
  64. $('.blockUser').click(function() {
  65. var csrf = $('form input[name="csrf_token"]').val();
  66. var user = $(this).find('i').attr('data-whoblock');
  67. $.ajax({
  68. type: "POST",
  69. url: "/settings/privacy/",
  70. data: { blockuser: user, csrf_token: csrf, block: true },
  71. success: function (data) { location.reload(); },
  72. returnData: "json"
  73. });
  74. });
  75. // Unblock
  76. $('.unBlockUser').click(function() {
  77. var csrf = $('form input[name="csrf_token"]').val();
  78. var hash = $(this).find('i').attr('data-whoblock');
  79. $.ajax({
  80. type: "POST",
  81. url: "/settings/privacy/",
  82. data: { unblock: hash, csrf_token: csrf },
  83. success: function (data) { location.reload(); },
  84. returnData: "json"
  85. });
  86. });
  87. });