FC - Hitman

Borra los temas (políticos, fútbol, apuestas, etc..) que quieras de FC

当前为 2015-12-08 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         FC - Hitman
// @namespace    https://greasyfork.org/es/scripts/14670-fc-hitman
// @version      0.4
// @description  Borra los temas (políticos, fútbol, apuestas, etc..) que quieras de FC
// @author       You
// @match        http://*.forocoches.com/*
// @grant        none
// @require 	 http://code.jquery.com/jquery-latest.js
// ==/UserScript==
/* jshint -W097 */
'use strict';

var hitman = function ()
{
	var words = {
		politics: ["Saenz de Santamaria", "Sáenz de Santamaría", "votantes", "pdr snchz", "partido político", "partido politico", "Pedro Sánchez", "Pedro Sanchez", "rajoy","soraya", "falange", "pableras","upyd", "coletas","psoe","debate", "carmena", "voto", "pablemos", "ciudadanos", "ciutadans", "discurso", "albert", "rivera", "iglesias", "elecciones", "votar", "votación", "votacion", "pedro sanchez", "pedro sánchez", "podemos", "podemitas", "pp"],
		football: ["real madrid", "futbol", "fútbol", "porra", "apuesta"]
	},
	clog = [];
	
	var init = function ()
	{
		removeThreads();
		setupPanel();
	}
	
	var setupPanel = function ()
	{
		$(".cajasprin:nth-of-type(1) tr").eq(1).append('<td><div id="hitman-config">Hitman</div></d>');
		
		var html = parseTemplate(function()
		{/*
			<div id="hitman-panel">
				Esconder temas de:
				<ul>
					<li>
						<label>
							<input type="checkbox" value="politics"> Política
						</label>
					</li>
					<li>
						<label>
							<input type="checkbox" value="football"> Fútbol
						</label>
					</li>
				</ul>
				<button>Guardar cambios</button>
			</div>
			<style>
				#hitman-config {
					cursor: pointer;
				}
				#hitman-panel {
					display: none;
					position: fixed;
				    background: white;
				    padding: 5px;
				    border: 1px solid;
				    margin-left: 74%;
				    margin-top: 6%;
				}
				#hitman-panel  ul {
					list-style-type: none;
			    	padding: 0px;
				}
			</style>
		*/});
		$("body").prepend(html);
		
		$("#hitman-config").on("click", function () {
			$('#hitman-panel').toggle();
		});

		$("#hitman-panel input").on("change", function () {
			updateCensor($(this).val(), $(this).is(":checked"));
		});
		
		$("#hitman-panel button").on("click", function () {
			location.reload();
		});
		loadConfig();
	}
	var loadConfig = function ()
	{
		var config = getConfig(),
			k;
		
		for (k in config) {
			if (config[k]) {
				$("#hitman-panel input[value=" + k + "]").prop("checked", true);
			}
		}
	}
	var parseTemplate = function(func) {
		return func.toString().replace(/^[^\/]+\/\*!?/, '').replace(/\*\/[^\/]+$/, '');
	}
	
	var updateCensor = function (type, status)
	{
		var config = getConfig();
		
		config[type] = status;
		
		setConfig(config);
	}
	
	var getConfig = function ()
	{
		var config = localStorage.hitman;
		
		if (config === undefined) {
			// default config
			return {
				politics: true,
			};
		}
		
		return JSON.parse(config);
	}
	
	var setConfig = function (config) {
		localStorage.hitman = JSON.stringify(config);
	}
	
	var removeThreads = function ()
	{
		var censorList = [],
			config = getConfig(),
			k;
		
		
		// setup the word censorship list
		for (k in config) {
			if (config[k]) {
				censorList = censorList.concat(words[k]);
			}
		}

		// find and delete threads containing those words
		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 censorList) {
				word = censorList[k];
				if (title.search(new RegExp(word, "i")) !== -1 || intro.search(new RegExp(word, "i")) !== -1 ) {
					jQuery(this).remove();
				}
			}
		});
	}
	
	return {
		init: init,
		clog: clog
	}
}();

$(document).ready(function() {
	hitman.init();
});