lyze237 / Reddit Spam Blocker

// ==UserScript==
// @name         Reddit Spam Blocker
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Tries to destroy spam things on reddit
// @author       Michael Weinberger
// @match        https://www.reddit.com/*
// @grant        none
// @homepageURL  https://lyze.at
// @author       lyze237
// ==/UserScript==
/* jshint -W097 */
'use strict';

// Your code here...
var whatToObserve = {childList: true, attributes: true, subtree: true, attributeOldValue: true, attributeFilter: ['class', 'style']};
var mutationObserver = new MutationObserver(function(mutationRecords) {
  $.each(mutationRecords, function(index, mutationRecord) {
      doIt();
  });
});
mutationObserver.observe(document.body, whatToObserve);

function doIt() {
 $('.thing').each(function( index ) {
    var title = $(this).find('.title').text();
    
    var alphabetic = /^[a-zA-Z0-9]+$/;
    
    var count = 0;
    for (var i = 0, len = title.length; i < len; i++) {
        if (alphabetic.test(title[i])) {
            count++;   
        }
    }
    
    if (count / title.length < 0.4) {
        $(this).remove();
        console.log(title + ": " + count + "(" + count / title.length + ")");   
    }
});   
}