Archive for March, 2009

Kill All Quizzes…

Updated 2009-08-03

Well the script stopped working a while ago, and I didn’t bother to update it… but this evening I thought I would…

Intro

So, Facebook sucks, but I can’t quit it. Anyone want to look up the definition of “addiction”? The newly redesigned news-feed removed the filter-by-app feature and added quizzes. Stupid fucking quizzes!

Googling for a way to remove them, I stumbled upon this Greasemonkey script by pepcza. It’s very simple and clever, using <jargon>XPath</jargon>, something that I’ve never touched before. It works, but doesn’t catch all quizzes, it requires you to use Firefox and install Greasemonkey, and it doesn’t delete those dag-named quizzes on the second viewing.

So I decided to make a bookmarklet that everyone can install in their bookmarks toolbar. One click, and bam, the quizzes disappear. Well almost all of them anyway.

How-To – Kuneri’s Version

Kuneri wrote a filter that is more comprehensive that it deletes all “news” from external apps (so he claims), which is a good idea because Facebook apps are 99.9% shit anyway. It also catches new items and filters them straight away.

I’ve expanded on his work and made different options, e.g. one that just fades the spam and makes it readable when you click on it, and another one that makes it faded and not take up that much space.

Total Deletion
javascript:void(( function () { document.addEventListener("DOMNodeInserted",function(event) {if(location.href.match('\/home\.php') && event.target.getElementsByClassName && event.target.getElementsByClassName('UIIntentionalStory_AttachmentInfo')) cleartheshizzle(event.target);}, false ); var cleartheshizzle=function(storyNode) {var footernodes = storyNode.getElementsByClassName('UIStoryAttachment');for (var i = 0; i < footernodes.length; i++) {if (footernodes[i].innerHTML.match('apps\.facebook\.com\/')) {storyNode.style.display='none';}};footernodes=null; }; if(location.href.match('\/home\.php')) {var storyNodes = document.getElementsByClassName('UIIntentionalStory');for (var i = 0; i < storyNodes.length; i++) {cleartheshizzle(storyNodes[i]);} }})());

Faded and Shrunk, Click to View
javascript:void(( function () { document.addEventListener("DOMNodeInserted",function(event) {if(location.href.match('\/home\.php') && event.target.getElementsByClassName && event.target.getElementsByClassName('UIIntentionalStory_AttachmentInfo')) cleartheshizzle(event.target);}, false ); var cleartheshizzle=function(storyNode) {var footernodes = storyNode.getElementsByClassName('UIStoryAttachment');for (var i = 0; i < footernodes.length; i++) {if (footernodes[i].innerHTML.match('apps\.facebook\.com\/')) {var tgt = storyNode;tgt.onclick = function() {this.style.height = (this.style.height == '20px')?'auto':'20px';this.style.opacity = (this.style.opacity < 1)?1:0.2;};tgt.style.height = '20px';tgt.style.opacity = 0.2;tgt.style.overflow = 'hidden';}};footernodes=null; }; if(location.href.match('\/home\.php')) {var storyNodes = document.getElementsByClassName('UIIntentionalStory');for (var i = 0; i < storyNodes.length; i++) {cleartheshizzle(storyNodes[i]);} }})());

Here’s a preview of what it does, with pixelation to protect the innocent and the stupid:
Fade and Shrink

How To
  1. Copy one of the codes in the gray boxes above (you can triple-click to select the whole thing) into your clipboard.
  2. Go to your Bookmarks toolbar (in Firefox, this is the bar where the “Smart Bookmarks” appears), right click in an empty area, and select “New Bookmark…”
  3. Add Bookmark
    Paste the copied code into the “Location:”
  4. Give the bookmark a name. I label mine “Fuck Quizzes”, and click “Add”.
  5. To test, go to your Facebook news feed, click the bookmark, and see the quizzes (if there were any) disappear.
  6. Profit!

Old and Doesn’t Always Work – pepcza Version

pepcza’s version of the script tries to find the words “took the” and “quiz”, but I think the quizmakers are changing it to “completed the quiz”, so it doesn’t always work.
(Tried on Firefox and Opera. If you use IE, my condolonces.)

  1. Copy the following code (you can triple-click to select the whole thing) into your clipboard:
    javascript:void((function(){var filterString = []; var h = 0; filterString[h++] = "//h3[@class = 'UIIntentionalStory_Message' and ((contains(string(.), 'took the') and contains(string(.), 'quiz')) or contains(string(.), 'Check out this quiz!'))]/ancestor::div[contains(@class, 'UIStory')][1]"; filterString[h++] = "//div[@class = 'UIStoryAttachment_Copy' and ((contains(string(.), 'took') and contains(string(.), 'quiz')) or contains(string(.), 'Check out this quiz!'))]/ancestor::div[contains(@class, 'UIStory')]"; for (var h = 0; h < filterString.length; h++) { var quizStories = document.evaluate(filterString[h], document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < quizStories.snapshotLength; i++) { quizStories.snapshotItem(i).style.display = 'none';}}})());
  2. Continue with Step 2 above!

Thoughts

I wonder if there’s a way to “OR” XPath statements, there probably is, I’m just too lazy to read up on it. And I wonder if this will just make the problem worse, because people who remove the damned quiz-spam will not complain about it, and the original problem won’t get fixed.

Oh No, A Diary!

Anyway, I happened upon avoision.com through BoingBoing, and wasted a few hours reading through the entries. Heh, blogs that go back years and years and have a lot of entries are always fun like that. It also reminded me of my own attempts of blogging, and then returning to the entries years later to think, “Wow, I’ve forgotten about that!”

So then I thought, “I should start (re-)doing that, blogging my daily life.”. Then I thought, “But all I do is sit around and watch my life tick away.” (not really, but that’s the “executive summary”).

Anyway, today I’ve been hacking a PHP script… hey, where did everyone go? … that creates HTTP Post requests, especially multi-part requests. The post body is made as a MIME stream, with a separator string that is unique and doesn’t occur in the contents. So I created said MIME stream, sent it to the server, and the server doesn’t see it properly. After a few hours of debugging, I saw the problem.

If the boundary (i.e. separator) is “abcd”, the first part is indicated with "--abcd", the last part is terminated with "--abcd--". Unfortunately the boundary Firefox generates is usually something like "------------1231231312". So two more -’s in front of that wasn’t really noticable.

Aarrgghhh!!!!

Oh well, that’s the problem with not reading the specs… you FAIL.


 

March 2009
M T W T F S S
« Jan   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

a

Reverse

To reverse the order of the entries (chronogical top-to-bottom), paste this into your address bar, and hit Enter: