
今天在chrome上安装了Tampermonkey扩展,折腾一番后想起来给贴吧发帖框添加小尾巴。于是去尝试一番,现在成功了。
document.getElementsByClassName("poster_submit")[0].addEventListener('click', function(){
var ueditorAllP=document.getElementById('ueditor_replace').getElementsByTagName('p');
ueditorAllP[ueditorAllP.length-1].innerHTML+='<br><br>Servant Saber、召唤に従い参上した。';
}, true)
原理是给提交按钮添加一个事件,当点击它的时候,在输入框内最后一个P标签内(因为每次按enter换行都会产生一个新的P标签)的html代码中,追加小尾巴的html代码。注意不能使用innerText,因为这样的话,如果最后一个P标签内有图片,则图片会被文字替换,图片就没了。
PS:Tampermonkey可以引用外部js文件,格式是使用// @require,然后在后面加上js文件的url,如下:
// @require /f/keymaster.js
JavaScript 中有一些特殊的字符,如果想要在字符串中使用,需要加上一个反斜线。
代码 输出结果
---------------------
\' 单引号
\" 双引号
\& 与符号
\\ 反斜线
\n 换行
\r 回车
\t 制表符
\b 后退
\f 换页符
使用js设置css属性的时候,属性名经常和css的有区别。例如css中的'backgroung-image',使用js设置的时候需要写成'backgroundImage'。下面就是JS和CSS属性的对照表:
| CSS语法 (不区分大小写) | JavaScript语法 (区分大小写) |
| border | border |
| border-bottom | borderBottom |
| border-bottom-color | borderBottomColor |
| border-bottom-style | borderBottomStyle |
| border-bottom-width | borderBottomWidth |
| border-color | borderColor |
| border-left | borderLeft |
| border-left-color | borderLeftColor |
| border-left-style | borderLeftStyle |
| border-left-width | borderLeftWidth |
| border-right | borderRight |
| border-right-color | borderRightColor |
| border-right-style | borderRightStyle |
| border-right-width | borderRightWidth |
| border-style | borderStyle |
| border-top | borderTop |
| border-top-color | borderTopColor |
| border-top-style | borderTopStyle |
| border-top-width | borderTopWidth |
| border-width | borderWidth |
| clear | clear |
| float | floatStyle |
| margin | margin |
| margin-bottom | marginBottom |
| margin-left | marginLeft |
| margin-right | marginRight |
| margin-top | marginTop |
| padding | padding |
| padding-bottom | paddingBottom |
| padding-left | paddingLeft |
| padding-right | paddingRight |
| padding-top | paddingTop |
| background | background |
| background-attachment | backgroundAttachment |
| background-color | backgroundColor |
| background-image | backgroundImage |
| background-position | backgroundPosition |
| background-repeat | backgroundRepeat |
| color | color |
| display | display |
| list-style-type | listStyleType |
| list-style-image | listStyleImage |
| list-style-position | listStylePosition |
| list-style | listStyle |
| white-space | whiteSpace |
| font | font |
| font-family | fontFamily |
| font-size | fontSize |
| font-style | fontStyle |
| font-variant | fontVariant |
| font-weight | fontWeight |
| letter-spacing | letterSpacing |
| line-break | lineBreak |
| line-height | lineHeight |
| text-align | textAlign |
| text-decoration | textDecoration |
| text-indent | textIndent |
| text-justify | textJustify |
| text-transform | textTransform |
| vertical-align | verticalAlign |

