All Projects → 710850609 → autojs-webView

710850609 / autojs-webView

Licence: Apache-2.0 license
autojs的webView实现,支持初始化脚本注入、jsBridge两端互调

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to autojs-webView

animaris
Documentation and Mock for JSBridge base on ThinkJS & MongoDB & React & Antd.
Stars: ✭ 28 (-26.32%)
Mutual labels:  webview, jsbridge
QuickWebKit
A great & strong plugin based WebViewController. 一款基于插件的 WebView 视图控制器,您可以基于它设计您的浏览器插件,然后像积木一样来组装它们。
Stars: ✭ 29 (-23.68%)
Mutual labels:  webview, jsbridge
Vassonic
VasSonic is a lightweight and high-performance Hybrid framework developed by tencent VAS team, which is intended to speed up the first screen of websites working on Android and iOS platform.
Stars: ✭ 11,466 (+30073.68%)
Mutual labels:  webview, h5
vue-js-bridge
vue-js-bridge for Vue.js
Stars: ✭ 41 (+7.89%)
Mutual labels:  webview, jsbridge
flutter app o2o
flutter高校食堂o2o预定服务,商业级应用,持续升级,完全开源。
Stars: ✭ 45 (+18.42%)
Mutual labels:  webview
webview
Cross-platform header-only webview library for C++
Stars: ✭ 59 (+55.26%)
Mutual labels:  webview
webview
Build cross platform desktop apps with Elixir and web technologies.
Stars: ✭ 18 (-52.63%)
Mutual labels:  webview
RobustWebView
Android WebView H5 秒开方案总结
Stars: ✭ 38 (+0%)
Mutual labels:  webview
gowebview
tool to build android apps with WebView from your golang http server; moved to gitlab.com/microo8/gowebview
Stars: ✭ 35 (-7.89%)
Mutual labels:  webview
coc-webview
Using an external browser to support the webview in coc.nvim.
Stars: ✭ 21 (-44.74%)
Mutual labels:  webview
html-page-call-native
❤️ HTML5 call native app
Stars: ✭ 33 (-13.16%)
Mutual labels:  h5
Android-Web-Inspector
How to Inspecting Android WebView, Network logs, XHR logs (including url request and parameter) and Element/DOM inspecting
Stars: ✭ 54 (+42.11%)
Mutual labels:  webview
vscode-android-webview-debug
Debug your JavaScript code running in WebViews on any Android device from VS Code.
Stars: ✭ 18 (-52.63%)
Mutual labels:  webview
vue-automation
一款开箱即用的 Vue 项目模版,基于 Vue 2.x
Stars: ✭ 31 (-18.42%)
Mutual labels:  h5
flutter examples
Random flutter examples
Stars: ✭ 18 (-52.63%)
Mutual labels:  webview
X5Bridge
Three party libraries of Tencent x5webview and JS interaction
Stars: ✭ 17 (-55.26%)
Mutual labels:  webview
cordova-plugin-x5-tbs
Use Tencent Browser Service(TBS) instead of System WebView for Cordova App
Stars: ✭ 65 (+71.05%)
Mutual labels:  webview
ios-visionkit-webview
Element detection with Vision Framework and CoreML
Stars: ✭ 26 (-31.58%)
Mutual labels:  webview
flutter webview
A complete tutorial series on Flutter webview.
Stars: ✭ 39 (+2.63%)
Mutual labels:  webview
autolua
autolua支持安卓设备的找图找色,模拟点击,类似按键精灵,触动,autojs等软件的功能
Stars: ✭ 25 (-34.21%)
Mutual labels:  autojs

autojs-webView

autojs的webView实现,支持初始化脚本注入、jsBridge两端互调

一、功能介绍

  • 1 支持启动时注入自定义JavaScript脚本
  • 2 webview输出到autojs控制台
  • 3 支持渲染markdown文件
  • 4 支持jsBridge,H5端调用安卓端autojs方法
  • 5 支持inent url打开app页面
  • 6 支持vconsole
  • 7 支持debug模式
    • 需要在电脑Chrome内核浏览器上访问 chrome://inspect/#devices

二、项目结构说明

autojs-webView
├── LICENSE
├── README.md
├── expand -------------------------------------->  webView扩展功能目录
   ├── core ------------------------------------>  webView扩展核心目录
      ├── jsBridge.ts ------------------------->  
      ├── vConsole.ts ------------------------->  
      ├── vconsole.min.ts --------------------->  
      └── webViewExpand.js -------------------->  webView扩展API
   ├── handler --------------------------------->  
      ├── bridgeHandler.js -------------------->  autoJs提供给网页调用的方法
      └── webErrorHandler.js ------------------>  
   └── inject ---------------------------------->  页面注入JavaScript脚本文件
       └── demo.ts ----------------------------->  页面注入JavaScript脚本例子
├── main.js ------------------------------------->  
└── project.json -------------------------------->  

三、webViewExpand.js 方法说明

1 init(webViewWidget, jsFileList [, supportVConsole])

初始化扩展支持,页面加载完时注入脚本

- webViewWidget: webView组件
- jsFileList: 待注入的多个脚本文件路径,数组格式
- supportVConsole: 是否支持VConsole, 默认false

2 showMarkdown(markdownFilePath)

webView渲染MarkDown文件,基于 markedjs 实现

- markdownFilePath: markdown文件绝对路径

3 callJavaScript(webViewWidget, script [, callback])

autoJs在网页执行JavaScript代码

- webViewWidget: webView组件
- script: JavaScript脚本
- callback: 执行完回调函数

三、网页调用autoJs方法说明

1 定义autoJs方法的方法名、入参数据结构、返回值的数据结构

扩展对出入参的数据格式都规定为JSON,这里只需要定义JSON的数据结构即可

2 提供autoJs被调用的方法实现

bridgeHandler.js 中定义,并注册到 module.exports 中 例如

/**
 * 处理逻辑例子: toast 提示
 */
function toastAction(params) {
    toast(params.msg);
    return {msg: 'toast提示成功'};
}
module.exports = {
    handle: handle,
    // 注册被调用方法
    toast: toastAction
}

3 执行webViewExpand.init方法,开启webView扩展

webViewExpand.init(ui.webView, ["expand/inject/demo.ts"], true);

4 在网页中调用autoJs方法

"ui";
ui.layout(
    <vertical>
        <webview id="webView" layout_below="title" w="auto" h="auto" />
    </vertical>
);

// 在页面中调用autoJs方法
let js = "try{window.Android.invoke('toast', " + 
"{msg: '测试jsBridge1'}, " +
"(data) => {" +
"    console.log('接收到callback1:' + JSON.stringify(data));" +
"}" +
");}catch(e){console.trace(e)}";
let webViewExpand = require("expand/core/webViewExpand.js");

// 开启webView扩展
webViewExpand.init(ui.webView, [], true);
// 加载页面 */
ui.webView.loadUrl("https://cn.bing.com/");
// 等待页面加载完,或是在init方法中注入JavaScript脚本文件触发执行
setTimeout(() => {
    webViewExpand.callJavaScript(ui.webView, js);
}, 2000);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].