Feature Addition: Hide Post By User

Well, 55 is what’s released, not 57. I’m running 57 and it works fine. I test muted you. Figuring out how to unmute was more of a challenge.

2 Likes

I’ve been enjoying this new feature – thank you! – but now think I’ve found an issue that I haven’t seen mentioned so far: it seems to only work in the original thread. When going to a new thread, the hidden poster re-appears. In other words, the hiding seems to be thread-specific. Is that right, or is that just me? (Mac, Firefox 55.0.3)

7 Likes

UPDATE:
Managed to replicate bug. Attempting to fix bug. See thread here for more info:

ORIGINAL POST:

It shouldn’t be thread specific. I don’t have a Mac to test on, but mute seems to be working as designed across the following setups:

Theme: Earthtones
(Working) Firefox 55 / Windows 7
(Working) Pale Moon 27 / Windows 7
(Working) Chrome Current / Windows 7
(Working) Chrome Current / Android
(Working) Firefox Focus / Android

Theme: Default Dark
(Working) Firefox 55 / Windows 7
(Working) Pale Moon 27 / Windows 7
(Working) Chrome Current / Windows 7
(Working) Chrome Current / Android
(Working) Firefox Focus / Android

I recommend closing any open Cafe tabs, opening one tab, and muting the trouble user. Alternatively, after muting somebody, reload all Cafe tabs to see it take effect.

2 Likes

Making it thread specific might be a great idea. I don’t take anything from online too too personally, but I don’t mind the notion that I could filter out someone I think is acting in bad faith on a subject they don’t even realize they’re kind of hung up on - or just repeating themselves.

Time will tell, thanks for the efforts!

2 Likes

Hm. I think I could do something like that, I’m just out of creative juice today.

Thank you!

2 Likes

It can also simply be a tool to avoid wasting one’s time. I’m not removing myself from the NYT “community” by avoiding Ross Douthat or David Brooks.

11 Likes

And now it’s not working… S7 / Android / Chrome.

99 bug reports on the wall
99 bug reports
take one down and patch it around
107 bug reports on the wall

edit to add:
tested, working on chrome (android lollipop), all themes

6 Likes

A post was merged into an existing topic: A Quiet Place

And, you’d be stating an affinity FOR them, if you said you were doing so, made sure we knew, acted generally like it was their loss that your mind would no longer be digesting their words.

If you avoid them and don’t need approval for it, (as you do) then we’re on the same page. :smiley:

2 Likes

Given the opinions held about the nyt by people here that I respect, acknowledging that I read it isn’t a fishing trip for compliments.

Maybe I’m not parsing your comment properly.

2 Likes

but it’s so easy to parse (no it isn’t)

The only compliment is my observation that you’re not tootin your own horn at all, to clarify that you’re not who I was referring to (someone who was).

I read lots of stuff, glad you do too.

2 Likes

7 posts were split to a new topic: Other Place Encounters and Comments

@tinoesroho I run a Discourse-powered forum and am constantly being asked for this feature. Is it available as a plugin, or just on this theme?

3 Likes

@Fallhammer:
Thank you for reaching out to us!

It can be added to any theme.

To do so, head into your admin panel. Choose customize, then pick a theme. Choose edit CSS. Click the head tab. Then paste the following. Make sure to change the cookie name to avoid any gnarly interactions with other sites. Click save, and you’re done. Repeat for each theme:

<script type="text/javascript">
var run_script = false;

$(document).ready(function(){
    if (window.location.href.indexOf("/t/") > 0) {
        run_script = true;
        MakeMagic();
    }
});    

if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) {
    this.GM_getValue=function (key,def) {
        return localStorage[key] || def;
    };
    this.GM_setValue=function (key,value) {
        return localStorage[key]=value;
    };
    this.GM_deleteValue=function (key) {
        return delete localStorage[key];
    };
}

var GR_COOKIE_NAME = 'discourse_mute_users';
var hide_ids = $.parseJSON(GM_getValue(GR_COOKIE_NAME, '{}'));

(function(){
    event = function(event){
        if (event.animationName == 'nodeInserted') {
            RecastSpell();
        }
    }
        
document.addEventListener('animationstart', event, false);
document.addEventListener('MSAnimationStart', event, false);
document.addEventListener('webkitAnimationStart', event, false);
})();

