分类
信息技术

博客评论个人信息自动填写代码

博客具有互动性,体现之一就是博客文章的评论内容。来而不往非礼也,对评论者进行回访自然不是一个坏事。然而对别人的博客进行评论时,初次需要填写昵称,邮箱,网址,自然有些麻烦。有没有更简单的方法呢?有!

对于WordPress, Z-Blog, Typecho这三款博客程序,可以将以下三段JS代码各自保存成相应的书签——在浏览器的收藏栏(或叫书签栏)中新建一个书签,内容为各段代码,名称任意。

以后需要填写评论信息的时候就可以点击相应书签,就可以自动填写信息了,再也不会出现写10秒的内容,花30秒去填写评论者个人信息——估计卢松松同学可能就是靠这招来闯遍博客界的评论。

Windows, Ubuntu下的Firefox, Chrome, IE9浏览器均通过验证。请将代码中的评论者名称,邮箱和网址作相应更改,注意引号应该为英文状态下的半角形式。

WordPress的代码如下(对Emblog无效):

javascript:(function(){document.getElementById('author').value='你的昵称'; document.getElementById('email').value='你的邮箱'; document.getElementById('url').value='你的网址';})()

Z-blog的代码如下:

javascript:(function(){document.getElementById('inpName').value='你的昵称'; document.getElementById('inpEmail').value='你的邮箱'; document.getElementById('inpHomePage').value='你的网址';})()

Typecho的代码如下:

javascript:(function(){document.getElementById('author').value='你的昵称'; document.getElementById('mail').value='你的邮箱'; document.getElementById('url').value='你的网址';})()

网上已经有人提到过以上方法,但由于引号状态不为英文状态(可能是由于采用中文雅黑字体导致英文标点发生问题),导致出错,足见天下大事必作于细,写博文亦如此。至于Em-Blog程序,理论上应该也可以实现,但我没有成功过,希望知情人留言贡献,土木坛子替EmBlog博主们先谢谢了。

Update: 受IsayMe博主的指点,上面的三段代码可以合为一段变成一个书签(请将昵称、邮箱和网址作相应更改),代码自动选择博客程序,就不必人肉去查看博客程序类型再决定书签代码了。感谢IsayMe博主,博友力量就是大!

三合一代码如下:

javascript: void function() { var formArray = ["commentform", "comment_form","frmSumbit"], nameArray = ["author", "author", "inpName"], emailArray = ["email", "mail", "inpEmail"], urlArray = ["url", "url", "inpHomePage"]; for (i = 0; i < formArray.length; i++) { var form = document.getElementById(formArray[i]); if (form != null) { var name = document.getElementById(nameArray[i]), email = document.getElementById(emailArray[i]), url = document.getElementById(urlArray[i]); name != null && (name.value = "土木坛子"), email != null && (email.value = "[email protected]"), url != null && (url.value = "https://tumutanzi.com"); break } } return ! 1 } ()

更新:升级版本,一码解决WordPress, Z-Blog, Typecho, Emblog四种博客程序的评论填充问题。感谢 https://leonax.net/ 博主的功劳。请自行修改相应信息:名称、邮箱、网址。


javascript:var myName="你的名称",myEmail="[email protected]",myUrl="http://yourdomain.com";function fillForm(r,e,m,t){if(null!=r){var n=document.querySelector(r);if(null==n)return!1}var u=document.querySelector(e);if(null==u)return!1;u.setAttribute("value",myName);var l=document.querySelector(m);if(null!=l){l.setAttribute("value",myUrl);}var o=document.querySelector(t);return null==o?!1:(o.setAttribute("value",myEmail),!0)};[function(){return fillForm("#commentform","#author","#url","#email")},function(){return fillForm("#comment_form","#author","#url","#mail")},function(){return fillForm("#frmSumbit","#inpName","#inpHomePage","#inpEmail")},function(){return fillForm("#commentform",'input[name="comname"]','input[name="comurl"]','input[name="commail"]')}].some(function(r){return r()});

磨刀不误砍柴工。

“博客评论个人信息自动填写代码”上的75条回复

重置了chrome的所有设置,把同步存储的也删了,结果导致找这段自动填表的代码找了好久。还好,找到了。

才看到这篇文章,已转走……如果早发现就不自己瞎折腾了:http://www.ilxtx.com/automatically-fill-in-personal-information.html

在浏览器的收藏栏(或叫书签栏)中新建一个书签,内容为本语言各段代码,名称任意。
自动提交是什么?

我意思是 已自动填充了 名称+地址+网址,如何能自动填入想要回复的“留言內容”,或者再厉害点,无驗证碼的直接自动提交?

其实也简单,我帮你写了一个示例,你可以改成你的内容(这相当于为机器人留言打开了方便之门……):

javascript:(function(){document.getElementById('comment').value='文章不错,感谢分享。'; document.getElementById('author').value='土木坛子'; document.getElementById('email').value='[email protected]'; document.getElementById('url').value='https://tumutanzi.com';})()

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注