AdBlock for Facebook

Block / Hide "Sponsored" posts on Facebook

Author
thorlancaster
Daily installs
1
Total installs
996
Ratings
2 0 0
Version
1.6
Created
Updated
License
N/A
Applies to

Author's Description

This script blocks ads on Facebook that use the word "Sponsored" or contains those letters in that order with other characters from "Sponsored" thrown in between.

As of the time posting it works great on the English version of Facebook.

This script works differently than other sponsored-post blockers in that it does not try to match a list of possible patterns. In addition, posts that have been scanned and are not ads are marked with a special variable. The above improvements make the performance impact of this script minimal (around 4ms with 100 posts on page).

Due to Facebook's ever-changing ad-obfusciation techniques, this script may periodically fail to block sponsored posts. To determine the cause of the error, add "abDbg=true" as a URL parameter. Normal posts will then be colored green and sponsored posts red. If a post is not colored, the checkAds() function is missing some posts. If a sponsored post is green, the isAd() function is at fault.

Version 1.3 worked for quite some time, but after the Facebook outage early March 2019, sponsored posts began to sporadically re-appear. I am not entirely certain of the reason but suspect that content is now being loaded asynchronously, causing posts to be blank for quite some time. With the old script, the blank posts would be scanned and verified as non-sponsored, and then Facebook would fill some with sponsored content, which would not be blocked because that post had already been scanned and found clean.

Scanning every post, every run would technically work, but that would incur an increasing CPU penalty the longer you scrolled, as the amount of posts to scan would keep growing and growing. The solution to that problem was to implement a checksum. With a checksum, the post is re-scanned whenever it changes, blowing ads away even if the post has been sitting clean and empty for a while. As of version 1.5 the checksum has been implemented and all ads are being successfully blocked on my (Chrome, Linux) computer.

Version 1.5 worked for a while, and then Facebook decided to not create the "stream_pagelet" element before the script executed. This caused my script to not work, so I added a 1.5 second delay to fix that issue.

Coming up in some future version is a small button to unhide sponsored posts. Thanks to user Mikhoul for suggesting this feature, it would be quite useful. I might also add an option to whitelist sponsored posts from certain organizations.