Aniplex+ 1/7 saber 婚纱ver 原型制作:樱前线 协力:stronger。
全高约25cm,售价14040日元 2015年9月发售。
再现了TYPE-MOON10周年「TYPE-MOON Fes.」主题曲「From new world」CD上的图片。面纱可脱。
恩,我这氪不起金的也就看看图。真的很美啊。
Read More →
js的循环中可以使用continue跳过本次循环,使用break来跳出整个循环。
<script type="text/javascript">
for (var i = 0; i <= 10; i++) {
if (i==5) continue;
if (i==9) break;
document.write(i+' ');
};
</script>
上面的示例中,如果不干预循环操作,那么在页面上将会输出0-10这几个数字。但是干预之后,5不会出现,9和10也不会出现。因为循环到5的时候跳过了本次循环应该执行的操作,而到9的时候,又跳出了循环。
ps:if语句中如果条件后只有一句代码,可以省略花括号。
js中的return,常见的有两种用法。一种是使用'return false'、'return true'来阻止或允许某个动作,代码如下:
<a href="/" onclick="return false">Saber酱的抱枕</a>
此时点击a标签不会做跳转动作。这个方法也常被用在表单验证的提交过程中。
另一种使用方法是用return返回所需的值。
<script type="text/javascript">
function add (x,y) {
var sum=x+y;
return sum;
}
alert(add(1,3));
</script>
上面的示例里,add函数计算了两个参数相加之和,然后返回结果(sum的值)。这样,我们可以在调用这个函数的时候直接取得结果sum。如果不返回sum的值的话,想要弹出sum值,就只能在函数内操作了,因为函数外无法获取到sum的值(仅讨论此例)。
话说,以上两种方法有时候也可能需要结合起来使用。例如:
<a href="/" onclick="return skip(this.innerText)">Saber酱的抱枕</a>
<a href="http://www.baidu.com/" onclick="return skip(this.innerText)">百度</a>
<script type="text/javascript">
function skip (x) {
if (x=='Saber酱的抱枕') {return false;}else{return true}
}
</script>
当点击链接的时候,是执行'return false'还是执行'return true',是由函数内return返回的值所决定的。

最早我用的识图工具是谷歌识图。后来百度识图功能也上线了,我就开始时不时的使用百度识图。百度识图在一步步成长,识别率、结果数都在提高,很少有图片只有谷歌才能搜索到了(gif除外)。百度识图的功能也逐渐完善,虽然还没有图片时间范围、使用权限的选择,不过一般我们也很少关心这些。但时至今日,比起谷歌识图还是有不小的差距。因为现在谷歌被墙,所以我需要识图的时候基本都是先去百度,如果得到了满意的结果了,那就OK。如果不满意的话,再去谷歌。可惜大部分的情况,都是最后不得不去去谷歌上寻找。


从对上传图片出处的猜测上,可以看出差距还是非常明显。
Read More →

角色:Saber CN:妙妙 摄影:羽音 化妆:妙妙 后期:羽音
Saber型月10周年婚纱COS,转自鱼丸社
Read More →
自定义表单我们一般都是搜集信息之后在后台看的。如果要在前台展示,可以用以下方法调用:
{dede:loop table='dede_diyform1' sort='id' row='5' if=''}
[field:youname/]
{/dede:loop}
其中'dede_diyform1'为自定义表单的数据表,sort='id'是调用方式, row调用条数,if是调用条件。[field:youname/] 为需调用的字段的名称。
看到别的网站,有的选项卡都是用传参的方式切换的,避免了代码重写,于是我也试着做了一个。
<script type="text/javascript">
function setTab (tabTitId,tabPre,tabNum) {//参数是tab标题的id,本组tab的公共前缀,本组tab的个数。
//把字符串传参的时候,要加单引号。不是字符串也不是数字的时候,传递的是页面的元素。
for (var i = tabNum; i > 0; i--) {
document.getElementById(tabPre+i+"_tit").className="tab_Tit_off";//所有标题设置className
document.getElementById(tabPre+i+"_box").style.display="none";//隐藏所有box
};
document.getElementById(tabTitId).className="tab_Tit_on";//对当前标题设置className
document.getElementById(tabTitId.replace("tit","box")).style.display="block";//显示当前标题对应的box
}
setTab('tab1_1_tit','tab1_',4);//页面载入后对第一个tab执行一次
setTab('tab2_1_tit','tab2_',3);//页面载入后对第一个tab执行一次
</script>
选项卡标题和内容的id使用相同的前缀和有规律的序号,再把当前标题的id、选项卡的前缀、个数传递到函数里。class只和样式有关。