Block Spambot Phone/Email Harvesting
Spambots are about. They harvest telephone numbers and email addresses from websites and store them in a database.
Then they spam the numbers and addresses from in their database with telephone calls, email, and text messages.
Some website owners don't publish their addresses and numbers on their websites because they don't want to be bothered. Others, especially business owners, want that information available to their prospective customers, yet they hesitate to publish it because of the spam problem.
A common compromise is using a form for people to get in touch. Because there are bots that automatically submit forms with their spam messages, many site owners resort to a form that can't be automatically submitted, like Spam-Free Form.
Most email address and telephone number harvesting robots are unsophisticated. They parse the source code of the web page, grab what they're interested in, and go on to the next URL. The bots might parse JavaScript. Yet few, if any, compile and run JavaScript.
By parsing JavaScript, I mean they are likely to find this email address because it is a simple parse:
var address = "name@example.com";
However, they are unlikely to find this email address:
var address = "name"; address += "@"; address += "example.com";
JavaScript with more obfuscation than the above example is virtually impossible to parse.
In addition to spambots, there is software out there that grabs an image of web pages. That image is scanned by other software to read email addresses, telephone numbers, and other information the software engineers may be interested in.
To get around that, the system presented in this article delays publishing and linking the email or phone data on the web page. Thus, an image made of the web page does not have that information.
Further below, you'll see a custom JavaScript code generator for delayed publication of obfuscated versions of your telephone number and/or email address. The number and address are linked so your reader can tap instead of copy.
When you see the code the generator provides, I think you will be well satisfied that spambots are unable to parse it.
First, here is a demonstration. Then, I will describe how to implement it for your contact or other pages.
Telephone:
Email:
Publishing of the above data was delayed 4 seconds. To view the delay, reload this page.
Spambot Block and Delayed Publication Implementation
Implementing the feature requires two things:
-
The HTML code with places to publish the email address and/or telephone number.
-
The JavaScript to maintain the obfuscation and to delay the publication of the data.
Let's get started.
The HTML to Publish the Phone/Email
The telephone number is published within an HTML container that has an id="-ph-content-"
id and value. It may be a div
container or a span
container. (Or other HTML container, such as pre
or td
.)
The example on this page uses a span
container.
Within the span container, before the telephone number is published, can be any content or no content at all. If it contains content, the content is replaced with the telephone number when the number is published.
The example on this page puts a "loading" icon into the span
container. For clarity, here is the HTML tag being used for the example.
<span id="-ph-content-"> <img src="https://www.willmaster.com/images/working.gif" style="height:.8em;" alt="loading"> </span>
Wherever you put the HTML container for the telephone number is where the JavaScript will publish the number when 4 seconds have elapsed. (See The JavaScript Code Generator for the JavaScript.)
Publishing the email address is similar to publishing the telephone number. The difference is the id
value. Use id="-em-content-"
for the email address.
For clarity, here is the HTML tag being used for the example on this page.
<span id="-em-content-"> <img src="https://www.willmaster.com/images/working.gif" style="height:.8em;" alt="loading"> </span>
Here is the JavaScript code generator.
The JavaScript Code Generator
Use the generator below to generate the JavaScript your implementation will require.
Delayed-Publication JavaScript Generation
Email address:
Telephone number:
(generated code will be in box below)
The generator does not check for valid-formatted email addresses or telephone numbers.
Also, no customization is required for the above code, although you can make adjustments if you wish to.
Install the JavaScript by pasting the code into your web page near the bottom of your web page source code. Above the cancel </body>
tag generally is a good spot.
When it's installed, it's ready to go.
Testing
When the HTML containers for either or both the linked telephone number and/or linked email address are in place, along with the JavaScript provided by the generator above, then the system should work.
Test it, of course. Tap the linked telephone number to see if your computer or device reacts as expected. And tap the linked email address to also check its reaction.
The generator in this article may be used for any telephone numbers and email addresses that you want to publish.
(This article first appeared in Possibilities newsletter.)
Will Bontrager