赞
踩
tampermonkey(油猴) GM_addStyle
tampermonkey脚本中 GM_addStyle的教程很少,连自身的文档都没有案例,网上查了很久,自己记录一下。
var ads=["iframe",".layout-header",".layout-footer",".xuexi",".WNiH6aSBS23IzewzHGi4v",'audio',".redflag-2","div[style='background-repeat: no-repeat;']",".my-points-section .earn-header",'img'];
for(var i=0 ;i<ads.length;i++){
GM_addStyle(ads[i]+'{display:none}')
}
GM_addStyle(".my-points-card {height:150px !important}");
GM_addStyle("* {margin-top:0px !important; margin-left:0px !important}");
1、GM_addStyle可以自动遍历这里.my-points-card
是一个元素数组及多个div公用一个class GM_addStyle将所有元素都添加了指定属性。
2、* 指所有元素,使用要小心。
3、括号内可以指定多个元素,中间用逗号隔开。
GM_addStyle(".my-points-card,.layout-header{height:150px !important}")
4、只能添加style属性中的值;多属性用分号隔开。
GM_addStyle("* {margin-top:0px !important; margin-left:0px !important}");
5、!important表示添加的属性权限,每一个属性后面都要跟一个。
6、GM_addStyle 要在文件中声明。
// @grant GM_addStyle
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。