fastchar-dom-plugin
Version:
Chrome插件,用于操作HTML的DOM
143 lines (142 loc) • 4.06 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FastConstant = void 0;
var FastConstant;
(function (FastConstant) {
/**
* 工具类
* @author 沈建(Janesen)
*/
class FastHelper {
/**
* 构建唯一标识符
* @author Janesen
* @private
*/
static buildUDID() {
let d = new Date().getTime();
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
let r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
}
}
FastConstant.FastHelper = FastHelper;
/**
* FastDOM对象
* @author 沈建(Janesen)
*/
class FastDOM {
/**
* 是否进入调试模式
*/
static debug = false;
/**
* 插件当前版本号
*/
static PLUGIN_VERSION = "2.1.5";
/**
* 插件下载地址
*/
static PLUGIN_DOWNLOAD_URL = "https://www.fastchar.com/fastchar-dom-plugin.zip";
/**
* 是否采用长链接方式
*/
static USE_RUNTIME_CONNECT = true;
/**
* 执行请求的标签名称
*/
static DOM_TAG_NAME = "fastchar-dom-plugin";
/**
* 之前请求携带的数据
*/
static DOM_DATA_NAME = "fastchar-dom-data";
/**
* 数据是否已接收
*/
static DOM_DATA_RECEIVE = "fastchar-dom-data-receive";
/**
* 执行操作统计
*/
static DOM_DATA_INVOKE_COUNT = "fastchar-dom-data-invoke-count";
/**
* 预计回调总数
*/
static DOM_DATA_CALLBACK_TOTAL = "fastchar-dom-data-callback-total";
/**
* 回调不限次数
*/
static DOM_DATA_CALLBACK_ALWAYS = "fastchar-dom-data-callback-always";
/**
* 回调数据的标签名
*/
static DOM_DATA_CALLBACK_TAG_NAME = "fastchar-dom-callback";
/**
* 错误消息
*/
static DOME_DATA_ERROR = "fastchar-dom-error";
/**
* 是否已加载插件
*/
static DOM_PLUGIN = "fastchar-dom-plugin";
/**
* 加载插件版本
*/
static DOM_PLUGIN_VERSION = "fastchar-dom-plugin-version";
/**
* 执行方法超时时间,单位:毫秒
*/
static DOM_INVOKE_TIMEOUT = 15000;
/**
* 内容页面保活心跳间隔,单位:毫秒
*/
static DOM_CONTENT_IDLE_DURATION = 100;
/**
* 内容页面失效时间,单位:毫秒
*/
static DOM_CONTENT_TIMEOUT = 3000;
/**
* 背景页心跳器,单位:毫秒
*/
static DOM_BACKGROUND_IDLE_DURATION = 100;
}
FastConstant.FastDOM = FastDOM;
/**
* 执行DOM相关的事件
* @author 沈建(Janesen)
*/
class FastDOMEvents {
/**
* 事件注册链接
*/
static ON_REGISTER_CONNECT = "OnRegisterConnect";
/**
* 事件:执行方法
*/
static ON_INVOKE_METHOD = "OnInvokeMethod";
/**
* 事件:回调方法
*/
static ON_RETURN_METHOD = "OnReturnMethod";
/**
* 事件:检查消息
*/
static ON_WATCH_MESSAGE = "OnWatchMessage";
/**
* 事件:心跳
*/
static ON_IDLE = "OnIdle";
}
FastConstant.FastDOMEvents = FastDOMEvents;
/**
* window.postMessage事件类型
*/
class WindowMessageEvents {
/**
* 网络请求响应事件
*/
static HTTP_RESPONSE_LISTENER = "HTTP_RESPONSE_LISTENER";
}
FastConstant.WindowMessageEvents = WindowMessageEvents;
})(FastConstant = exports.FastConstant || (exports.FastConstant = {}));