前言

之前在调试邮件通知样式的时候,因为要在博主邮箱和测试邮箱反复切换,每次重新手动填写都很乏味,所以一直想有一个一键填充个人信息的功能。后来在 twikoo 的 issue 看到了龙笑天的文章,不过在 twikoo 等评论区填写了识别不到,今天群里 Android 大佬解决了,又新学了一个 dispatchEvent() 方法,嘿嘿 (*^▽^*)

书签代码源码

可以将代码中的昵称,邮箱,网址修改成你的信息,然后使用JS压缩工具压缩后使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
javascript: void (function () {
var lauthor = ["#author","input[name='comname']","#inpName","input[name='author']","#ds-dialog-name","#name","input[name='nick']","#comment_author"],
lmail =["#mail","#email","input[name='commail']","#inpEmail","input[name='email']","#ds-dialog-email","input[name='mail']","#comment_email"],
lurl =["#url","input[name='comurl']","#inpHomePage","#ds-dialog-url","input[name='url']","input[name='website']","#website","input[name='link']","#comment_url"];
for (i = 0; i < lauthor.length; i++) {
var author = document.querySelector(lauthor[i]);
if (author != null) {
author.value = '昵称';
author.dispatchEvent(new Event('input'));
author.dispatchEvent(new Event('change'));
break;
}
}
for (j = 0; j < lmail.length; j++) {
var mail = document.querySelector(lmail[j]);
if (mail != null) {
mail.value = '邮箱';
mail.dispatchEvent(new Event('input'));
mail.dispatchEvent(new Event('change'));
break;
}
}
for (k = 0; k < lurl.length; k++) {
var url = document.querySelector(lurl[k]);
if (url != null) {
url.value = '网址';
url.dispatchEvent(new Event('input'));
url.dispatchEvent(new Event('change'));
break;
}
}
return !1;
})();

自动生成书签代码

填写自己的个人信息,其中昵称和邮箱为必填项,点击按钮,一键自动生成代码并复制到粘贴板

昵称:
网址:

使用方法

  1. 新建一个书签,或直接收藏本页
  2. 编辑书签,将网址改为上面生成的代码
  3. 评论需要填写个人信息时点击一下该书签即可

油猴脚本自动填充版

原文地址