Cloaking Specific Text on Web Page

293 Views Asked by At

Is there any way I could make specific text strings "invisible" on my web page?

For example,

If I were to specify the string "hxxp://nullrefer.com/?", I would need that text to appear invisible on my page everywhere it's mentioned, automatically.

So, if the url "hxxp://nullrefer.com/?hxxp://www.Amazon.com" were to be mentioned on my page, viewers would only be able to see the "hxxp://www.Amazon.com" portion of it. Almost as if you were to turn the Opacity of to the text down to 0% for that specific string only, everywhere it appears on the page, automatically. I need it to still physically be there, but be as invisible as possible.

Are there any scripts out there for something like this?

1

There are 1 best solutions below

1
On

This will replace all of the links on your page with whatever you specify instead of nullrefer.. Also if you only want it to affect a certain id/class you can do it with

a[i].parentNode.id == "someid" a[i].parentNode.className == "someid"

Pretty basic and awful but it'll do what you want. Add it to the bottom of your page.

<script type="text/javascript">

var a = document.getElementsByTagName('a');
for(i=0;i<a.length;i++)
{
    if(a[i].parentNode.id == "someid")
    a[i].href = "hxxp://www.nullrefer.com/?" + a[i].href;
}
</script>