Remove Tweet Footers

By cxx Last update Feb 8, 2009 — Installed 51 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0

There are 1 previous version of this script.

// ==UserScript==
// @name           Remove Tweet Footers
// @namespace      http://cxx.tumblr.com/
// @include        http://twitter.com/*
// @include        https://twitter.com/*
// @include        http://explore.twitter.com/*
// @require        http://gist.github.com/3242.txt
// @version        0.1.20090208.0
// ==/UserScript==

var NGList;

function loadNGList() {
	NGList = eval(GM_getValue('NGList', {}));
}

function storeNGList() {
	GM_setValue('NGList', NGList.toSource());
}

function scanStatuses(pages) {
	var statuses = [];
	var ngPat = /\s+[*[][\s\S]{1,20}$/;
	pages.forEach(function(p){
		$X('.//li[starts-with(@class,"hentry")]', p).forEach(function(i){
			var name = ($X('span[@class="status-body"]/strong/a', i)[0]
				|| $X('//meta[@name="page-user-screen_name"]/@content')[0]
			).textContent;
			var node = $X('.//span[@class="entry-content"]', i)[0];
			var body = node.innerHTML.replace(/<a href="[^"]+">\.\.\.<\/a>$/, '');
			var id = i.id.slice(7);
			statuses.push({ name: name, node: node });
			if (!NGList[name])
				NGList[name] = { ng: [] };
			var match = ngPat.exec(body);
			if (match && match[0].indexOf('twicco') == -1) {
				if (NGList[name].cand && NGList[name].cand.id != id) {
					if (match[0] == NGList[name].cand.body)
						NGList[name].ng.push(NGList[name].cand.body);
					delete NGList[name].cand;
				}
				if (NGList[name].ng.every(function(n){ return n != match[0]; }))
					NGList[name].cand = { body: match[0], id: id };
			}
			else
				delete NGList[name].cand;
		});
	});

	statuses.forEach(function(s){
		var body = s.node.innerHTML;
		NGList[s.name].ng.forEach(function(n){
			body = body.replace(n, '');
		});
		s.node.innerHTML = body;
	});
	statuses.forEach(function(s){
		if (NGList[s.name] && !NGList[s.name].cand && NGList[s.name].ng.length == 0)
			delete NGList[s.name];
	});

	storeNGList();
}

function clearNGList() {
	NGList = {};
	storeNGList();
}

function addFilter() {
	window.AutoPagerize.addFilter(scanStatuses);
}

loadNGList();
scanStatuses([document.body]);

if (window.AutoPagerize)
	addFilter();
else
	window.addEventListener('GM_AutoPagerizeLoaded', addFilter, false);

GM_registerMenuCommand('Remove Tweet Footers - clear NG list', clearNGList);