简体   繁体   English

通过JavaScript隐藏Google的链接

[英]Hide links from Google via JavaScript

We have some links we want to hide from Google, using Javascript to "hide" the link but let it work for the real clients. 我们有一些我们想从Google隐藏的链接,使用Javascript“隐藏”该链接,但让其对实际客户有效。

I was told from the SEO agency that the best method is to base64 encode the link and call it via javascript: SEO机构告诉我,最好的方法是对链接进行base64编码并通过javascript调用它:

<a data-href="RdcDovL1N0YWdpbmc...base64...hhcmRpbmctaGVycmVuLWhlbaQtMTgyMDg3"
   href="#">Link</a>


<script>
<!--
var _dlist = document.getElementsByTagName('A');
for(i=0;i<_dlist.length;i++) {
    var _data = _dlist[i].getAttribute( 'data-href' );
    if( _data !== 'null' ) {
        var _extend = CryptoJS.enc.Base64.parse( _data );
        _dlist[i].setAttribute( 'href', _extend.toString( CryptoJS.enc.Latin1 ) );
    }
}
-->
</script> 

My problem now is, I don't want to include another 2 files (they suggested me crypto-js lib) just for the links. 我现在的问题是,我不想仅为链接添加另外两个文件(它们向我建议crypto-js lib)。 I'd like to ask you, how far does Google reveal links and follow them and what's the easiest approach without loading more scripts. 我想问你,Google展示链接并跟踪链接有多远,什么是最简单的方法而不加载更多脚本。 jQuery is available. jQuery可用。

This is what I ended up with: 我最终得到的是:

Links look like: 链接看起来像:

<a href="#" onclick="linkAction(this); return false;" 
   data-href="uggc://fgntvat.....">

Where data-href is Rot13 encoded and linkAction does: 其中data-href是Rot13编码的,而linkAction是:

function linkAction(e) {
    window.location = rot13($(e).data('href'));
}

..in an external JS file. ..在外部JS文件中。

I think this is the best obfuscation without performance overhead. 我认为这是没有性能开销的最佳混淆方法。 Let's see what the SEO agency says :-) 让我们看看SEO机构说的是什么:-)

PS Rot13 taken from: Where is my one-line implementation of rot13 in JavaScript going wrong? PS Rot13来自: 我的JavaScript中rot13的单行实现在哪里出错?

The thread is a bit abandoned, and the circumstances are a bit other too. 该线程已被废弃,情况也有所不同。 The code cited at the beginning seems to be from the agency i was working for. 一开始引用的代码似乎来自我工作的代理商。

After becoming known the googlebot is a kind of Chrome and posts like this , there are not many approaches remaining to hide links from googlebot. 成为Googlebot的一种Chrome浏览器并发布了类似这样的信息后 ,就没有太多方法可以隐藏来自Googlebot的链接了。

One approach seems to me to be promising - maybe, if somebody would find it promising too, it would be coded: 在我看来,一种方法似乎很有希望-也许,如果有人也觉得有希望,它将被编码为:

  • Step 1: publish a non-existing image 步骤1:发布不存在的图像
  • Step 2: write a javascript function, which finds links with special certain class="hidden" and redesigns urls in the href-attribute using a regex. 第2步:编写一个javascript函数,该函数查找具有特定特定class="hidden"链接,并使用正则表达式重新设计href属性中的网址。 With redesign i mean something like: replace . redesign意思是:替换. and/or / with | 和/或/| , % or * , or divide url in some parts with non-url characters, like | %* ,或在某些部分用非网址字符分隔网址,例如| or * . *
  • Step 3: write a second javascript function, which redesigns urls back to real urls, 第3步:编写第二个JavaScript函数,将网址重新设计为真实网址,
  • Step 4: place both javascripts into external file and close it against crawling with X-Robots-Tag 第4步:将两个JavaScript都放到外部文件中,然后关闭它以防止使用X-Robots-Tag进行抓取
  • Step 5: fire onError for non-existing image at least 6 seconds after onLoad (to be sure, that Googlebot goes away) 第5步:在onLoad后至少6秒钟为不存在的图片触发onError (确保Googlebot消失了)
  • Step 6: trigger through onError the second javascript, which makes urls urls again 第6步:通过onError触发第二个javascript,这将再次使url变为url

The approach could be maybe reverted, like: url redesign could be triggered immediately through onError , and Back-Redesign could be triggered through onClick . 该方法可以还原,例如:可以通过onError立即触发url重新设计,而可以通过onClick触发Back- onClick

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM