tampermonkey(油猴) GM_addStyle

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
  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值