// ==UserScript==
// @name KAT - Block From Profile
// @namespace Keka
// @version 1.0
// @description Block users from on their profile and/or posts
// @author PXgamer & Keka
// @include *kat.cr/*
// @require https://greasyfork.org/scripts/19498-get-blocked-users/code/Get%20Blocked%20Users.js
// @grant none
// @downloadURL none
// ==/UserScript==
var hideBlocked = false; // true hides blocked users posts / false shows them with a green blocked icon
// If viewing blocked users posts (hideBlocked = false)
// You cannot unhide rates and reply/quote buttons
// from blocked users.
// You should not be replying to
// Or rating posts from blocked users
// As per KAT rules
/////////////// Do NOT Edit Below This Line ///////////////
var blockedArray = gbu(); // blocked users list
$(window).load(function(){
// User Pages
if (window.location.href.search("\/user\/") != -1){
var who = $.trim($("h1.nickname").html().split('<')[0]);
var bm = $('a.postLink.kaButton.smallButton.normalText[href^="/bookmarks/"');
var hash = bm.attr('href').split('/')[4];
// Unblock button
if(blockedArray.indexOf(who) !== -1){bm.after(' unblock user');}
// Block button
else{bm.after(' block user');}
}
// Post Boxes
if (window.location.href.search("\/community\/") != -1){
$("div[id^='post']").each(function(){
var thisPost = $(this);
var who;
if($(this).find('.userPic i.ka-message').length){
who = $(this).find('.userPic i.ka-message').parent('a').attr('href').split('/')[3];
//$(this).find('.userPic i.ka-community').parent().after('');
}
if(blockedArray.indexOf(who) == -1){
// Not Blocked
$(this).find('.userPic i.ka-community').parent().after('');
}
else{
// Hide post if hideBlocked is true
if(hideBlocked === true){
thisPost.hide();
thisPost.prev('div.commentHeadLine').text('Blocked User Post ('+who+')');}
// Or Show Blocked Button
else{
thisPost.find('.rate').hide(); // hides +/- and ratings
thisPost.find(".commentcontent div:last-child").hide(); // hide quote/reply buttons
$(this).find('.userPic i.ka-community').parent().after('');}
}
// Done Loop
});
}
/////////////// Functions ///////////////
// Block
$('.blockUser').click(function() {
var csrf = $('form input[name="csrf_token"]').val();
var user = $(this).find('i').attr('data-whoblock');
$.ajax({
type: "POST",
url: "/settings/privacy/",
data: { blockuser: user, csrf_token: csrf, block: true },
success: function (data) { location.reload(); },
returnData: "json"
});
});
// Unblock
$('.unBlockUser').click(function() {
var csrf = $('form input[name="csrf_token"]').val();
var hash = $(this).find('i').attr('data-whoblock');
$.ajax({
type: "POST",
url: "/settings/privacy/",
data: { unblock: hash, csrf_token: csrf },
success: function (data) { location.reload(); },
returnData: "json"
});
});
});