Skip to content

Instantly share code, notes, and snippets.

@Aran-Fey
Last active June 11, 2020 21:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Aran-Fey/bfa61a33157a5da475d110c4400eb6f2 to your computer and use it in GitHub Desktop.
Save Aran-Fey/bfa61a33157a5da475d110c4400eb6f2 to your computer and use it in GitHub Desktop.
A userscript that hides all answers and comments from certain users on StackOverflow. Currently, the user ids of the blocked users must be edited directly in the script's source code.
// ==UserScript==
// @name StackExchange hide user posts
// @description Hides all comments and answers from blocked users
// @version 1.3.8
// @author Paul Pinterits
// @include /^https?://(meta\.)?(stackoverflow|serverfault|superuser|(.*\.)?stackexchange)\.com/questions(/tagged/.*)?$/?/
// @namespace Aran-Fey
// @require https://github.com/Aran-Fey/userscript-lib/raw/ca6999d1bac2494421b70286f74d7a9a9ba636e7/userscript_lib.js
// @require https://github.com/Aran-Fey/SE-userscript-lib/raw/bf77f40b25d7fa88a6c3f474390c858446154ec2/SE_userscript_lib.js
// @grant none
// @updateURL https://gist.github.com/Aran-Fey/bfa61a33157a5da475d110c4400eb6f2/raw/SE_hide_user_posts.user.js
// @downloadURL https://gist.github.com/Aran-Fey/bfa61a33157a5da475d110c4400eb6f2/raw/SE_hide_user_posts.user.js
// ==/UserScript==
// add user ids to this array to block people
// for example, `var blocked_user_ids = [1222951];` would hide all of my posts (:
var blocked_user_ids = [];
blocked_user_ids = blocked_user_ids.map(id => id+"");
function hide_if_blocked(post){
if (blocked_user_ids.includes(post.author.id))
post.hide();
}
page.transform_answers(hide_if_blocked, Rerun.AFTER_CHANGE);
page.transform_comments(hide_if_blocked, Rerun.AFTER_CHANGE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment