Skip to content

Instantly share code, notes, and snippets.

@kms70847
Created February 2, 2015 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kms70847/50602fde7106a3d2d818 to your computer and use it in GitHub Desktop.
Save kms70847/50602fde7106a3d2d818 to your computer and use it in GitHub Desktop.
removes the avatars of ten-or-less rep users
// ==UserScript==
// @name avatar blocker
// @namespace about:blank
// @description removes the avatars of ten-or-less rep users
// @include http://chat.stackoverflow.com/rooms/*
// @version 1
// @grant none
// ==/UserScript==
//gets the reputation of the user that owns this user-container
function getRep(userBox){
var id = parseInt(userBox.id.replace(/[^\d]*/, ""));
//`users` might not exist yet, if the page just recently loaded.
if (users[id] == undefined){return undefined;}
return users[id].reputation;
}
//alters the image in this user-container to the default anonymous avatar.
function anonymize(userBox){
userBox.getElementsByClassName("avatar")[0].getElementsByTagName("img")[0]["src"] = IMAGE("anon.png");
}
//iterate through the users in the sidebar, anonymizing anyone with ten or less rep
function check_users(){
sidebar = document.getElementsByClassName("sidebar-widget")[0];
userBoxes = sidebar.getElementsByClassName("user-container");
for(var i = 0; i < userBoxes.length; i+=1){
var userBox = userBoxes[i];
var rep = getRep(userBox);
if (rep < 10){
anonymize(userBox);
}
}
}
//check users once a second
window.setInterval(check_users, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment