No Sarahah

Chrome Extension

Foreword

I'm neither for nor against the idea of Sarahah. I'm indifferent towards it. This extension was developed as a quick hack in response to a casual conversation with a friend who asked: "Is there a way to block these annoying Sarahah.com posts flooding my Facebook feed ?" :) A day later, here I am.

What is Sarahah? TL;DR Version

Service, named after the Arabic word for “honesty,” quickly became a hit. Following its launch in June on the App Store, it rose to the top free app. Sarahah bills itself as a way to collect “honest” feedback — a chance for friends and co-workers to offer advice, comment on your strengths and weaknesses, or frankly point out problems. Sarahah has become a full-blown fad, taking over the feeds of Twitter and Facebook through screenshots of the teal speech bubbles that hold their anonymous messages.

The Issue

Though Facebook feeds offers a way to block certain App Post, posts from Sarahah are embedded images that not posted or linked to a Facebook App. Hence the current system was limited in its ability to block all Sarahah related posted for a user. The fact that the service went viral, most users, especially in certain demographics and geographic sectors see a steep rise in Sarahah posts.

The Solution

The Chrome extension works on Facebook.com pages and 'listens' for changes to Feed (using MutationObservers). The extension on the client browser then scans the newly loaded posts for images and hyperlinks to '*.sarahah.com'.

For a noob extension developer, with limited client-side image processing experience, it was fascinating to look back at the different approaches I attempted and failed.

Approach - I (Image Similarity)

Resemble.JS, a library analyses and compares images with HTML5 canvas and JavaScript. It compares two image canvases and provides a percentage similarity between the two images.

With a base image of the Sarahah message bubble, the extension tried to compare images on the feed for similarity. Unfortunately, the processing of this operation was rather heavyweight for the rate at which new feeds loaded on feeds and this led to frequent unresponsiveness of the browser tab.

Optimizing the scan by looking for images above a particular size of width did not help much in improving the performance issues.

Approach - II (Dominant Color)

The next approach was to use the 'Teal' branding of Sarahah to spot the images. I explored identifying the commonly used color in the image to match with 'Teal' piggy-banking on a library, Color-Thief.

However, there was one limitation to this approach. The palette returned varied depending on the number of words in the message and this lead to a relatively poor hit rate of about 70%.

Approach - III (Vibrant Color)

In the process of looking around of client side image processing libraries, I stumbled on Vibrant.js which in addition to the dominant colors, also returned the 'Most Vibrant' colors among other qualified colors.

This way the hit rate to the match for Teal color in most cases except the ones with 'excessive' emojis was much better.

Bringing it all together

The final optimization to improve the color matching. I learn that the
'color distance' between two RGB triplets was an inaccurate measure of color similarity. DeltaE Algorithms was better based on the perception of the human eye for color similarity.

After optimizing the match distances values based on a training set of 1000 images generated from a rather crude library, Occupy-Sarahah, I was able to ascertain a limiting distance with 95% confidence levels.

Closing Thoughts

However, the extension is not available on the Chrome Web Store (but can be downloaded from the link below). The extension in certain ways discourages the use and promotion of Sarahah App. On an ethical note and with empathy towards the developers of Sarahah, I believe the choice of use and disuse should be left to the user and not be enforced.