autorlink.js

来自「源码新闻发布系统」· JavaScript 代码 · 共 49 行

JS
49
字号
// AutoRLink - auto rewrite autolinks, based on Chris Ridings'// AutoBlink (http://www.searchguild.com/autoblink2.js)// Fill in the following if you wish to do this. // e.g.  var affiliate="news"// Leave as is to remove links in the normal wayvar affiliate="news";var illegalExternHost=new RegExp(/(sohu\.com)|(focus\.cn)|(focus\.com)|(sogou\.com)|(sina\.com)|(163\.com)|(netease\.com)/g);var linkcount;function checklinks() {  if (!(linkcount==document.links.length)) {    // Something changed the links!    // Iterate for an link of illegal extern host    for (i=0; i < document.links.length; i++) {      if (document.links[i].href.match(illegalExternHost)) {        // If we find an link match illegalExternHost extern host        if (affiliate=="") {           // No affiliate id defined so remove the links          var tr = document.links[i].parentTextEdit.createTextRange();          tr.moveToElementText(document.links[i]);          tr.execCommand("Unlink",false);          tr.execCommand("Unselect",false);          i--;        } else {          // An affiliate id defined so rewrite the links          var q="";          if (document.links[i].href.indexOf("query")>0) {            q=document.links[i].href.substring(document.links[i].href.indexOf("query")+6);          } else {            q=document.links[i].innerText;            if(q == "") {              q="房地产";            }          }          document.links[i].href="http://search.soufun.com/search?dir=" + affiliate + "&q=" + q + "";        }      }    }  }  linkcount = document.links.length;  setTimeout("checklinks()",1000);}if (document.getElementById && document.createElement) {  linkcount=document.links.length;  setTimeout("checklinks()",1000);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?