function RecastSpell(){
    if (run_script == true) {
        MakeMagic();
    }
}

function MakeMagic(){
    hide_ids = $.parseJSON(GM_getValue(GR_COOKIE_NAME, '{}'));
	function handle_post_node(node){
		var tid = node.getAttribute('data-user-id');
		var name = $('[data-user-id="'+tid+'"]').find('.username a').first().text();
		function mute_foo(){
		    //var name = $(node).find('.names').text;
		    var confirmString = "Really mute " + name + "?";  
		    if (confirm(confirmString) == true) {
 	                this.innerHTML = "Unmute;"
			$(node).find('.contents').hide();
			$(node).find('.names').hide();
			$(node).find('.avatar').hide();
			$(this).unbind('click', mute_foo);
			$(this).click(umute_foo);
			hide_ids[tid] = 1;
			GM_setValue(GR_COOKIE_NAME, JSON.stringify(hide_ids));
			$('[data-user-id="'+tid+'"]').find('.mute_btn').remove();
			$('[data-user-id="'+tid+'"]').each(function(){ handle_post_node(this) });         
		    }
		}
		function umute_foo(){
		    var confirmString = "Unmute " + name + "?";  
		    if (confirm(confirmString) == true) {
			this.innerHTML = "Mute";
			$(node).find('.contents').show();
			$(node).find('.names').show();
			$(node).find('.avatar').show();
			$(this).unbind('click', umute_foo);
			$(this).click(mute_foo);
			delete hide_ids[tid];
			GM_setValue(GR_COOKIE_NAME, JSON.stringify(hide_ids));
			$('[data-user-id="'+tid+'"]').find('.umute_btn').remove();
			$('[data-user-id="'+tid+'"]').each(function(){ $(this).find('.contents').show(); handle_post_node(this) });
		    }
		}
		if(hide_ids[tid]){			
			$(node).find('.contents').hide();
			$(node).find('.names').hide();
			$(node).find('.avatar').hide();
			if($(node).find('.umute_btn').length > 0) return;
			var btn = $('<button class="umute_btn" title="Unmute this user." style="background-color: Transparent; background-repeat:no-repeat; border: none; cursor:pointer; overflow: hidden; outline:none; margin-left: 3px; "><i class="fa fa-microphone"></i></button>');
			$(node).find('.post-info').first().prepend(btn);
			btn.click(umute_foo);
		}else {
			if($(node).find('.mute_btn').length > 0) return;
			var btn = $('<button title="Mute this user." style="background: none;" class="mute_btn"><i class="fa fa-microphone-slash"></i></button>');
			btn.insertBefore($(node).find('.create').last());
			btn.click(mute_foo);
		}
	}
	
	$('article').each(function(){handle_post_node(this)});
	var observer = new MutationObserver(function(mutations) {
		for(var i=0; i < mutations.length; ++i){
			var mutation = mutations[i];
			for(var j=0; j < mutation.addedNodes.length; ++j){
				if(mutation.addedNodes[j].nodeName == "#text") continue;
				var node = mutation.addedNodes[j];
				//console.log(node);
				if(node.className == 'container posts'){
					$(node).find('article').each(function(){handle_post_node(this)});
					continue;
				}
				// just to be sure (TODO: sometimes when jumping to a thread via notification the posts aren't handled.
				// This "hack" (should) ensure that all posts are handled )
				if(node.className == 'topic-link'){
					$(window.document).find('article').each(function(){handle_post_node(this)});
					continue;
				}
				if(node.className == 'ember-view post-cloak'){
					node = $(node).find('article').get(0);
				}
				if(node.nodeName == "ARTICLE" && node.getAttribute('data-user-id')){
					handle_post_node(node);	
				}
			}
		}
	});
	observer.observe(document, { subtree: true, childList: true});
}
</script>
5 Likes

You’re becoming famous! :grinning:

8 Likes

It. Just. Works.

YOU’RE AMAZING!

14 Likes

Welcome to the Elsewhere Cafe!

10 Likes

I think a round of drinks is in order! An endless mug for you?

11 Likes