Press "Enter" to skip to content

Facebook’s hidden battle against ad-blockers

The methods Facebook uses to thwart ad-blocking technology have been criticised by web developers.

The social network injects dozens of lines of code in every page to make it harder for ad blockers to detect and hide sponsored posts.

But that makes the website less efficient and stops software such as screen readers used by visually impaired users from working properly.

The BBC has contacted Facebook for comment.

In order to block advertising, developers look for patterns in a website’s code that can be consistently identified and hidden.

It would be easy for a plug-in to spot the word “sponsored” or to find a container labelled “ad” inside the webpage code, so companies, including Facebook, use coding tricks to obfuscate their ads.

The tricks Facebook uses to fool ad-blocking plug-ins include:

  • breaking up the word “sponsored” into small chunks only one or two letters long
  • inserting extra letters, as in “SpSonSsoSredS”, hidden to the viewer
  • adding the word to all regular posts on the news feed, even ones that are not ads, and then using another piece of code to hide it on the non-ads

Facebook provides some controls for users to influence the ads they see.

“Although you can’t opt out of seeing ads entirely, you can influence the types of ads you see by giving us feedback or hiding ads and advertisers that you don’t want to see,” it says in its help centre.

Developers working on the uBlock Origin browser plug-in have been documenting their counter-measures on coding site Github.

In one case, they worked at blocking ad containers labelled “feed_subtitle” and “feed-subtitle”.

“That solves it quite neatly,” one said. But two days later, Facebook had changed its code again.

“These guys act quick. Now the div [container] is named ‘feed_sub_title_ 128; 1402960186614717; 0; 2216051248638936; 1542673577: -7185000746684546330: 5:0:47233’,” a coder said.

One, posting as filbo, pointed out that the sponsored text was different depending on your language settings, so ad-blocking efforts should not focus on the word “sponsored”.

“If a workable UI-language-neutral expression can be written, that’s better,” they wrote.

Another, posting as okiehsch, suggested development would never stop.

“I doubt very much that Facebook will stop trying to push their ads, so this issue will never be ‘fixed’,” they wrote.

Source: BBC