FC - Hitman

Borra temas políticos de FC

目前為 2015-12-08 提交的版本,檢視 最新版本

// ==UserScript==
// @name         FC - Hitman
// @namespace    http://forocoches.com/
// @version      0.1
// @description  Borra temas políticos de FC
// @author       You
// @match        http://*.forocoches.com/*
// @grant        none
// ==/UserScript==
/* jshint -W097 */
'use strict';

// Your code here...
var hitman = function () {
	var words = ["rajoy","soraya", "falange", "pableras","upyd", "coletas","psoe","debate", "carmena", "voto", "pablemos", "ciudadanos", "ciutadans", "discurso", "albert", "rivera", "iglesias", "elecciones", "votar", "votación", "votación", "pedro sanchez", "pedro sánchez", "podemos", "podemitas", "pp"],
	clog = [];
	
	var init = function () {
		removePoliticThreads();
	}
	
	var removePoliticThreads = function () {
		jQuery('#threadbits_forum_2 tr').each(function () {
			var title = jQuery(this).find("td[title] a").eq(1).text(),
				intro = jQuery(this).find("td[title]").attr("title"),
                k,
				word;
			
			for (k in words) {
				word = words[k];
				if (title.search(new RegExp(word, "i")) !== -1 || intro.search(new RegExp(word, "i")) !== -1 ) {
					jQuery(this).remove();
				}
			}
		});
	}
	
	return {
		init: init,
		clog: clog
	}
}();

if (typeof jQuery == "undefined")
{
	var s = document.createElement("script");
	s.type = "text/javascript";
	s.src = "//code.jquery.com/jquery-1.11.3.min.js";
	document.head.appendChild(s);

	// Electrik se peta el debugging en JS
	console.log = function () {
		for (var i = 0; i < arguments.length; i++) {
	        hitman.clog[hitman.clog.length] = arguments[i];
	    }
	}

	setTimeout(function (){
		jQuery(function() {
			hitman.init();
		});
	}, 1000);
} else {
	hitman.init();
}