DEV Community

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

Posted on

4 3

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.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay