Protecting your content from AI scrapers by drawing text in javascript


We live in an annoying age of mass AI scraper bots that don't obey the law.

In many scenarios(but not all) you can protect content by drawing the text in html5

To draw text on an HTML5 canvas using JavaScript, you use the fillText() or strokeText() methods of the 2D rendering context.

  • First, obtain a reference to the canvas element and its 2D context using getContext('2d').
  • Then, set properties like fontfillStylestrokeStyletextAlign, and textBaseline to control the appearance and positioning of the text.
  • The fillText() method draws filled text, where the text is filled with the current fillStyle
  • Its syntax is ctx.fillText(text, x, y [, maxWidth]), where text is the string to draw, x and y are the coordinates for the starting point, and maxWidth is an optional parameter to constrain the text width.

Here is a good standard hello world


const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'green';
ctx.font = '60px san-serif';
ctx.fillText('Hello, World!', 100, 200);

 

 

How do you rate this article?

3


Ph03nix
Ph03nix

I am and ethical hacker with years of experience, and many certifications.


Useful Tools for Techs, Geeks, Dorks, and Nerds
Useful Tools for Techs, Geeks, Dorks, and Nerds

This is dedicated to Useful hardware and software tools for those in the IT profession and for those who just do it as a hobby.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.