npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fis-prepackager-widget-admix

v0.0.2

Published

组件样式混淆插件

Downloads

3

Readme

FIS反广告拦截组件样式混淆插件

通过分析组件widget代码,自动混淆指定组件内所有相关的样式选择器以实现有效的广告反拦截,包括类html、css和js文件的自动混淆,支持设置过滤和自定义的混淆处理。

注意

  • 不适用于列表型内容中插入的广告(如贴吧楼层中的广告,混淆后还是容易通过选择器被识别出来)
  • 混淆的组件css选择器和样式不能被其他组件所调用(因为只混淆当前组件内的代码)
  • 由于混淆范围大,请务必在指定组件内谨慎使用!如果JS中混淆不充分请设置自定义混淆处理
  • 如果在fis中使用,请注意需要混淆的文件是否设置了isHtmlLike、isCssLike、isJsLike属性

使用方法

安装此插件并进行配置

执行npm install -g fis-prepackager-widget-admix 安装插件

FIS2:

//vi fis-conf.js

fis.config.merge({
    modules: {
        widget-admix: 'ad-mix'
    },
    settings: {
        prepackager: {
            'widget-inline':  {
                ignore: '.clearfix,',//不进行混淆的选择器,多个逗号隔开
                list: [ //需要混淆的组件,相对模块根目录路径
                    'widget/slogan'
                ],
                //自定义混淆处理
                mix : {}
            }
        }
    }
});

注意:如果您已使用其他prepackager插件,请在已有地方添加widget-admix,逗号隔开

FIS3:

//vi fis-conf.js

fis.match("::package",{
    prepackager : fis.plugin('widget-admix',{
          ignore: '.clearfix',//不进行混淆的选择器,多个逗号隔开
          list: [ //需要混淆的组件,相对模块根目录路径
              'widget/slogan'
          ],
          //自定义混淆处理
          mix : {}
    })
})

配置说明

  • ignore : 不进行混淆的选择器(如果不是本组件样式默认不会混淆),多个逗号隔开,如.clearfix,#wrap
  • list : 需要混淆的组件,数组,相对模块根目录路径
  • mix : 自定义混淆处理

例如JS中如果要设置自定义混淆逻辑:

 mix : {
    //数组形式,代表多个混淆逻辑,依次执行
    'js' : [function(code){
        var map = this.map;//混淆前后索引表,map.id,map.class
        //do something with js code
        return code;
    }]
 }

使用效果

自动获取组件内所有css文件和模板内嵌css选择器,生成hash值进行混淆处理

每次编译都重新生成一遍

开发时:

/*css文件*/
#slogan {
    position: relative;
}
<!-- isHtmlLike 的文件 -->
//默认支持html style和smarty {%style%}、<%style%>标签
<style>
    .style_test a{
        color:black;
    }
</style>

编译后:

/*css文件*/
#llM67m {
    position: relative;
}
<!-- isHtmlLike 的文件 -->
<style>
    .aiMy8D a{
        color:black;
    }
</style>

自动替换模板文件中的样式选择器(id|class="xxx")

开发时:

<section class="section ignore_class" id='slogan'>
</section>

编译后:

<section class="zhDXWk ignore_class"  id='zhDXWk'>
</section>

自动替换JS代码中的选择器或class名称

  • 替换原生JS中getElementsByClassName、getElementById、setAttribute中的 class/id
  • 替换 css3选择器字符串 .class #id
  • 替换 jquery (add|remove|has|toggle)Class对应的一个或多个class
  • 支持自定义混淆逻辑

开发时:

    var a = document.getElementsByClassName("style_test");
    var b = $(".style_test");
    b.addClass("style_test style_test2");

编译后:

    var a = document.getElementsByClassName("cakPrn");
    var b = $(".cakPrn");
    b.addClass("cakPrn cakPrn2");

测试

cd test/moduleA
fis release -d output