Skip to content

Instantly share code, notes, and snippets.

@motemen
Created March 30, 2011 13:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motemen/894439 to your computer and use it in GitHub Desktop.
Save motemen/894439 to your computer and use it in GitHub Desktop.
Make one's tweets boring
// ==UserScript==
// @name BoringTwitter
// @namespace http://tokyoenvious.net/
// @description Make one's tweets boring
// @include http://twitter.com/#!/*
// @include https://twitter.com/#!/*
// @require https://github.com/cho45/jsdeferred/raw/master/jsdeferred.userscript.js
// ==/UserScript==
with (D()) + function () {
var match = /^#!\/(\w+)/.exec(location.hash);
if (!match) return;
var screenName = match[1];
var isInterestingTweetID = null;
var tweetElemsToCheck = [];
getInterestingTweetIDs(screenName).next(function (ids) {
isInterestingTweetID = ids;
tweetElemsToCheck.forEach(filterTweetElem);
});
document.addEventListener('DOMNodeInserted', function (e) {
var elem = e.target;
if (elem.className.indexOf('stream-item') == -1) return;
if (!isInterestingTweetID) {
tweetElemsToCheck.push(elem);
} else {
filterTweetElem(elem);
}
}, false);
function getInterestingTweetIDs (screenName) {
try {
var cache = eval(GM_getValue('favstar-' + screenName, '({})'));
} catch (e) {
}
if (cache && cache.expire > new Date().getTime()) {
return next(function () { return cache.ids });
}
return xhttp.get('http://favstar.fm/users/' + screenName + '/rss').next(function (r) {
var ids = {};
var d = DOMParser().parseFromString(r.responseText, 'text/xml');
Array.forEach(
d.querySelectorAll('item link'), function (link) {
if (/(\d+)$/.exec(link.textContent)) {
ids[RegExp.$1] = true;
}
}
);
GM_setValue(
'favstar-' + screenName,
uneval({
expire: new Date().getTime() + 60 * 60 * 1000, // 1 hour
ids: ids
})
);
return ids;
}).error(function (e) { alert(e) });
}
function filterTweetElem (elem) {
var tweetID = elem.getAttribute('data-item-id');
if (isInterestingTweetID[tweetID]) {
elem.style.visibility = 'hidden';
}
}
} ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment