GithubHelp home page GithubHelp logo

webpack-autojs's Introduction

由于webpack5和4语法不一样, 本项目创建时用的是webpack4, 所以请安装指定版本的webpack 和 cli

请手动创建一个dist文件夹

20200920 添加一个字符串替换的正则, 比如

    InputLayout.prototype.render = function () {
        return <EditText padding='10 5' drawablePadding="5" gravity='center_vertical' />
    }

替换为

    InputLayout.prototype.render = function () {
        return `<EditText padding='10 5' drawablePadding="5" gravity='center_vertical' />`
    }

就是在xml两边加上反引号, 其他啥也没动.

QQ交流群 1019208967 webpack-autojs

bilibili 本仓库的使用教程 https://www.bilibili.com/video/BV1n7411q7rC/

该视频已作废, 因为是好几月前录制的, 请以README为准

-2. 无法加载文件, 因为在此系统上禁止运行脚本。 cmd管理员执行该代码 set-ExecutionPolicy RemoteSigned

-1. 需要全局安装webpack webpack-cli npm i -g webpack webpack-cli --registry=https://registry.npm.taobao.org

  1. 功能: 打包autojs, 不论单个文件, 还是多个文件, 不管有ui还是没ui, 都可以正常打包使用

  2. 下载仓库

    git clone https://github.com/snailuncle/webpack-autojs

  3. 命令行 npm install --registry=https://registry.npm.taobao.org

  4. 复制autojs项目的入口文件路径到entry.txt

  5. 命令行 webpack

  6. 打包后的文件在dist目录下

其他说明:

  1. 主要配置文件就一个scriptConfig.js
  2. scriptNamePrefix是文件前缀, 可以为打包后的文件加一个文件前缀, 比如打包index.js, 前缀为测试_, 那么打包后的文件名就是测试_index.js
  3. header.txt 该文件中的内容会被添加到打包后的文件的头部, 默认为空.
  4. uiMode true: ui模式, false 非ui模式
  5. base64webpack打包后是否base64编码
  6. base64RandomStrLengthbase64编码后, 在字符串前面添加的随机字符长度

其他说明2:

  1. 目前支持的ui有四种, ui.layout, ui.inflate, floaty.rawWindow, floaty.window
  2. 如果layoutContent是一个字符串变量, 而不是xml的话, 可以尝试, 将floaty.window定义为floatyWindow, 其他的ui.layout, ui.inflate, floaty.rawWindow, floaty.window也一样:
let floatyWindow = floaty.window;
var w = floatyWindow(layoutContent);
  1. loader文件是node_modules\webpack-autojs-loader\index.js

其他说明3:

  1. webview打包推荐: https://github.com/molysama/auto.pro
  2. require只能用相对路径, webpack才能正常打包
  3. require如果用绝对路径, 请使用global.require代替 如global.require("/sdcard/module1.js")

常见错误

  1. xml中使用了圆括号, 由于loader使用了正则匹配, 圆括号会影响正则, 请使用中文括号
  2. require使用了绝对路径, 请避免使用绝对路径,
  3. 如果require用了绝对路径, webpack是找不到的, webpack是电脑使用的工具, 不是手机使用的工具,他找不到/sdcard, 请使用global.require代替
  4. 若果xml中有list, 请不要省略this, 因为loader正则中会区分xml中的{{}}中是不是带了this, 来进行不同的处理
  5. 变量未定义, 请注意所有变量都要先定义, 再使用; 注意js的变量提升, 导致打包后的运行错误.
  6. 如果不定义就使用, 请在变量前面加上 global. 这7个字符, 可以避免一些变量提升导致的错误
  7. 如果导入jar或者dex, 使用java对象, 建议直接使用对象的完整名字, 比如var url = new java.net.URL(myUrl);, 而不是var url = new URL(myUrl);

js转dex, 可以参考此仓库

batchJs2Dex

so中执行autojs脚本, 可以参考此仓库

autojsNativeJs

webpack-autojs's People

Contributors

snailuncle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

webpack-autojs's Issues

xml中使用了this, webpack不认识autojs里面的xml中的this, 请用其他方式实现

1、xml中使用了this, webpack不认识autojs里面的xml中的this, 请用其他方式实现
请问如何替换this?
<list id="apps" layout_weight="1"> <text id="name" text="{{this.Name}}" marginTop="16" maxLines="1" ellipsize="end"/> <text id="path" text="{{apps[这里的索引值应该用什么?].Name}}" marginTop="8" maxLines="1" ellipsize="end"/> </list>
使用apps[0].Name固定索引值是可以的,不知变量该用什么?或者有什么其它方法

非常感谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.