快速填写评论框信息

拖动上面到书签栏,点击comment测试,

javascript代码:

javascript:
var n='Pang';
e='[email protected]';
u='http://www.hhtjim.com';
wp_ar = a('author');
wp_em = a('email') || a('mail');
wp_url = a('url');
ds_ar = a('ds-dialog-name');
ds_em = a('ds-dialog-email');
ds_url = a('ds-dialog-url');
uyan_ar = a('uyan_uname') || a('uyan_l_uname');
uyan_em = a('uyan_email') || a('uyan_l_email');
uyan_url = a('uyan_l_ulink');
dlu_ar = a('idenglu_name');
dlu_em = a('idenglu_email');
dlu_url = a('idenglu_homepage');
em_ar = b('comname');
em_em = b('commail');
em_url = b('comurl');
if(wp_ar){wp_ar.value = n;
wp_em.value = e;
wp_url.value = u;
}if(ds_ar){ds_ar.value = n;
ds_em.value = e;
ds_url.value = u;
}if(uyan_ar){uyan_ar.value = n;
uyan_em.value = e;
uyan_url.value = u;
}if(dlu_ar){dlu_ar.value = n;
dlu_em.value = e;
dlu_url.value = u;
}if(em_ar){em_ar.value = n;
em_em .value = e;
em_url.value = u;
}
function a(i) {
var i = document.getElementById(i);
return i;
}function b(i) {
var i = document.all(i);
return i;
}
void(0);

说明:

第2、3和4行分别自己的昵称,邮箱,网址。

由于代码太长,所以方便到emblog、WordPress、typecho、多说、灯鹭、有言都可以一键填写信息。

不知道代码源自哪里了,到处都飞。只是我这更加强了些。

由于ID或name的不同或许不会达到满意的效果,仅供测试。
150206添加:

javascript: var n = 'Pang',//自己的昵称
e = '[email protected]',//邮箱
u = 'http://www.hhtjim.com';//网站
var a =
{
//任意命名:{ar:'昵称处input的name或者id值',em:'邮箱处的name或者id值',url:'主页处的name或者id值'},
    wp:{ar:'author',em:['email','mail'],url:'url'},
    ds:{ar:'ds-dialog-name',em:'ds-dialog-email',url:'ds-dialog-url'},
    uyan:{ar:['uyan_uname','uyan_l_uname'],em:['uyan_email','uyan_l_email'],url:'uyan_l_ulink'},
    dlu:{ar:'idenglu_name',em:'idenglu_email',url:'idenglu_homepage'},
    em:{ar:'comname',em:'commail',url:'comurl'},
    diy:{ar:'comment_author',em:'comment_email',url:'comment_url'},
    zblog:{ar:'inpName',em:'inpEmail',url:'inpHomePage'},
    phpernote: {ar: 'c_name',em: 'c_email',url: 'c_url'}
};
c(a);
function c(arr) {
    function a(i) {
        var i = document.getElementById(i);
        return i;
    }
    function b(i) {
        var i = document.all(i);
        var is_one_DOM = ( typeof HTMLElement === 'object' ) ?
                        function(obj){
                            return obj instanceof HTMLElement;
                        } :
                        function(obj){
                            return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';
                        };
        if(!is_one_DOM(i))//如果是多个dom对象
        {
            for (var s in i) {
                if (i[s].tagName == 'INPUT'){return i[s];break;}else{continue;}
            }
        }
        else
        {
            return i;
        }
    }
    for (var s in arr) {
        for (var s_ in arr[s]) {
            if (typeof(arr[s][s_]) == "object") {
                for (var s__ in arr[s][s_]) {
                    eval('var ' + s + '_' + s_ + '= b("' + arr[s][s_][s__] + '");if(' + s + '_' + s_ + '){switch ("' + s_ + '") {case "ar":{' + s + '_' + s_ + '.value=n;break;}case "em":{' + s + '_' + s_ + '.value=e;break;}case "url":{' + s + '_' + s_ + '.value=u;break;}}}');
                }
            } else {
                eval('var ' + s + '_' + s_ + '= b("' + arr[s][s_] + '");if(' + s + '_' + s_ + '){switch ("' + s_ + '") {case "ar":{' + s + '_' + s_ + '.value=n;break;}case "em":{' + s + '_' + s_ + '.value=e;break;}case "url":{' + s + '_' + s_ + '.value=u;break;}}}');
            }
        }
    }
}
void(0);

GitHub地址:https://github.com/Hootrix/fast-type-comment-info-javascript/blob/master/type-comment-info.js
参考:
快速在WordPress填写名称、EMAIL等信息
document.all用法
js 判断js函数、变量是否存在

03-04 15:07