DEV Community

Cover image for Trick FB with some JS to allow advertisement for titles not allowed
decker
decker

Posted on

Trick FB with some JS to allow advertisement for titles not allowed

If you want to give away your PS account, you need a list of all games purchased and as a developer you will not do it by hand.

So for my four pages of games I own for the PS I write a little script that works with:

https://library.playstation.com/recently-purchased

document.querySelectorAll('[data-qa="collection-game-list-product#title"')
  .forEach((node) =>
    console.log(node.textContent))
Enter fullscreen mode Exit fullscreen mode

So with all those console logs, I have all I need for a Facebook posting.

The problem is, my posting gets banned, I think because of some game titles in there.

My idea to get beyond this, was to add little spaces to each letter, so that a simple algorithm can not find the forbidden names.

First I create a long string from my console logs.

allTitles = `The Art of Horizon Zero Dawn™
Horizon Zero Dawn™: Complete Edition
HITMAN 3
HITMAN 3
ABZU
Enter the Gungeon
Paper Beast
Rez Infinite
The Witness
Thumper
...
Enter fullscreen mode Exit fullscreen mode

Next I transform each string line into a new string in with each letter is separated by a hair space.

spacedTitles = allTitles.split('\n').map((title) => {
  return [...title].map(char => char + '\u200A').join('')
})
Enter fullscreen mode Exit fullscreen mode

And this spaced title map is then transformed back into a long string on the console.

console.log(
  spacedTitles.reduce((all, title) =>
    `${all}${title}\n`, ''
  )
)
Enter fullscreen mode Exit fullscreen mode

Becoming this

T h e   A r t   o f   H o r i z o n   Z e r o   D a w n ™ 
H o r i z o n   Z e r o   D a w n ™ :   C o m p l e t e   E d i t i o n 
H I T M A N   3 
H I T M A N   3 
A B Z U 
E n t e r   t h e   G u n g e o n 
P a p e r   B e a s t 
R e z   I n f i n i t e 
T h e   W i t n e s s 

And this is finally not recordnized by FB as forbidden - mission complete.

Top comments (0)