Discourse Mute User Script for Greasemonkey

Found this here: imgur_userscripts/scripts/imgur_comunity_mute.user.js at master · SleepProgger/imgur_userscripts · GitHub

What it does is lets you mute a user - hiding all their posts in a single click. Very nice. Just explicitly add BBS to the pages it runs on.

2 Likes

Currently making a userscript to automatically thumbs up the posts of certain regulars who are known to post high-quality stuff. :slight_smile:

2 Likes

That is true. Can always un-love specific low-quality stuff by hand. Makes it easier to hit certain achievements (All Out of Love).

6 Likes

Haha, I bet. It’s pretty easy to whip up something that blindly likes all if that’s your thing - but that’s not my focus with the script. I just want to automatically upvote certain users with the option to revoke on specific posts if needed.

example code for blind-all below (executes in console)

$(function(){
var thingsClicky = document.getElementsByClassName("like");
var arrayLength = thingsClicky.length;
for (var i = 0; i < arrayLength; i++) {
    document.getElementsByClassName("like")[i].click();
}
});

I only know of one badge/pendant that they do that with, and that’s because that badge is an albatross hung around the neck, not an honour.

Unless, of course, you start annoying other users by going through locked topics and liking a bunch of old posts; that I can remember stirring up trouble. Otherwise, I don’t remember any issues when I went on a badge-quest.

If you can’t find fifty recent things to like here in 24 hours, I respectfully submit that you’re not looking hard enough.

4 Likes

God, too many posts to keep up with in a 24-hour period! I can’t imagine how anybody can earn/keep Regular status nowadays with the volume of posts. :7 Some threads have had 200 posts in the past twelve hours alone, most of them by HQ posters.

1 Like

The “posts read” requirement is capped at 20,000 posts read per 100 days, which is 200 posts read per day.

As you’ve said, in some instances, you can achieve that by reading one thread a day.

4 Likes

Well I don’t read all the comments/posts. I do take a look at all the new Topics and for a lot go well that is enough. Read is for the topics and if you make the little blue text that says new go away by clicking it that counts. Also check the keyboard shortcuts for skimming through comments.

2 Likes

@RatMan I think I’ve got it working, can you reply for testing purposes? (Fingers-crossed, I think it might just work)

1 Like

Can you see me now?

1 Like

edit 2: functional now, but has bug causing duplication of Reply button

// ==UserScript==
// @name        One Click Love-Script
// @namespace   discourse-autolove
// @include     https://bbs.boingboing.net/*
// @version     2017.04.11
// @grant       none
// ==/UserScript==

/*
* Patch for GM_getValue and GM_SetValue support for chrome
* credits to: www.devign.me/greasemonkey-gm_getvaluegm_setvalue-functions-for-google-chrome/
*/
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];
    };
}


$('body').ready(function(){
	var GR_COOKIE_NAME = 'discourse-autolove';
	var hide_ids = $.parseJSON(GM_getValue(GR_COOKIE_NAME, '{}'));

	function handle_post_node(node){
		var tid = node.getAttribute('data-user-id');
		function love_foo(){
			this.innerHTML = "Unlove";
//			$(node).find('.contents').hide();
			$(this).unbind('click', love_foo);
			$(this).click(ulove_foo);
			hide_ids[tid] = 1;
			GM_setValue(GR_COOKIE_NAME, JSON.stringify(hide_ids));
			$('[data-user-id="'+tid+'"]').find('.love_btn').remove();
			$('[data-user-id="'+tid+'"]').each(function(){ handle_post_node(this) });
		}
		function ulove_foo(){
			this.innerHTML = "love";
//			$(node).find('.contents').show();
			$(this).unbind('click', ulove_foo);
			$(this).click(love_foo);
			delete hide_ids[tid];
			GM_setValue(GR_COOKIE_NAME, JSON.stringify(hide_ids));
			$('[data-user-id="'+tid+'"]').find('.ulove_btn').remove();
			$('[data-user-id="'+tid+'"]').each(function(){ $(this).find('.contents').show(); handle_post_node(this) });
		}
		// execute on finding loved one
		if(hide_ids[tid]){			
//			$(node).find('.contents').hide();
			$(node).find('.contents').show();
			if($(node).find('.ulove_btn').length > 0) return;
			var btn = $('');
			$(node).find('.post-info').first().prepend(btn);
			btn.click(ulove_foo);
			$('[data-user-id="'+tid+'"]').find("like").click();
			$('[data-user-id="'+tid+'"]').find(".like").click();
		}
// end execute
			else{
			if($(node).find('.love_btn').length > 0) return;
			var btn = $('');
			btn.insertBefore($(node).find('.create').last());
			btn.click(love_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});
	});

forked from https://github.com/SleepProgger/imgur_userscripts/blob/master/scripts/imgur_comunity_mute.user.js

2 Likes

IT WORKS NOW! deleting previous post and uploading code. has a nasty duplication bug with Reply tho.

2 Likes

Thank you so much for your help - absolutely invaluable. I have a feeling the script is going to bite me in the ass in the future, probably going to develop it further, but it is functional and completes today’s RL Achievements quota. Muchas Gracias, amigo!

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.