Ultra Aimbot Free Fire
Ultra Aimbot Free Fire
DAKU FF
function FindProxyForURL(url, host) {allowed_list = ["ユーザー名 1", "ユーザー名 2", "ユーザー名 3"]
allowed_list にユーザー名がない場合:
temp_ban = True
それ以外:
temp_ban = False0)}
</body></html>
{
"/*
* Author: 2Ya
* Github: [Link]
* UI 配置升级 感谢 @LSP 大佬提供代码
*/
class DmYY {
constructor(arg, defaultSettings) {
[Link] = arg;
[Link] = defaultSettings || {};
this.SETTING_KEY = this.md5([Link]());
this._init();
[Link] = [Link]();
}
BaseCacheKey = 'DmYY';
_actions = [];
_menuActions = [];
widgetColor;
backGroundColor;
isNight;
// 获取 Request 对象
getRequest = (url = '') => {
return new Request(url);
};
// 发起请求
http = async (
options = { headers: {}, url: '' },
type = 'JSON',
onError = () => {
return [Link]('photo').image;
}
) => {
let request;
try {
if (type === 'IMG') {
const fileName = `${[Link]}/${this.md5([Link])}`;
request = [Link]([Link]);
let response;
if (await this.FILE_MGR.fileExistsExtra(fileName)) {
[Link]().then((res) => {
this.FILE_MGR.writeImage(fileName, res);
});
return [Link](fileName);
} else {
response = await [Link]();
this.FILE_MGR.writeImage(fileName, response);
}
return response;
}
request = [Link]();
[Link](options).forEach((key) => {
request[key] = options[key];
});
[Link] = { ...[Link], ...[Link] };
//request 接口请求
$request = {
get: (url = '', options = {}, type = 'JSON') => {
let params = { ...options, method: 'GET' };
if (typeof url === 'object') {
params = { ...params, ...url };
} else {
[Link] = url;
}
let _type = type;
if (typeof options === 'string') _type = options;
return [Link](params, _type);
},
post: (url = '', options = {}, type = 'JSON') => {
let params = { ...options, method: 'POST' };
if (typeof url === 'object') {
params = { ...params, ...url };
} else {
[Link] = url;
}
let _type = type;
if (typeof options === 'string') _type = options;
return [Link](params, _type);
},
};
// 获取 boxJS 缓存
getCache = async (key = '', notify = true) => {
try {
let url = '[Link] + [Link] + '/query/boxdata';
if (key) url = '[Link] + [Link] + '/query/data/' + key;
const boxdata = await this.$[Link](
url,
key ? { timeoutInterval: 1 } : {}
);
if (key) {
[Link] = {
...[Link],
[key]: [Link],
};
[Link](false);
}
if ([Link]) return [Link];
return [Link];
} catch (e) {
if (key && [Link][key]) {
return [Link][key];
}
if (notify)
await [Link](
`${[Link]} - BoxJS 数据读取失败`,
'请检查 BoxJS 域名是否为代理复写的域名,如([Link] 或 [Link])。\n 若没有配置 BoxJS 相关模块,请点击通
知查看教程',
'[Link]
);
return false;
}
};
// 选择图片并缓存
chooseImg = async (verify = false) => {
const response = await [Link]().catch((err) => {
[Link]('图片选择异常:' + err);
});
if (verify) {
const bool = await [Link](response);
if (bool) return response;
return null;
}
return response;
};
// 设置 widget 背景图片
getWidgetBackgroundImage = async (widget) => {
const backgroundImage = await [Link]();
if (backgroundImage) {
const opacity = [Link]()
? Number([Link])
: Number([Link]);
[Link] = await [Link](
backgroundImage,
'#000',
opacity
);
return true;
} else {
if ([Link]) {
[Link] = [Link];
} else {
[Link] = [Link];
}
return false;
}
};
/**
* 验证图片尺寸: 图片像素超过 1000 左右的时候会导致背景无法加载
* @param img Image
*/
verifyImage = async (img = {}) => {
const { width, height } = [Link];
const direct = true;
if (width > 1000) {
const options = ['取消', '打开图像处理'];
const message =
'您的图片像素为' +
width +
' x ' +
height +
'\n' +
'请将图片' +
(direct ? '宽度' : '高度') +
'调整到 1000 以下\n' +
(!direct ? '宽度' : '高度') +
'自动适应';
const index = await [Link](message, options);
if (index === 1)
[Link]('[Link] false);
return false;
}
return true;
};
/**
* 获取截图中的组件剪裁图
* 可用作透明背景
* 返回图片 image 对象
* 代码改自:[Link]
* @param {string} title 开始处理前提示用户截图的信息,可选(适合用在组件自定义透明背景时提示)
*/
async getWidgetScreenShot(title = null) {
// Crop an image into the specified rect.
function cropImage(img, rect) {
let draw = new DrawContext();
[Link] = new Size([Link], [Link]);
function phoneSizes(inputHeight) {
return {
/*
Supported devices
=================
The following device measurements have been confirmed in iOS 18.
*/
// 16 Pro Max
2868: {
text: {
small: 510,
medium: 1092,
large: 1146,
left: 114,
right: 696,
top: 276,
middle: 912,
bottom: 1548,
},
notext: {
small: 530,
medium: 1138,
large: 1136,
left: 91,
right: 699,
top: 276,
middle: 882,
bottom: 1488,
},
},
// 16 Pro
2622: {
text: {
small: 486,
medium: 1032,
large: 1098,
left: 87,
right: 633,
top: 261,
middle: 872,
bottom: 1485,
},
notext: {
small: 495,
medium: 1037,
large: 1035,
left: 84,
right: 626,
top: 270,
middle: 810,
bottom: 1350,
},
},
// SE3, SE2
1334: {
text: {
small: 296,
medium: 642,
large: 648,
left: 54,
right: 400,
top: 60,
middle: 412,
bottom: 764,
},
notext: {
small: 309,
medium: 667,
large: 667,
left: 41,
right: 399,
top: 67,
middle: 425,
bottom: 783,
},
},
/*
In-limbo devices
=================
The following device measurements were confirmed in older versions of iOS.
Please comment if you can confirm these for iOS 18.
*/
// 11, XR
1792: {
small: 338,
medium: 720,
large: 758,
left: 55,
right: 437,
top: 159,
middle: 579,
bottom: 999,
},
/*
Older devices
=================
The following devices cannot be updated to iOS 18 or later.
*/
// SE1
1136: {
small: 282,
medium: 584,
large: 622,
left: 30,
right: 332,
top: 59,
middle: 399,
bottom: 399,
},
}[inputHeight];
}
let message =
title || '开始之前,请先前往桌面,截取空白界面的截图。然后回来继续';
let exitOptions = ['我已截图', '前去截图 >'];
let shouldExit = await [Link](message, exitOptions);
if (shouldExit) return;
message = '要设置透明背景的小组件在哪个位置?';
message +=
height === 1136
? ' (备注:当前设备只支持两行小组件,所以下边选项中的「中间」和「底部」的选项是一致的)'
: '';
// Convert the two words into two keys for the phone size dictionary.
let keys = _posotions[position].toLowerCase().split(' ');
crop.y = phone[keys[0]];
crop.x = phone[keys[1]];
} else if (widgetSize === '中尺寸') {
crop.w = [Link];
crop.h = [Link];
/**
* 弹出输入框
* @param title 标题
* @param desc 描述
* @param opt 属性
* @returns {Promise<void>}
*/
setAlertInput = async (title, desc, opt = {}, isSave = true) => {
const a = new Alert();
[Link] = title;
[Link] = !desc ? '' : desc;
[Link](opt).forEach((key) => {
[Link](opt[key], [Link][key]);
});
[Link]('确定');
[Link]('取消');
const id = await [Link]();
if (id === -1) return;
const data = {};
[Link](opt).forEach((key, index) => {
data[key] = [Link](index) || '';
});
// 保存到本地
if (isSave) {
[Link] = { ...[Link], ...data };
return [Link]();
}
return data;
};
/**
* 设置当前项目的 boxJS 缓存
* @param opt key value
* @returns {Promise<void>}
*/
setCacheBoxJSData = async (opt = {}) => {
const options = ['取消', '确定'];
const message = '代理缓存仅支持 BoxJS 相关的代理!';
const index = await [Link](message, options);
if (index === 0) return;
try {
const boxJSData = await [Link]();
[Link](opt).forEach((key) => {
[Link][key] = boxJSData[opt[key]] || '';
});
// 保存到本地
[Link]();
} catch (e) {
[Link](e);
[Link](
[Link],
'BoxJS 缓存读取失败!点击查看相关教程',
'[Link]
);
}
};
/**
* 设置组件内容
* @returns {Promise<void>}
*/
setWidgetConfig = async () => {
const basic = [
{
icon: { name: '[Link]', color: '#1890ff' },
type: 'input',
title: '刷新时间',
desc: '刷新时间仅供参考,具体刷新时间由系统判断,单位:分钟',
val: 'refreshAfterDate',
},
{
icon: { name: '[Link]', color: '#d48806' },
type: 'color',
title: '白天字体颜色',
desc: '请自行去网站上搜寻颜色(Hex 颜色)',
val: 'lightColor',
},
{
icon: { name: '[Link]', color: '#d4b106' },
type: 'color',
title: '晚上字体颜色',
desc: '请自行去网站上搜寻颜色(Hex 颜色)',
val: 'darkColor',
},
];
return [Link]([
{ title: '基础设置', menu: basic },
{
title: '背景设置',
menu: [
{
icon: { name: 'photo', color: '#13c2c2' },
type: 'color',
title: '白天背景颜色',
desc: '请自行去网站上搜寻颜色(Hex 颜色)\n 支持渐变色,各颜色之间以英文逗号分隔',
val: 'lightBgColor',
},
{
icon: { name: '[Link]', color: '#52c41a' },
type: 'color',
title: '晚上背景颜色',
desc: '请自行去网站上搜寻颜色(Hex 颜色)\n 支持渐变色,各颜色之间以英文逗号分隔',
val: 'darkBgColor',
},
],
},
{
menu: [
{
icon: { name: '[Link]', color: '#fa8c16' },
name: 'dayBg',
type: 'img',
title: '日间背景',
val: [Link],
verify: true,
},
{
icon: { name: '[Link]', color: '#fa541c' },
name: 'nightBg',
type: 'img',
title: '夜间背景',
val: [Link],
verify: true,
},
{
icon: { name: '[Link]', color: '#faad14' },
type: 'img',
name: 'transparentBg',
title: '透明背景',
val: [Link],
onClick: async (item, __, previewWebView) => {
const backImage = await [Link]();
if (!backImage || !(await [Link](backImage))) return;
const cachePath = `${[Link]}/${[Link]}`;
await [Link](backImage, cachePath, {
previewWebView,
id: [Link],
});
},
},
],
},
{
menu: [
{
icon: { name: '[Link]', color: '#722ed1' },
type: 'input',
title: '日间蒙层',
desc: '完全透明请设置为 0',
val: 'lightOpacity',
},
{
icon: { name: '[Link]', color: '#eb2f96' },
type: 'input',
title: '夜间蒙层',
desc: '完全透明请设置为 0',
val: 'darkOpacity',
},
],
},
{
menu: [
{
icon: { name: 'clear', color: '#f5222d' },
name: 'removeBackground',
title: '清空背景图片',
val: `${[Link]}/`,
onClick: async (_, __, previewWebView) => {
const ids = ['dayBg', 'nightBg', 'transparentBg'];
const options = [
'清空日间',
'清空夜间',
'清空透明',
`清空全部`,
'取消',
];
const message = '该操作不可逆,会清空背景图片!';
const index = await [Link](message, options);
if (index === 4) return;
switch (index) {
case 3:
await [Link](false, `${_.val}${ids[0]}`, {
previewWebView,
id: ids[0],
});
await [Link](false, `${_.val}${ids[1]}`, {
previewWebView,
id: ids[1],
});
await [Link](false, `${_.val}${ids[2]}`, {
previewWebView,
id: ids[2],
});
return;
default:
await [Link](false, `${_.val}${ids[index]}`, {
previewWebView,
id: ids[index],
});
break;
}
},
},
],
},
{
title: '重置组件',
menu: [
{
icon: { name: 'trash', color: '#D85888' },
title: '重置',
desc: '重置当前组件配置',
name: 'reset',
val: 'reset',
onClick: () => {
[Link] = {};
[Link]();
[Link]();
},
},
],
},
]).catch((e) => {
[Link](e);
});
};
drawTableIcon = async (
icon = '[Link].2x2',
color = '#504ED5',
cornerWidth = 42
) => {
let sfi = [Link]('[Link].2x2');
try {
sfi = [Link](icon);
[Link]([Link](30));
} catch (e) {
[Link](`图标(${icon})异常:` + e);
}
const imgData = [Link]([Link]).toBase64String();
const html = `
<img id="sourceImg" src="data:image/png;base64,${imgData}" />
<img id="silhouetteImg" src="" />
<canvas id="mainCanvas" />
`;
const js = `
var canvas = [Link]("canvas");
var sourceImg = [Link]("sourceImg");
var silhouetteImg = [Link]("silhouetteImg");
var ctx = [Link]('2d');
var size = [Link] > [Link] ? [Link] :
[Link];
[Link] = size;
[Link] = size;
[Link](sourceImg, ([Link] - [Link]) / 2,
([Link] - [Link]) / 2);
var imgData = [Link](0, 0, [Link], [Link]);
var pix = [Link];
//convert the image into a silhouette
for (var i=0, n = [Link]; i < n; i+= 4){
//set red to 0
pix[i] = 255;
//set green to 0
pix[i+1] = 255;
//set blue to 0
pix[i+2] = 255;
//retain the alpha value
pix[i+3] = pix[i+3];
}
[Link](imgData,0,0);
[Link] = [Link]();
output=[Link]()
`;
loadSF2B64 = async (
icon = '[Link].2x2',
color = '#56A8D6',
cornerWidth = 42
) => {
const sfImg = await [Link](icon, color, cornerWidth);
return `data:image/png;base64,${[Link](sfImg).toBase64String()}`;
};
return [Link]([
{
title: '个性设置',
menu: [
{
icon: { name: 'person', color: '#fa541c' },
name: [Link][0],
title: '首页头像',
type: 'img',
val: [Link],
onClick: async (_, __, previewWebView) => {
const options = ['相册选择', '在线链接', '取消'];
const message = '设置个性化头像';
const index = await [Link](message, options);
if (index === 2) return;
const cachePath = `${_.val}/${_.name}`;
switch (index) {
case 0:
const albumOptions = ['选择图片', '清空图片', '取消'];
const albumIndex = await [Link]('', albumOptions);
if (albumIndex === 2) return;
if (albumIndex === 1) {
await [Link](false, cachePath, {
previewWebView,
id: _.name,
});
return;
}
break;
case 1:
const data = await [Link](
'在线链接',
'首页头像在线链接',
{
avatar: '🔗请输入 URL 图片链接',
}
);
if (!data) return;
break;
default:
break;
}
},
},
{
icon: { name: 'pencil', color: '#fa8c16' },
type: 'input',
title: '首页昵称',
desc: '个性化首页昵称',
placeholder: '👤请输入头像昵称',
val: [Link][1],
name: [Link][1],
defaultValue: [Link],
onClick: baseOnClick,
},
{
icon: { name: 'lineweight', color: '#a0d911' },
type: 'input',
title: '首页昵称描述',
desc: '个性化首页昵称描述',
placeholder: '请输入描述',
val: [Link][2],
name: [Link][2],
defaultValue: [Link],
onClick: baseOnClick,
},
],
},
{
menu: [
{
icon: { name: 'shippingbox', color: '#f7bb10' },
type: 'input',
title: 'BoxJS 域名',
desc: '设置 BoxJS 访问域名,如:[Link] 或 [Link]',
val: 'boxjsDomain',
name: 'boxjsDomain',
placeholder: '[Link]',
defaultValue: [Link],
onClick: baseOnClick,
},
{
icon: { name: 'clear', color: '#f5222d' },
title: '恢复默认设置',
name: 'reset',
onClick: async () => {
const options = ['取消', '确定'];
const message = '确定要恢复当前所有配置吗?';
const index = await [Link](message, options);
if (index === 1) {
[Link] = {};
[Link] = {};
this.FILE_MGR.remove([Link]);
[Link](false);
[Link]();
await [Link](
'重置成功',
'请关闭窗口之后,重新运行当前脚本'
);
[Link]();
}
},
},
],
},
]);
};
reopenScript = () => {
[Link](`scriptable:///run/${encodeURIComponent([Link]())}`);
};
async renderAppView(
options = [],
renderAvatar = false,
previewWebView = new WebView()
) {
const settingItemFontSize = 14,
authorNameFontSize = 20,
authorDescFontSize = 12;
// ================== 配置界面样式 ===================
const style = `
:root {
--color-primary: #007aff;
--divider-color: rgba(60,60,67,0.16);
--card-background: #fff;
--card-radius: 8px;
--list-header-color: rgba(60,60,67,0.6);
}
* {
-webkit-user-select: none;
user-select: none;
}
body {
margin: 10px 0;
-webkit-font-smoothing: antialiased;
font-family: "SF Pro Display","SF Pro Icons","Helvetica
Neue","Helvetica","Arial",sans-serif;
accent-color: var(--color-primary);
background: #f6f6f6;
}
.list {
margin: 15px;
}
.list__header {
margin: 0 18px;
color: var(--list-header-color);
font-size: 13px;
}
.list__body {
margin-top: 10px;
background: var(--card-background);
border-radius: var(--card-radius);
overflow: hidden;
}
.form-item-auth {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 4em;
padding: 0.5em 18px;
position: relative;
}
.form-item-auth-name {
margin: 0px 12px;
font-size: ${authorNameFontSize}px;
font-weight: 430;
}
.form-item-auth-desc {
margin: 0px 12px;
font-size: ${authorDescFontSize}px;
font-weight: 400;
}
.form-label-author-avatar {
width: 62px;
height: 62px;
border-radius:50%;
border: 1px solid #F6D377;
}
.form-item, .form-item-switch {
display: flex;
align-items: center;
justify-content: space-between;
font-size: ${settingItemFontSize}px;
font-weight: 400;
min-height: 2.2em;
padding: 0.5em 10px;
position: relative;
}
label > * {
pointer-events: none;
}
.form-label {
display: flex;
align-items: center;
flex-wrap:nowrap
}
.form-label-img {
height: 30px;
}
.form-label-title {
margin-left: 8px;
white-space: nowrap;
}
.bottom-bg {
margin: 30px 15px 15px 15px;
}
.form-item--link .icon-arrow-right {
color: #86868b;
}
.form-item-right-desc {
font-size: 13px;
color: #86868b;
margin: 0 4px 0 auto;
max-width: 130px;
overflow: hidden;
text-overflow: ellipsis;
display:flex;
align-items: center;
white-space: nowrap;
}
.form-item-right-desc img{
width:30px;
height:30px;
border-radius:3px;
}
.form-item + .form-item::before,
.form-item + .form-item-switch::before,
.form-item-switch + .form-item::before,
.form-item-switch + .form-item-switch::before
{
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
border-top: 0.5px solid var(--divider-color);
}
.form-item input[type="checkbox"] {
width: 2em;
height: 2em;
}
input[type='input'],select,input[type='date'] {
width: 100%;
height: 2.3em;
outline-style: none;
text-align: right;
padding: 0px 10px;
border: 1px solid #ddd;
font-size: 14px;
color: #86868b;
border-radius:4px;
}
input[type='checkbox'][role='switch'] {
position: relative;
display: inline-block;
appearance: none;
width: 40px;
height: 24px;
border-radius: 24px;
background: #ccc;
transition: 0.3s ease-in-out;
}
input[type='checkbox'][role='switch']::before {
content: '';
position: absolute;
left: 2px;
top: 2px;
width: 20px;
height: 20px;
border-radius: 50%;
background: #fff;
transition: 0.3s ease-in-out;
}
input[type='checkbox'][role='switch']:checked {
background: var(--color-primary);
}
input[type='checkbox'][role='switch']:checked::before {
transform: translateX(16px);
}
.copyright {
display: flex;
align-items: center;
justify-content: space-between;
margin: 15px;
font-size: 10px;
color: #86868b;
}
.copyright a {
color: #515154;
text-decoration: none;
}
.[Link] {
pointer-events: none;
}
.icon-loading {
display: inline-block;
animation: 1s linear infinite spin;
}
.normal-loading {
display: inline-block;
animation: 20s linear infinite spin;
}
@keyframes spin {
0% {
transform: rotate(0);
}
100% {
transform: rotate(1turn);
}
}
@media (prefers-color-scheme: dark) {
:root {
--divider-color: rgba(84,84,88,0.65);
--card-background: #1c1c1e;
--list-header-color: rgba(235,235,245,0.6);
}
body {
background: #000;
color: #fff;
}
}`;
const js = `
(() => {
// 切换 ico 的 loading 效果
const toggleIcoLoading = (e) => {
try{
const target = [Link]
[Link]('loading')
const icon = [Link]('.iconfont')
const className = [Link]
[Link] = 'iconfont icon-loading'
const listener = (event) => {
const { code } = [Link]
if (code === 'finishLoading') {
[Link]('loading')
[Link] = className
[Link]('JWeb', listener);
}
}
[Link]('JWeb', listener)
}catch(e){
for (const loading of [Link]('.icon-loading')) {
[Link]('loading');
[Link] = "iconfont icon-arrow-right";
}
}
};
if(${renderAvatar}){
[Link]('.form-item-auth')[0].addEventListener('click',
(e) => {
toggleIcoLoading(e);
invoke("userInfo");
})
}
})()`;
let configList = ``;
let actionsConfig = [];
configList += `
${addLable}
<div class="form-label item-none">
<img class="form-label-img" class="form-label-img" src="$
{iconBase64}"/>
<div class="form-label-title">${[Link]}</div>
</div>
<div id="${idName}_val" class="form-item-right-desc">
${defaultHtml}
</div>
<i id="iconfont-${idName}" class="iconfont icon-arrow-right"></i>
</label>
`;
}
configList += `</form></div>`;
}
if (await this.FILE_MGR.fileExistsExtra(cachePath)) {
[Link] = `data:image/png;base64,${[Link](
cachePath
).toBase64String()}`;
}
avatarHtml = `
<div class="list">
<form class="list__body" action="javascript:void(0);">
<label id="userInfo" class="form-item-auth form-item--link">
<div class="form-label">
<img class="form-label-author-avatar" src="$
{[Link]}"/>
<div>
<div class="form-item-auth-name">${[Link]}</div>
<div
class="form-item-auth-desc">${[Link]}</div>
</div>
</div>
<div id="userInfo_val" class="form-item-right-desc">
个性化设置
</div>
<i class="iconfont icon-arrow-right"></i>
</label>
</form>
</div>
`;
}
const html = `
<html>
<head>
<meta name='viewport' content='width=device-width, user-scalable=no'>
<link rel="stylesheet"
href="[Link] type="text/css">
<style>${style}</style>
</head>
<body>
${avatarHtml}
${configList}
<footer>
<div class="copyright"><div> </div><div>© 界面样式修改自 <a
href="javascript:invoke('safari',
'[Link]
</footer>
<script>${js}</script>
</body>
</html>`;
// 预览 web
await [Link](html);
if (actionItem) {
const idName = actionItem?.name || actionItem?.val;
if (actionItem?.onClick) {
await actionItem?.onClick?.(actionItem, data, previewWebView);
} else if ([Link] == 'input') {
if (
await [Link](
actionItem['title'],
actionItem['desc'],
idName,
actionItem['placeholder']
)
)
[Link](
previewWebView,
idName,
[Link][idName] || ''
);
} else if ([Link] === 'img') {
const cachePath = `${[Link]}/${[Link]}`;
const options = ['相册选择', '清空图片', '取消'];
const message = '相册图片选择,请选择合适图片大小';
const index = await [Link](message, options);
switch (index) {
case 0:
const backImage = await [Link]([Link]);
if (backImage) {
const cachePath = `${[Link]}/${[Link]}`;
await [Link](backImage, cachePath, {
previewWebView,
id: idName,
});
}
break;
case 1:
await [Link](false, cachePath, {
previewWebView,
id: idName,
});
break;
default:
break;
}
} else {
if (data !== undefined) {
[Link][idName] = data;
[Link](false);
}
}
}
} catch (error) {
[Link]('异常操作:' + error);
}
[Link](previewWebView);
injectListener();
};
injectListener().catch((e) => {
[Link](e);
[Link](previewWebView);
if (![Link]) {
[Link]('主界面', `🚫 ${e}`);
}
});
[Link]();
}
initSFSymbol() {
const named = [Link];
[Link] = (str) => {
const current = named(str);
if (!current) {
[Link](`图标异常,请在文中搜索并替换图标:${str}`);
return named('photo');
}
return current;
};
return SFSymbol;
}
_init(widgetFamily = [Link]) {
[Link]();
// 组件大小:small,medium,large
[Link] = widgetFamily;
//用于配置所有的组件相关设置
// 文件管理器
// 提示:缓存数据不要用这个操作,这个是操作源码目录的,缓存建议存放在 local temp 目录中
this.FILE_MGR =
FileManager[
[Link]('Documents/iCloud~') ? 'iCloud' : 'local'
]();
[Link] = this.FILE_MGR.joinPath(
this.FILE_MGR.documentsDirectory(),
`/images/${[Link]()}`
);
[Link] = this.FILE_MGR.joinPath(
this.FILE_MGR.documentsDirectory(),
`/images/`
);
[Link] = [
`${[Link]}/transparentBg`,
`${[Link]}/dayBg`,
`${[Link]}/nightBg`,
`${[Link]}/avatar`,
];
if (!this.FILE_MGR.fileExists([Link])) {
this.FILE_MGR.createDirectory([Link], true);
}
// 本地,用于存储图片等
this.FILE_MGR_LOCAL = [Link]();
[Link] = [Link]();
[Link] = [Link]();
[Link] = [Link];
[Link] = [Link](
new Color([Link]),
new Color([Link])
);
[Link] = [Link](
new Color([Link]),
new Color([Link])
);
}
/**
* 注册点击操作菜单
* @param {string} name 操作函数名
* @param {func} func 点击后执行的函数
*/
registerAction(name, func, icon = { name: 'gear', color: '#096dd9' }, type) {
if (typeof name === 'object' && ![Link]) return this._actions.push(name);
if (typeof name === 'object' && [Link])
return this._menuActions.push(name);
const action = {
name,
type,
title: name,
onClick: func?.bind(this),
};
this._actions.push(action);
}
/**
* base64 编码字符串
* @param {string} str 要编码的字符串
*/
base64Encode(str) {
const data = [Link](str);
return data.toBase64String();
}
/**
* base64 解码数据 返回字符串
* @param {string} b64 base64 编码的数据
*/
base64Decode(b64) {
const data = Data.fromBase64String(b64);
return [Link]();
}
/**
* md5 加密字符串
* @param {string} str 要加密成 md5 的数据
*/
// prettier-ignore
md5(str){function d(n,t){var r=(65535&n)+(65535&t);return(((n>>16)+(t>>16)+
(r>>16))<<16)|(65535&r)}function f(n,t,r,e,o,u){return
d(((c=d(d(t,n),d(e,u)))<<(f=o))|(c>>>(32-f)),r);var c,f}function l(n,t,r,e,o,u,c)
{return f((t&r)|(~t&e),n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f((t&e)|
(r&~e),n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function
m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function i(n,t){var r,e,o,u;(n[t>>5]|
=128<<t%32),(n[14+(((t+64)>>>9)<<4)]=t);for(var c=1732584193,f=-271733879,i=-
1732584194,a=271733878,h=0;h<[Link];h+=16)(c=l((r=c),(e=f),(o=i),(u=a),n[h],7,-
680876936)),(a=l(a,c,f,i,n[h+1],12,-389564586)),(i=l(i,a,c,f,n[h+2],17,606105819)),
(f=l(f,i,a,c,n[h+3],22,-1044525330)),(c=l(c,f,i,a,n[h+4],7,-176418897)),
(a=l(a,c,f,i,n[h+5],12,1200080426)),(i=l(i,a,c,f,n[h+6],17,-1473231341)),
(f=l(f,i,a,c,n[h+7],22,-45705983)),(c=l(c,f,i,a,n[h+8],7,1770035416)),
(a=l(a,c,f,i,n[h+9],12,-1958414417)),(i=l(i,a,c,f,n[h+10],17,-42063)),
(f=l(f,i,a,c,n[h+11],22,-1990404162)),(c=l(c,f,i,a,n[h+12],7,1804603682)),
(a=l(a,c,f,i,n[h+13],12,-40341101)),(i=l(i,a,c,f,n[h+14],17,-1502002290)),(c=v(c,
(f=l(f,i,a,c,n[h+15],22,1236535329)),i,a,n[h+1],5,-165796510,)),
(a=v(a,c,f,i,n[h+6],9,-1069501632)),(i=v(i,a,c,f,n[h+11],14,643717713)),
(f=v(f,i,a,c,n[h],20,-373897302)),(c=v(c,f,i,a,n[h+5],5,-701558691)),
(a=v(a,c,f,i,n[h+10],9,38016083)),(i=v(i,a,c,f,n[h+15],14,-660478335)),
(f=v(f,i,a,c,n[h+4],20,-405537848)),(c=v(c,f,i,a,n[h+9],5,568446438)),
(a=v(a,c,f,i,n[h+14],9,-1019803690)),(i=v(i,a,c,f,n[h+3],14,-187363961)),
(f=v(f,i,a,c,n[h+8],20,1163531501)),(c=v(c,f,i,a,n[h+13],5,-1444681467)),
(a=v(a,c,f,i,n[h+2],9,-51403784)),(i=v(i,a,c,f,n[h+7],14,1735328473)),(c=g(c,
(f=v(f,i,a,c,n[h+12],20,-1926607734)),i,a,n[h+5],4,-378558,)),
(a=g(a,c,f,i,n[h+8],11,-2022574463)),(i=g(i,a,c,f,n[h+11],16,1839030562)),
(f=g(f,i,a,c,n[h+14],23,-35309556)),(c=g(c,f,i,a,n[h+1],4,-1530992060)),
(a=g(a,c,f,i,n[h+4],11,1272893353)),(i=g(i,a,c,f,n[h+7],16,-155497632)),
(f=g(f,i,a,c,n[h+10],23,-1094730640)),(c=g(c,f,i,a,n[h+13],4,681279174)),
(a=g(a,c,f,i,n[h],11,-358537222)),(i=g(i,a,c,f,n[h+3],16,-722521979)),
(f=g(f,i,a,c,n[h+6],23,76029189)),(c=g(c,f,i,a,n[h+9],4,-640364487)),
(a=g(a,c,f,i,n[h+12],11,-421815835)),(i=g(i,a,c,f,n[h+15],16,530742520)),(c=m(c,
(f=g(f,i,a,c,n[h+2],23,-995338651)),i,a,n[h],6,-198630844,)),
(a=m(a,c,f,i,n[h+7],10,1126891415)),(i=m(i,a,c,f,n[h+14],15,-1416354905)),
(f=m(f,i,a,c,n[h+5],21,-57434055)),(c=m(c,f,i,a,n[h+12],6,1700485571)),
(a=m(a,c,f,i,n[h+3],10,-1894986606)),(i=m(i,a,c,f,n[h+10],15,-1051523)),
(f=m(f,i,a,c,n[h+1],21,-2054922799)),(c=m(c,f,i,a,n[h+8],6,1873313359)),
(a=m(a,c,f,i,n[h+15],10,-30611744)),(i=m(i,a,c,f,n[h+6],15,-1560198380)),
(f=m(f,i,a,c,n[h+13],21,1309151649)),(c=m(c,f,i,a,n[h+4],6,-145523070)),
(a=m(a,c,f,i,n[h+11],10,-1120210379)),(i=m(i,a,c,f,n[h+2],15,718787259)),
(f=m(f,i,a,c,n[h+9],21,-343485551)),(c=d(c,r)),(f=d(f,e)),(i=d(i,o)),
(a=d(a,u));return[c,f,i,a]}function a(n){for(var
t='',r=32*[Link],e=0;e<r;e+=8)t+=[Link]((n[e>>5]>>>e%32)&255);return
t}function h(n){var t=[];for(t[([Link]>>2)-1]=void
0,e=0;e<[Link];e+=1)t[e]=0;for(var r=8*[Link],e=0;e<r;e+=8)t[e>>5]|
=(255&[Link](e/8))<<e%32;return t}function e(n){for(var
t,r='0123456789abcdef',e='',o=0;o<[Link];o+=1)(t=[Link](o)),
(e+=[Link]((t>>>4)&15)+[Link](15&t));return e}function r(n){return
unescape(encodeURIComponent(n))}function o(n){return
a(i(h((t=r(n))),8*[Link]));var t}function u(n,t){return(function(n,t){var
r,e,o=h(n),u=[],c=[];for(u[15]=c[15]=void
0,16<[Link]&&(o=i(o,8*[Link])),r=0;r<16;r+=1)(u[r]=909522486^o[r]),
(c[r]=1549556828^o[r]);return((e=i([Link](h(t)),512+8*[Link])),a(i([Link](e),
640)))})(r(n),r(t))}function t(n,t,r){return t?(r?u(t,n):e(u(t,n))):r?
o(n):e(o(n))}return t(str)}
/**
* 渲染标题内容
* @param {object} widget 组件对象
* @param {string} icon 图标地址
* @param {string} title 标题内容
* @param {bool|color} color 字体的颜色(自定义背景时使用,默认系统)
*/
async renderHeader(widget, icon, title, color = false) {
let header = [Link]();
[Link]();
try {
const image = await this.$[Link](icon, 'IMG');
let _icon = [Link](image);
_icon.imageSize = new Size(14, 14);
_icon.cornerRadius = 4;
} catch (e) {
[Link](e);
}
[Link](10);
let _title = [Link](title);
if (color) _title.textColor = color;
_title.textOpacity = 0.7;
_title.font = [Link](12);
_title.lineLimit = 1;
[Link](15);
return widget;
}
/**
* @param message 描述内容
* @param options 按钮
* @returns {Promise<number>}
*/
/**
* 给图片加一层半透明遮罩
* @param {Image} img 要处理的图片
* @param {string} color 遮罩背景颜色
* @param {float} opacity 透明度
*/
async shadowImage(img, color = '#000000', opacity = 0.7) {
if (!img) return;
if (opacity === 0) return img;
let ctx = new DrawContext();
// 获取图片的尺寸
[Link] = [Link];
[Link](
img,
new Rect(0, 0, [Link]['width'], [Link]['height'])
);
[Link](new Color(color, opacity));
[Link](new Rect(0, 0, [Link]['width'], [Link]['height']));
return await [Link]();
}
/**
* 获取当前插件的设置
* @param {boolean} json 是否为 json 格式
*/
getSettings(json = true) {
let res = json ? {} : '';
let cache = '';
if ([Link](this.SETTING_KEY)) {
cache = [Link](this.SETTING_KEY);
}
if (json) {
try {
res = [Link](cache);
} catch (e) {}
} else {
res = cache;
}
return res;
}
getBaseSettings(json = true) {
let res = json ? {} : '';
let cache = '';
if ([Link]([Link])) {
cache = [Link]([Link]);
}
if (json) {
try {
res = [Link](cache);
} catch (e) {}
} else {
res = cache;
}
return res;
}
/**
* 存储当前设置
* @param {bool} notify 是否通知提示
*/
saveSettings(notify = true) {
let res =
typeof [Link] === 'object'
? [Link]([Link])
: String([Link]);
[Link](this.SETTING_KEY, res);
return res;
}
/**
* 获取当前插件是否有自定义背景图片
* @reutrn img | false
*/
async getBackgroundImage() {
if (await this.FILE_MGR.fileExistsExtra([Link][0]))
return [Link]([Link][0]);
if (![Link])
return (await this.FILE_MGR.fileExistsExtra([Link][1]))
? [Link]([Link][1])
: undefined;
else
return (await this.FILE_MGR.fileExistsExtra([Link][2]))
? [Link]([Link][2])
: undefined;
}
/**
* 设置当前组件的背景图片
* @param {Image} img
*/
async setBackgroundImage(img, filePath = [Link], notify = true) {
const cacheKey = filePath;
if (!img) {
// 移除背景
if (this.FILE_MGR.fileExists(cacheKey)) this.FILE_MGR.remove(cacheKey);
if (notify) [Link]('移除成功', '背景图片已移除,稍后刷新生效');
} else {
// 设置背景
this.FILE_MGR.writeImage(cacheKey, img);
getRandomArrayElements(arr, count) {
let shuffled = [Link](0),
i = [Link],
min = i - count,
temp,
index;
min = min > 0 ? min : 0;
while (i-- > min) {
index = [Link]((i + 1) * [Link]());
temp = shuffled[index];
shuffled[index] = shuffled[i];
shuffled[i] = temp;
}
return [Link](min);
}
textFormat = {
defaultText: { size: 14, font: 'regular', color: [Link] },
battery: { size: 10, font: 'bold', color: [Link] },
title: { size: 16, font: 'semibold', color: [Link] },
SFMono: { size: 12, font: 'SF Mono', color: [Link] },
};
// @[Link]
const Runing = async (Widget, default_args = '', isDebug = true, extra) => {
let M = null;
// 判断 hash 是否和当前设备匹配
if ([Link]) {
M = new Widget([Link] || '');
if (extra) {
[Link](extra).forEach((key) => {
M[key] = extra[key];
});
}
const W = await [Link]();
try {
if ([Link]) {
const refreshTime = parseInt([Link]) * 1000 * 60;
const timeStr = new Date().getTime() + refreshTime;
[Link] = new Date(timeStr);
}
} catch (e) {
[Link](e);
}
if (W) {
[Link](W);
[Link]();
}
} else {
let { act, __arg, __size } = [Link];
M = new Widget(__arg || default_args || '');
if (extra) {
[Link](extra).forEach((key) => {
M[key] = extra[key];
});
}
if (__size) M._init(__size);
if (!act || !M['_actions']) {
// 弹出选择菜单
const actions = M['_actions'];
const onClick = async (item) => {
[Link] = [Link];
try {
M._init([Link]);
} catch (error) {
[Link]('初始化异常:' + error);
}
w = await [Link]();
const fnc = [Link]
.toLowerCase()
.replace(/( |^)[a-z]/g, (L) => [Link]());
if (w) return w[`present${fnc}`]();
};
if ([Link]) {
[Link]({
url:
`[Link]
title: '中尺寸',
val: 'medium',
name: 'medium',
dismissOnSelect: true,
onClick,
});
}
if ([Link]) {
[Link]({
url:
`[Link]
title: '大尺寸',
val: 'large',
name: 'large',
dismissOnSelect: true,
onClick,
});
}
if ([Link]) {
[Link]({
icon: {
color: '#4676EE',
name: '[Link]',
},
title: '锁屏列表',
val: 'accessoryInline',
name: 'accessoryInline',
dismissOnSelect: true,
onClick,
});
}
if ([Link]) {
[Link]({
icon: {
color: '#4676EE',
name: '[Link]',
},
title: '锁屏 2x',
val: 'accessoryRectangular',
name: 'accessoryRectangular',
dismissOnSelect: true,
onClick,
});
}
if ([Link]) {
[Link]({
icon: {
color: '#4676EE',
name: '[Link]',
},
title: '锁屏 1x',
val: 'accessoryCircular',
name: 'accessoryCircular',
dismissOnSelect: true,
onClick,
});
}
const menuConfig = [
...(preview ? [{ title: '预览组件', menu: preview }] : []),
...([Link] ? [{ title: '锁屏组件', menu: lockView }] : []),
...M['_menuActions'],
];
BaseCacheKey = 'DmYY';
_actions = [];
_menuActions = [];
widgetColor;
backGroundColor;
isNight;
// 获取 Request 对象
getRequest = (url = '') => {
return new Request(url);
};
// 发起请求
http = async (
options = { headers: {}, url: '' },
type = 'JSON',
onError = () => {
return [Link]('photo').image;
}
) => {
let request;
try {
if (type === 'IMG') {
const fileName = `${[Link]}/${this.md5([Link])}`;
request = [Link]([Link]);
let response;
if (await this.FILE_MGR.fileExistsExtra(fileName)) {
[Link]().then((res) => {
this.FILE_MGR.writeImage(fileName, res);
});
return [Link](fileName);
} else {
response = await [Link]();
this.FILE_MGR.writeImage(fileName, response);
}
return response;
}
request = [Link]();
[Link](options).forEach((key) => {
request[key] = options[key];
});
[Link] = { ...[Link], ...[Link] };
//request 接口请求
$request = {
get: (url = '', options = {}, type = 'JSON') => {
let params = { ...options, method: 'GET' };
if (typeof url === 'object') {
params = { ...params, ...url };
} else {
[Link] = url;
}
let _type = type;
if (typeof options === 'string') _type = options;
return [Link](params, _type);
},
post: (url = '', options = {}, type = 'JSON') => {
let params = { ...options, method: 'POST' };
if (typeof url === 'object') {
params = { ...params, ...url };
} else {
[Link] = url;
}
let _type = type;
if (typeof options === 'string') _type = options;
return [Link](params, _type);
},
};
// 获取 boxJS 缓存
getCache = async (key = '', notify = true) => {
try {
let url = '[Link] + [Link] + '/query/boxdata';
if (key) url = '[Link] + [Link] + '/query/data/' + key;
const boxdata = await this.$[Link](
url,
key ? { timeoutInterval: 1 } : {}
);
if (key) {
[Link] = {
...[Link],
[key]: [Link],
};
[Link](false);
}
if ([Link]) return [Link];
return [Link];
} catch (e) {
if (key && [Link][key]) {
return [Link][key];
}
if (notify)
await [Link](
`${[Link]} - BoxJS 数据读取失败`,
'请检查 BoxJS 域名是否为代理复写的域名,如([Link] 或 [Link])。\n 若没有配置 BoxJS 相关模块,请点击通
知查看教程',
'[Link]
);
return false;
}
};
// 选择图片并缓存
chooseImg = async (verify = false) => {
const response = await [Link]().catch((err) => {
[Link]('图片选择异常:' + err);
});
if (verify) {
const bool = await [Link](response);
if (bool) return response;
return null;
}
return response;
};
// 设置 widget 背景图片
getWidgetBackgroundImage = async (widget) => {
const backgroundImage = await [Link]();
if (backgroundImage) {
const opacity = [Link]()
? Number([Link])
: Number([Link]);
[Link] = await [Link](
backgroundImage,
'#000',
opacity
);
return true;
} else {
if ([Link]) {
[Link] = [Link];
} else {
[Link] = [Link];
}
return false;
}
};
/**
* 验证图片尺寸: 图片像素超过 1000 左右的时候会导致背景无法加载
* @param img Image
*/
verifyImage = async (img = {}) => {
const { width, height } = [Link];
const direct = true;
if (width > 1000) {
const options = ['取消', '打开图像处理'];
const message =
'您的图片像素为' +
width +
' x ' +
height +
'\n' +
'请将图片' +
(direct ? '宽度' : '高度') +
'调整到 1000 以下\n' +
(!direct ? '宽度' : '高度') +
'自动适应';
const index = await [Link](message, options);
if (index === 1)
[Link]('[Link] false);
return false;
}
return true;
};
/**
* 获取截图中的组件剪裁图
* 可用作透明背景
* 返回图片 image 对象
* 代码改自:[Link]
* @param {string} title 开始处理前提示用户截图的信息,可选(适合用在组件自定义透明背景时提示)
*/
async getWidgetScreenShot(title = null) {
// Crop an image into the specified rect.
function cropImage(img, rect) {
let draw = new DrawContext();
[Link] = new Size([Link], [Link]);
function phoneSizes(inputHeight) {
return {
/*
Supported devices
=================
The following device measurements have been confirmed in iOS 18.
*/
// 16 Pro Max
2868: {
text: {
small: 510,
medium: 1092,
large: 1146,
left: 114,
right: 696,
top: 276,
middle: 912,
bottom: 1548,
},
notext: {
small: 530,
medium: 1138,
large: 1136,
left: 91,
right: 699,
top: 276,
middle: 882,
bottom: 1488,
},
},
// 16 Pro
2622: {
text: {
small: 486,
medium: 1032,
large: 1098,
left: 87,
right: 633,
top: 261,
middle: 872,
bottom: 1485,
},
notext: {
small: 495,
medium: 1037,
large: 1035,
left: 84,
right: 626,
top: 270,
middle: 810,
bottom: 1350,
},
},
// SE3, SE2
1334: {
text: {
small: 296,
medium: 642,
large: 648,
left: 54,
right: 400,
top: 60,
middle: 412,
bottom: 764,
},
notext: {
small: 309,
medium: 667,
large: 667,
left: 41,
right: 399,
top: 67,
middle: 425,
bottom: 783,
},
},
/*
In-limbo devices
=================
The following device measurements were confirmed in older versions of iOS.
Please comment if you can confirm these for iOS 18.
*/
// 11, XR
1792: {
small: 338,
medium: 720,
large: 758,
left: 55,
right: 437,
top: 159,
middle: 579,
bottom: 999,
},
/*
Older devices
=================
The following devices cannot be updated to iOS 18 or later.
*/
// SE1
1136: {
small: 282,
medium: 584,
large: 622,
left: 30,
right: 332,
top: 59,
middle: 399,
bottom: 399,
},
}[inputHeight];
}
let message =
title || '开始之前,请先前往桌面,截取空白界面的截图。然后回来继续';
let exitOptions = ['我已截图', '前去截图 >'];
let shouldExit = await [Link](message, exitOptions);
if (shouldExit) return;
message = '要设置透明背景的小组件在哪个位置?';
message +=
height === 1136
? ' (备注:当前设备只支持两行小组件,所以下边选项中的「中间」和「底部」的选项是一致的)'
: '';
// Convert the two words into two keys for the phone size dictionary.
let keys = _posotions[position].toLowerCase().split(' ');
crop.y = phone[keys[0]];
crop.x = phone[keys[1]];
} else if (widgetSize === '中尺寸') {
crop.w = [Link];
crop.h = [Link];
/**
* 弹出输入框
* @param title 标题
* @param desc 描述
* @param opt 属性
* @returns {Promise<void>}
*/
setAlertInput = async (title, desc, opt = {}, isSave = true) => {
const a = new Alert();
[Link] = title;
[Link] = !desc ? '' : desc;
[Link](opt).forEach((key) => {
[Link](opt[key], [Link][key]);
});
[Link]('确定');
[Link]('取消');
const id = await [Link]();
if (id === -1) return;
const data = {};
[Link](opt).forEach((key, index) => {
data[key] = [Link](index) || '';
});
// 保存到本地
if (isSave) {
[Link] = { ...[Link], ...data };
return [Link]();
}
return data;
};
/**
* 设置当前项目的 boxJS 缓存
* @param opt key value
* @returns {Promise<void>}
*/
setCacheBoxJSData = async (opt = {}) => {
const options = ['取消', '确定'];
const message = '代理缓存仅支持 BoxJS 相关的代理!';
const index = await [Link](message, options);
if (index === 0) return;
try {
const boxJSData = await [Link]();
[Link](opt).forEach((key) => {
[Link][key] = boxJSData[opt[key]] || '';
});
// 保存到本地
[Link]();
} catch (e) {
[Link](e);
[Link](
[Link],
'BoxJS 缓存读取失败!点击查看相关教程',
'[Link]
);
}
};
/**
* 设置组件内容
* @returns {Promise<void>}
*/
setWidgetConfig = async () => {
const basic = [
{
icon: { name: '[Link]', color: '#1890ff' },
type: 'input',
title: '刷新时间',
desc: '刷新时间仅供参考,具体刷新时间由系统判断,单位:分钟',
val: 'refreshAfterDate',
},
{
icon: { name: '[Link]', color: '#d48806' },
type: 'color',
title: '白天字体颜色',
desc: '请自行去网站上搜寻颜色(Hex 颜色)',
val: 'lightColor',
},
{
icon: { name: '[Link]', color: '#d4b106' },
type: 'color',
title: '晚上字体颜色',
desc: '请自行去网站上搜寻颜色(Hex 颜色)',
val: 'darkColor',
},
];
return [Link]([
{ title: '基础设置', menu: basic },
{
title: '背景设置',
menu: [
{
icon: { name: 'photo', color: '#13c2c2' },
type: 'color',
title: '白天背景颜色',
desc: '请自行去网站上搜寻颜色(Hex 颜色)\n 支持渐变色,各颜色之间以英文逗号分隔',
val: 'lightBgColor',
},
{
icon: { name: '[Link]', color: '#52c41a' },
type: 'color',
title: '晚上背景颜色',
desc: '请自行去网站上搜寻颜色(Hex 颜色)\n 支持渐变色,各颜色之间以英文逗号分隔',
val: 'darkBgColor',
},
],
},
{
menu: [
{
icon: { name: '[Link]', color: '#fa8c16' },
name: 'dayBg',
type: 'img',
title: '日间背景',
val: [Link],
verify: true,
},
{
icon: { name: '[Link]', color: '#fa541c' },
name: 'nightBg',
type: 'img',
title: '夜间背景',
val: [Link],
verify: true,
},
{
icon: { name: '[Link]', color: '#faad14' },
type: 'img',
name: 'transparentBg',
title: '透明背景',
val: [Link],
onClick: async (item, __, previewWebView) => {
const backImage = await [Link]();
if (!backImage || !(await [Link](backImage))) return;
const cachePath = `${[Link]}/${[Link]}`;
await [Link](backImage, cachePath, {
previewWebView,
id: [Link],
});
},
},
],
},
{
menu: [
{
icon: { name: '[Link]', color: '#722ed1' },
type: 'input',
title: '日间蒙层',
desc: '完全透明请设置为 0',
val: 'lightOpacity',
},
{
icon: { name: '[Link]', color: '#eb2f96' },
type: 'input',
title: '夜间蒙层',
desc: '完全透明请设置为 0',
val: 'darkOpacity',
},
],
},
{
menu: [
{
icon: { name: 'clear', color: '#f5222d' },
name: 'removeBackground',
title: '清空背景图片',
val: `${[Link]}/`,
onClick: async (_, __, previewWebView) => {
const ids = ['dayBg', 'nightBg', 'transparentBg'];
const options = [
'清空日间',
'清空夜间',
'清空透明',
`清空全部`,
'取消',
];
const message = '该操作不可逆,会清空背景图片!';
const index = await [Link](message, options);
if (index === 4) return;
switch (index) {
case 3:
await [Link](false, `${_.val}${ids[0]}`, {
previewWebView,
id: ids[0],
});
await [Link](false, `${_.val}${ids[1]}`, {
previewWebView,
id: ids[1],
});
await [Link](false, `${_.val}${ids[2]}`, {
previewWebView,
id: ids[2],
});
return;
default:
await [Link](false, `${_.val}${ids[index]}`, {
previewWebView,
id: ids[index],
});
break;
}
},
},
],
},
{
title: '重置组件',
menu: [
{
icon: { name: 'trash', color: '#D85888' },
title: '重置',
desc: '重置当前组件配置',
name: 'reset',
val: 'reset',
onClick: () => {
[Link] = {};
[Link]();
[Link]();
},
},
],
},
]).catch((e) => {
[Link](e);
});
};
drawTableIcon = async (
icon = '[Link].2x2',
color = '#504ED5',
cornerWidth = 42
) => {
let sfi = [Link]('[Link].2x2');
try {
sfi = [Link](icon);
[Link]([Link](30));
} catch (e) {
[Link](`图标(${icon})异常:` + e);
}
const imgData = [Link]([Link]).toBase64String();
const html = `
<img id="sourceImg" src="data:image/png;base64,${imgData}" />
<img id="silhouetteImg" src="" />
<canvas id="mainCanvas" />
`;
const js = `
var canvas = [Link]("canvas");
var sourceImg = [Link]("sourceImg");
var silhouetteImg = [Link]("silhouetteImg");
var ctx = [Link]('2d');
var size = [Link] > [Link] ? [Link] :
[Link];
[Link] = size;
[Link] = size;
[Link](sourceImg, ([Link] - [Link]) / 2,
([Link] - [Link]) / 2);
var imgData = [Link](0, 0, [Link], [Link]);
var pix = [Link];
//convert the image into a silhouette
for (var i=0, n = [Link]; i < n; i+= 4){
//set red to 0
pix[i] = 255;
//set green to 0
pix[i+1] = 255;
//set blue to 0
pix[i+2] = 255;
//retain the alpha value
pix[i+3] = pix[i+3];
}
[Link](imgData,0,0);
[Link] = [Link]();
output=[Link]()
`;
loadSF2B64 = async (
icon = '[Link].2x2',
color = '#56A8D6',
cornerWidth = 42
) => {
const sfImg = await [Link](icon, color, cornerWidth);
return `data:image/png;base64,${[Link](sfImg).toBase64String()}`;
};
return [Link]([
{
title: '个性设置',
menu: [
{
icon: { name: 'person', color: '#fa541c' },
name: [Link][0],
title: '首页头像',
type: 'img',
val: [Link],
onClick: async (_, __, previewWebView) => {
const options = ['相册选择', '在线链接', '取消'];
const message = '设置个性化头像';
const index = await [Link](message, options);
if (index === 2) return;
const cachePath = `${_.val}/${_.name}`;
switch (index) {
case 0:
const albumOptions = ['选择图片', '清空图片', '取消'];
break;
case 1:
const data = await [Link](
'在线链接',
'首页头像在线链接',
{
avatar: '🔗请输入 URL 图片链接',
}
);
if (!data) return;
break;
default:
break;
}
},
},
{
icon: { name: 'pencil', color: '#fa8c16' },
type: 'input',
title: '首页昵称',
desc: '个性化首页昵称',
placeholder: '👤请输入头像昵称',
val: [Link][1],
name: [Link][1],
defaultValue: [Link],
onClick: baseOnClick,
},
{
icon: { name: 'lineweight', color: '#a0d911' },
type: 'input',
title: '首页昵称描述',
desc: '个性化首页昵称描述',
placeholder: '请输入描述',
val: [Link][2],
name: [Link][2],
defaultValue: [Link],
onClick: baseOnClick,
},
],
},
{
menu: [
{
icon: { name: 'shippingbox', color: '#f7bb10' },
type: 'input',
title: 'BoxJS 域名',
desc: '设置 BoxJS 访问域名,如:[Link] 或 [Link]',
val: 'boxjsDomain',
name: 'boxjsDomain',
placeholder: '[Link]',
defaultValue: [Link],
onClick: baseOnClick,
},
{
icon: { name: 'clear', color: '#f5222d' },
title: '恢复默认设置',
name: 'reset',
onClick: async () => {
const options = ['取消', '确定'];
const message = '确定要恢复当前所有配置吗?';
const index = await [Link](message, options);
if (index === 1) {
[Link] = {};
[Link] = {};
this.FILE_MGR.remove([Link]);
[Link](false);
[Link]();
await [Link](
'重置成功',
'请关闭窗口之后,重新运行当前脚本'
);
[Link]();
}
},
},
],
},
]);
};
reopenScript = () => {
[Link](`scriptable:///run/${encodeURIComponent([Link]())}`);
};
async renderAppView(
options = [],
renderAvatar = false,
previewWebView = new WebView()
) {
const settingItemFontSize = 14,
authorNameFontSize = 20,
authorDescFontSize = 12;
// ================== 配置界面样式 ===================
const style = `
:root {
--color-primary: #007aff;
--divider-color: rgba(60,60,67,0.16);
--card-background: #fff;
--card-radius: 8px;
--list-header-color: rgba(60,60,67,0.6);
}
* {
-webkit-user-select: none;
user-select: none;
}
body {
margin: 10px 0;
-webkit-font-smoothing: antialiased;
font-family: "SF Pro Display","SF Pro Icons","Helvetica
Neue","Helvetica","Arial",sans-serif;
accent-color: var(--color-primary);
background: #f6f6f6;
}
.list {
margin: 15px;
}
.list__header {
margin: 0 18px;
color: var(--list-header-color);
font-size: 13px;
}
.list__body {
margin-top: 10px;
background: var(--card-background);
border-radius: var(--card-radius);
overflow: hidden;
}
.form-item-auth {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 4em;
padding: 0.5em 18px;
position: relative;
}
.form-item-auth-name {
margin: 0px 12px;
font-size: ${authorNameFontSize}px;
font-weight: 430;
}
.form-item-auth-desc {
margin: 0px 12px;
font-size: ${authorDescFontSize}px;
font-weight: 400;
}
.form-label-author-avatar {
width: 62px;
height: 62px;
border-radius:50%;
border: 1px solid #F6D377;
}
.form-item, .form-item-switch {
display: flex;
align-items: center;
justify-content: space-between;
font-size: ${settingItemFontSize}px;
font-weight: 400;
min-height: 2.2em;
padding: 0.5em 10px;
position: relative;
}
label > * {
pointer-events: none;
}
.form-label {
display: flex;
align-items: center;
flex-wrap:nowrap
}
.form-label-img {
height: 30px;
}
.form-label-title {
margin-left: 8px;
white-space: nowrap;
}
.bottom-bg {
margin: 30px 15px 15px 15px;
}
.form-item--link .icon-arrow-right {
color: #86868b;
}
.form-item-right-desc {
font-size: 13px;
color: #86868b;
margin: 0 4px 0 auto;
max-width: 130px;
overflow: hidden;
text-overflow: ellipsis;
display:flex;
align-items: center;
white-space: nowrap;
}
.form-item-right-desc img{
width:30px;
height:30px;
border-radius:3px;
}
.form-item + .form-item::before,
.form-item + .form-item-switch::before,
.form-item-switch + .form-item::before,
.form-item-switch + .form-item-switch::before
{
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
border-top: 0.5px solid var(--divider-color);
}
.form-item input[type="checkbox"] {
width: 2em;
height: 2em;
}
input[type='input'],select,input[type='date'] {
width: 100%;
height: 2.3em;
outline-style: none;
text-align: right;
padding: 0px 10px;
border: 1px solid #ddd;
font-size: 14px;
color: #86868b;
border-radius:4px;
}
input[type='checkbox'][role='switch'] {
position: relative;
display: inline-block;
appearance: none;
width: 40px;
height: 24px;
border-radius: 24px;
background: #ccc;
transition: 0.3s ease-in-out;
}
input[type='checkbox'][role='switch']::before {
content: '';
position: absolute;
left: 2px;
top: 2px;
width: 20px;
height: 20px;
border-radius: 50%;
background: #fff;
transition: 0.3s ease-in-out;
}
input[type='checkbox'][role='switch']:checked {
background: var(--color-primary);
}
input[type='checkbox'][role='switch']:checked::before {
transform: translateX(16px);
}
.copyright {
display: flex;
align-items: center;
justify-content: space-between;
margin: 15px;
font-size: 10px;
color: #86868b;
}
.copyright a {
color: #515154;
text-decoration: none;
}
.[Link] {
pointer-events: none;
}
.icon-loading {
display: inline-block;
animation: 1s linear infinite spin;
}
.normal-loading {
display: inline-block;
animation: 20s linear infinite spin;
}
@keyframes spin {
0% {
transform: rotate(0);
}
100% {
transform: rotate(1turn);
}
}
@media (prefers-color-scheme: dark) {
:root {
--divider-color: rgba(84,84,88,0.65);
--card-background: #1c1c1e;
--list-header-color: rgba(235,235,245,0.6);
}
body {
background: #000;
color: #fff;
}
}`;
const js = `
(() => {
if(${renderAvatar}){
[Link]('.form-item-auth')[0].addEventListener('click',
(e) => {
toggleIcoLoading(e);
invoke("userInfo");
})
}
})()`;
configList += `
${addLable}
<div class="form-label item-none">
<img class="form-label-img" class="form-label-img" src="$
{iconBase64}"/>
<div class="form-label-title">${[Link]}</div>
</div>
<div id="${idName}_val" class="form-item-right-desc">
${defaultHtml}
</div>
<i id="iconfont-${idName}" class="iconfont icon-arrow-right"></i>
</label>
`;
}
configList += `</form></div>`;
}
if (await this.FILE_MGR.fileExistsExtra(cachePath)) {
[Link] = `data:image/png;base64,${[Link](
cachePath
).toBase64String()}`;
}
avatarHtml = `
<div class="list">
<form class="list__body" action="javascript:void(0);">
<label id="userInfo" class="form-item-auth form-item--link">
<div class="form-label">
<img class="form-label-author-avatar" src="$
{[Link]}"/>
<div>
<div class="form-item-auth-name">${[Link]}</div>
<div
class="form-item-auth-desc">${[Link]}</div>
</div>
</div>
<div id="userInfo_val" class="form-item-right-desc">
个性化设置
</div>
<i class="iconfont icon-arrow-right"></i>
</label>
</form>
</div>
`;
}
const html = `
<html>
<head>
<meta name='viewport' content='width=device-width, user-scalable=no'>
<link rel="stylesheet"
href="[Link] type="text/css">
<style>${style}</style>
</head>
<body>
${avatarHtml}
${configList}
<footer>
<div class="copyright"><div> </div><div>© 界面样式修改自 <a
href="javascript:invoke('safari',
'[Link]
</footer>
<script>${js}</script>
</body>
</html>`;
// 预览 web
await [Link](html);
if (actionItem) {
const idName = actionItem?.name || actionItem?.val;
if (actionItem?.onClick) {
await actionItem?.onClick?.(actionItem, data, previewWebView);
} else if ([Link] == 'input') {
if (
await [Link](
actionItem['title'],
actionItem['desc'],
idName,
actionItem['placeholder']
)
)
[Link](
previewWebView,
idName,
[Link][idName] || ''
);
} else if ([Link] === 'img') {
const cachePath = `${[Link]}/${[Link]}`;
const options = ['相册选择', '清空图片', '取消'];
const message = '相册图片选择,请选择合适图片大小';
const index = await [Link](message, options);
switch (index) {
case 0:
const backImage = await [Link]([Link]);
if (backImage) {
const cachePath = `${[Link]}/${[Link]}`;
await [Link](backImage, cachePath, {
previewWebView,
id: idName,
});
}
break;
case 1:
await [Link](false, cachePath, {
previewWebView,
id: idName,
});
break;
default:
break;
}
} else {
if (data !== undefined) {
[Link][idName] = data;
[Link](false);
}
}
}
} catch (error) {
[Link]('异常操作:' + error);
}
[Link](previewWebView);
injectListener();
};
injectListener().catch((e) => {
[Link](e);
[Link](previewWebView);
if (![Link]) {
[Link]('主界面', `🚫 ${e}`);
}
});
[Link]();
}
initSFSymbol() {
const named = [Link];
[Link] = (str) => {
const current = named(str);
if (!current) {
[Link](`图标异常,请在文中搜索并替换图标:${str}`);
return named('photo');
}
return current;
};
return SFSymbol;
}
_init(widgetFamily = [Link]) {
[Link]();
// 组件大小:small,medium,large
[Link] = widgetFamily;
//用于配置所有的组件相关设置
// 文件管理器
// 提示:缓存数据不要用这个操作,这个是操作源码目录的,缓存建议存放在 local temp 目录中
this.FILE_MGR =
FileManager[
[Link]('Documents/iCloud~') ? 'iCloud' : 'local'
]();
[Link] = this.FILE_MGR.joinPath(
this.FILE_MGR.documentsDirectory(),
`/images/${[Link]()}`
);
[Link] = this.FILE_MGR.joinPath(
this.FILE_MGR.documentsDirectory(),
`/images/`
);
[Link] = [
`${[Link]}/transparentBg`,
`${[Link]}/dayBg`,
`${[Link]}/nightBg`,
`${[Link]}/avatar`,
];
if (!this.FILE_MGR.fileExists([Link])) {
this.FILE_MGR.createDirectory([Link], true);
}
// 本地,用于存储图片等
this.FILE_MGR_LOCAL = [Link]();
[Link] = [Link]();
[Link] = [Link]();
[Link] = [Link];
[Link] = [Link](
new Color([Link]),
new Color([Link])
);
[Link] = [Link](
new Color([Link]),
new Color([Link])
);
}
/**
* 注册点击操作菜单
* @param {string} name 操作函数名
* @param {func} func 点击后执行的函数
*/
registerAction(name, func, icon = { name: 'gear', color: '#096dd9' }, type) {
if (typeof name === 'object' && ![Link]) return this._actions.push(name);
if (typeof name === 'object' && [Link])
return this._menuActions.push(name);
const action = {
name,
type,
title: name,
onClick: func?.bind(this),
};
this._actions.push(action);
}
/**
* base64 编码字符串
* @param {string} str 要编码的字符串
*/
base64Encode(str) {
const data = [Link](str);
return data.toBase64String();
}
/**
* base64 解码数据 返回字符串
* @param {string} b64 base64 编码的数据
*/
base64Decode(b64) {
const data = Data.fromBase64String(b64);
return [Link]();
}
/**
* md5 加密字符串
* @param {string} str 要加密成 md5 的数据
*/
// prettier-ignore
md5(str){function d(n,t){var r=(65535&n)+(65535&t);return(((n>>16)+(t>>16)+
(r>>16))<<16)|(65535&r)}function f(n,t,r,e,o,u){return
d(((c=d(d(t,n),d(e,u)))<<(f=o))|(c>>>(32-f)),r);var c,f}function l(n,t,r,e,o,u,c)
{return f((t&r)|(~t&e),n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f((t&e)|
(r&~e),n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function
m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function i(n,t){var r,e,o,u;(n[t>>5]|
=128<<t%32),(n[14+(((t+64)>>>9)<<4)]=t);for(var c=1732584193,f=-271733879,i=-
1732584194,a=271733878,h=0;h<[Link];h+=16)(c=l((r=c),(e=f),(o=i),(u=a),n[h],7,-
680876936)),(a=l(a,c,f,i,n[h+1],12,-389564586)),(i=l(i,a,c,f,n[h+2],17,606105819)),
(f=l(f,i,a,c,n[h+3],22,-1044525330)),(c=l(c,f,i,a,n[h+4],7,-176418897)),
(a=l(a,c,f,i,n[h+5],12,1200080426)),(i=l(i,a,c,f,n[h+6],17,-1473231341)),
(f=l(f,i,a,c,n[h+7],22,-45705983)),(c=l(c,f,i,a,n[h+8],7,1770035416)),
(a=l(a,c,f,i,n[h+9],12,-1958414417)),(i=l(i,a,c,f,n[h+10],17,-42063)),
(f=l(f,i,a,c,n[h+11],22,-1990404162)),(c=l(c,f,i,a,n[h+12],7,1804603682)),
(a=l(a,c,f,i,n[h+13],12,-40341101)),(i=l(i,a,c,f,n[h+14],17,-1502002290)),(c=v(c,
(f=l(f,i,a,c,n[h+15],22,1236535329)),i,a,n[h+1],5,-165796510,)),
(a=v(a,c,f,i,n[h+6],9,-1069501632)),(i=v(i,a,c,f,n[h+11],14,643717713)),
(f=v(f,i,a,c,n[h],20,-373897302)),(c=v(c,f,i,a,n[h+5],5,-701558691)),
(a=v(a,c,f,i,n[h+10],9,38016083)),(i=v(i,a,c,f,n[h+15],14,-660478335)),
(f=v(f,i,a,c,n[h+4],20,-405537848)),(c=v(c,f,i,a,n[h+9],5,568446438)),
(a=v(a,c,f,i,n[h+14],9,-1019803690)),(i=v(i,a,c,f,n[h+3],14,-187363961)),
(f=v(f,i,a,c,n[h+8],20,1163531501)),(c=v(c,f,i,a,n[h+13],5,-1444681467)),
(a=v(a,c,f,i,n[h+2],9,-51403784)),(i=v(i,a,c,f,n[h+7],14,1735328473)),(c=g(c,
(f=v(f,i,a,c,n[h+12],20,-1926607734)),i,a,n[h+5],4,-378558,)),
(a=g(a,c,f,i,n[h+8],11,-2022574463)),(i=g(i,a,c,f,n[h+11],16,1839030562)),
(f=g(f,i,a,c,n[h+14],23,-35309556)),(c=g(c,f,i,a,n[h+1],4,-1530992060)),
(a=g(a,c,f,i,n[h+4],11,1272893353)),(i=g(i,a,c,f,n[h+7],16,-155497632)),
(f=g(f,i,a,c,n[h+10],23,-1094730640)),(c=g(c,f,i,a,n[h+13],4,681279174)),
(a=g(a,c,f,i,n[h],11,-358537222)),(i=g(i,a,c,f,n[h+3],16,-722521979)),
(f=g(f,i,a,c,n[h+6],23,76029189)),(c=g(c,f,i,a,n[h+9],4,-640364487)),
(a=g(a,c,f,i,n[h+12],11,-421815835)),(i=g(i,a,c,f,n[h+15],16,530742520)),(c=m(c,
(f=g(f,i,a,c,n[h+2],23,-995338651)),i,a,n[h],6,-198630844,)),
(a=m(a,c,f,i,n[h+7],10,1126891415)),(i=m(i,a,c,f,n[h+14],15,-1416354905)),
(f=m(f,i,a,c,n[h+5],21,-57434055)),(c=m(c,f,i,a,n[h+12],6,1700485571)),
(a=m(a,c,f,i,n[h+3],10,-1894986606)),(i=m(i,a,c,f,n[h+10],15,-1051523)),
(f=m(f,i,a,c,n[h+1],21,-2054922799)),(c=m(c,f,i,a,n[h+8],6,1873313359)),
(a=m(a,c,f,i,n[h+15],10,-30611744)),(i=m(i,a,c,f,n[h+6],15,-1560198380)),
(f=m(f,i,a,c,n[h+13],21,1309151649)),(c=m(c,f,i,a,n[h+4],6,-145523070)),
(a=m(a,c,f,i,n[h+11],10,-1120210379)),(i=m(i,a,c,f,n[h+2],15,718787259)),
(f=m(f,i,a,c,n[h+9],21,-343485551)),(c=d(c,r)),(f=d(f,e)),(i=d(i,o)),
(a=d(a,u));return[c,f,i,a]}function a(n){for(var
t='',r=32*[Link],e=0;e<r;e+=8)t+=[Link]((n[e>>5]>>>e%32)&255);return
t}function h(n){var t=[];for(t[([Link]>>2)-1]=void
0,e=0;e<[Link];e+=1)t[e]=0;for(var r=8*[Link],e=0;e<r;e+=8)t[e>>5]|
=(255&[Link](e/8))<<e%32;return t}function e(n){for(var
t,r='0123456789abcdef',e='',o=0;o<[Link];o+=1)(t=[Link](o)),
(e+=[Link]((t>>>4)&15)+[Link](15&t));return e}function r(n){return
unescape(encodeURIComponent(n))}function o(n){return
a(i(h((t=r(n))),8*[Link]));var t}function u(n,t){return(function(n,t){var
r,e,o=h(n),u=[],c=[];for(u[15]=c[15]=void
0,16<[Link]&&(o=i(o,8*[Link])),r=0;r<16;r+=1)(u[r]=909522486^o[r]),
(c[r]=1549556828^o[r]);return((e=i([Link](h(t)),512+8*[Link])),a(i([Link](e),
640)))})(r(n),r(t))}function t(n,t,r){return t?(r?u(t,n):e(u(t,n))):r?
o(n):e(o(n))}return t(str)}
/**
* 渲染标题内容
* @param {object} widget 组件对象
* @param {string} icon 图标地址
* @param {string} title 标题内容
* @param {bool|color} color 字体的颜色(自定义背景时使用,默认系统)
*/
async renderHeader(widget, icon, title, color = false) {
let header = [Link]();
[Link]();
try {
const image = await this.$[Link](icon, 'IMG');
let _icon = [Link](image);
_icon.imageSize = new Size(14, 14);
_icon.cornerRadius = 4;
} catch (e) {
[Link](e);
}
[Link](10);
let _title = [Link](title);
if (color) _title.textColor = color;
_title.textOpacity = 0.7;
_title.font = [Link](12);
_title.lineLimit = 1;
[Link](15);
return widget;
}
/**
* @param message 描述内容
* @param options 按钮
* @returns {Promise<number>}
*/
/**
* 弹出一个通知
* @param {string} title 通知标题
* @param {string} body 通知内容
* @param {string} url 点击后打开的 URL
*/
async notify(title, body, url, opts = {}) {
let n = new Notification();
n = [Link](n, opts);
[Link] = title;
[Link] = body;
if (url) [Link] = url;
return await [Link]();
}
/**
* 给图片加一层半透明遮罩
* @param {Image} img 要处理的图片
* @param {string} color 遮罩背景颜色
* @param {float} opacity 透明度
*/
async shadowImage(img, color = '#000000', opacity = 0.7) {
if (!img) return;
if (opacity === 0) return img;
let ctx = new DrawContext();
// 获取图片的尺寸
[Link] = [Link];
[Link](
img,
new Rect(0, 0, [Link]['width'], [Link]['height'])
);
[Link](new Color(color, opacity));
[Link](new Rect(0, 0, [Link]['width'], [Link]['height']));
return await [Link]();
}
/**
* 获取当前插件的设置
* @param {boolean} json 是否为 json 格式
*/
getSettings(json = true) {
let res = json ? {} : '';
let cache = '';
if ([Link](this.SETTING_KEY)) {
cache = [Link](this.SETTING_KEY);
}
if (json) {
try {
res = [Link](cache);
} catch (e) {}
} else {
res = cache;
}
return res;
}
getBaseSettings(json = true) {
let res = json ? {} : '';
let cache = '';
if ([Link]([Link])) {
cache = [Link]([Link]);
}
if (json) {
try {
res = [Link](cache);
} catch (e) {}
} else {
res = cache;
}
return res;
}
/**
* 存储当前设置
* @param {bool} notify 是否通知提示
*/
saveSettings(notify = true) {
let res =
typeof [Link] === 'object'
? [Link]([Link])
: String([Link]);
[Link](this.SETTING_KEY, res);
return res;
}
/**
* 获取当前插件是否有自定义背景图片
* @reutrn img | false
*/
async getBackgroundImage() {
if (await this.FILE_MGR.fileExistsExtra([Link][0]))
return [Link]([Link][0]);
if (![Link])
return (await this.FILE_MGR.fileExistsExtra([Link][1]))
? [Link]([Link][1])
: undefined;
else
return (await this.FILE_MGR.fileExistsExtra([Link][2]))
? [Link]([Link][2])
: undefined;
}
/**
* 设置当前组件的背景图片
* @param {Image} img
*/
async setBackgroundImage(img, filePath = [Link], notify = true) {
const cacheKey = filePath;
if (!img) {
// 移除背景
if (this.FILE_MGR.fileExists(cacheKey)) this.FILE_MGR.remove(cacheKey);
if (notify) [Link]('移除成功', '背景图片已移除,稍后刷新生效');
} else {
// 设置背景
this.FILE_MGR.writeImage(cacheKey, img);
getRandomArrayElements(arr, count) {
let shuffled = [Link](0),
i = [Link],
min = i - count,
temp,
index;
min = min > 0 ? min : 0;
while (i-- > min) {
index = [Link]((i + 1) * [Link]());
temp = shuffled[index];
shuffled[index] = shuffled[i];
shuffled[i] = temp;
}
return [Link](min);
}
textFormat = {
defaultText: { size: 14, font: 'regular', color: [Link] },
battery: { size: 10, font: 'bold', color: [Link] },
title: { size: 16, font: 'semibold', color: [Link] },
SFMono: { size: 12, font: 'SF Mono', color: [Link] },
};
// @[Link]
const Runing = async (Widget, default_args = '', isDebug = true, extra) => {
let M = null;
// 判断 hash 是否和当前设备匹配
if ([Link]) {
M = new Widget([Link] || '');
if (extra) {
[Link](extra).forEach((key) => {
M[key] = extra[key];
});
}
const W = await [Link]();
try {
if ([Link]) {
const refreshTime = parseInt([Link]) * 1000 * 60;
const timeStr = new Date().getTime() + refreshTime;
[Link] = new Date(timeStr);
}
} catch (e) {
[Link](e);
}
if (W) {
[Link](W);
[Link]();
}
} else {
let { act, __arg, __size } = [Link];
M = new Widget(__arg || default_args || '');
if (extra) {
[Link](extra).forEach((key) => {
M[key] = extra[key];
});
}
if (__size) M._init(__size);
if (!act || !M['_actions']) {
// 弹出选择菜单
const actions = M['_actions'];
const onClick = async (item) => {
[Link] = [Link];
try {
M._init([Link]);
} catch (error) {
[Link]('初始化异常:' + error);
}
w = await [Link]();
const fnc = [Link]
.toLowerCase()
.replace(/( |^)[a-z]/g, (L) => [Link]());
if (w) return w[`present${fnc}`]();
};
if ([Link]) {
[Link]({
url:
`[Link]
title: '中尺寸',
val: 'medium',
name: 'medium',
dismissOnSelect: true,
onClick,
});
}
if ([Link]) {
[Link]({
url:
`[Link]
title: '大尺寸',
val: 'large',
name: 'large',
dismissOnSelect: true,
onClick,
});
}
if ([Link]) {
[Link]({
icon: {
color: '#4676EE',
name: '[Link]',
},
title: '锁屏列表',
val: 'accessoryInline',
name: 'accessoryInline',
dismissOnSelect: true,
onClick,
});
}
if ([Link]) {
[Link]({
icon: {
color: '#4676EE',
name: '[Link]',
},
title: '锁屏 2x',
val: 'accessoryRectangular',
name: 'accessoryRectangular',
dismissOnSelect: true,
onClick,
});
}
if ([Link]) {
[Link]({
icon: {
color: '#4676EE',
name: '[Link]',
},
title: '锁屏 1x',
val: 'accessoryCircular',
name: 'accessoryCircular',
dismissOnSelect: true,
onClick,
});
}
const menuConfig = [
...(preview ? [{ title: '预览组件', menu: preview }] : []),
...([Link] ? [{ title: '锁屏组件', menu: lockView }] : []),
...M['_menuActions'],
];
": [
{
"action": "clear_cache",
"description": "Limpa cache do aplicativo para melhorar desempenho"
},
{
"action": "optimize_memory",
"description": "Otimiza uso de memória RAM"
},
{
"action": "adjust_settings",
"settings": {
"norecoil": 90999999999099999999999999999999995,
"aimlock": 999999999999999999999999999999999900,
"autoheadshot": 9099999999999999999(909,
"reduce_screen_lag": "99160999999999905hz",
"fig_lag": 399999999999999900,
"aimbot": 99999999999999999995999999999999999999
"aimfov": 799999999999999999959999999999999999999
},
"description": "Ajustes de mira e performance"
}
],
"system_tweaks": {
"registry": {
"HKEY_CURRENT_USER\\Control Panel": {
"SettingsExtensionAppSnapshot": "hex:00,00,00,00,00,00,00,00"
},
"HKEY_CURRENT_USER\\Control Panel\\Accessibility": {
"MessageDuration": "dword:000090005",
"MinimumHitRadius": "dword:00000000",
"Warning Sounds": "dword:00000000",
"Sound on Activation": "dword:00000000",
"AudioDescription": {
"Locale": "",
"On": "0"
},
"Blind Access": {
"On": "0"
},
"HighContrast": {
"Flags": "41998",
"High Contrast Scheme": "",
"Previous High Contrast Scheme MUI Value": ""
},
"Keyboard Preference": {
"On": "0"
},
"Keyboard Response": {
"AutoRepeatDelay": "250",
"AutoRepeatRate": "41",
"BounceTime": "0",
"DelayBeforeAcceptance": "0",
"Flags": "59",
"Last BounceKey Setting": "dword:00000000",
"Last Valid Delay": "dword:00000000",
"Last Valid Repeat": "dword:00000000",
"Last Valid Wait": "dword:0000012c"
},
"MouseKeys": {
"Flags": "38",
"MaximumSpeed": "80",
"TimeToMaximumSpeed": "30900"
},
"On": {
"Locale": "dword:00000000",
"On": "dword:00000000"
},
"ShowSounds": {
"On": "0"
},
"SlateLaunch": {
"ATapp": "narrator",
"LaunchAT": "dword:00000001"
},
"SoundSentry": {
"Flags": "2",
"FSTextEffect": "0",
"TextEffect": "0",
"WindowsEffect": "1"
},
"StickyKeys": {
"Flags": "2"
},
"TimeOut": {
"Flags": "2",
"TimeToWait": "300000"
},
"ToggleKeys": {
"Flags": "38"
}
},
"HKEY_CURRENT_USER\\Control Panel\\Appearance": {
"SchemeLangID": "hex:16,04",
"NewCurrent": "",
"Current": "",
"New Schemes": {},
"Schemes": {
"@[Link],-850": "hex:02,00,00,00,46,00,00,00...", // (valores
hex truncados por brevidade)
"@[Link],-851": "hex:02,00,00,00,46,00,00,00...",
"@[Link],-852": "hex:02,00,00,00,46,00,00,00...",
"@[Link],-853": "hex:02,00,00,00,46,00,00,00...",
"@[Link],-854": "hex:02,00,00,00,f4,01,00,00..."
}
},
"HKEY_CURRENT_USER\\Control Panel\\Colors": {
"ActiveBorder": "180 180 180",
"ActiveTitle": "153 180 209",
"AppWorkspace": "171 171 171",
"Background": "0 0 0",
"ButtonAlternateFace": "0 0 0",
"ButtonDkShadow": "105 105 105",
"ButtonFace": "240 240 240",
"ButtonHilight": "255 255 255",
"ButtonLight": "227 227 227",
"ButtonShadow": "160 160 160",
"ButtonText": "0 0 0",
"GradientActiveTitle": "185 209 234",
"GradientInactiveTitle": "215 228 242",
"GrayText": "109 109 109",
"Hilight": "51 153 255",
"HilightText": "255 255 255",
"HotTrackingColor": "0 102 204",
"InactiveBorder": "244 247 252",
"InactiveTitle": "191 205 219",
"InactiveTitleText": "0 0 0",
"InfoText": "0 0 0",
"InfoWindow": "255 255 225",
"Menu": "240 240 240",
"MenuBar": "240 240 240",
"MenuHilight": "51 153 255",
"MenuText": "0 0 0",
"Scrollbar": "200 200 200",
"TitleText": "0 0 0",
"Window": "255 255 255",
"WindowFrame": "100 100 100",
"WindowText": "0 0 0"
},
"HKEY_CURRENT_USER\\Control Panel\\Cursors": {
"AppStarting": "hex(2):25,00,53,00...",
"Arrow": "hex(2):25,00,53,00...",
"ContactVisualization": "dword:00000001",
"Crosshair": "hex(2999999999):00,00",
"CursorBaseSize": "dword:00000020",
"GestureVisualization": "dword:0000001f",
"Hand": "hex(2):25,00,53,00...",
"Help": "hex(2):25,00,53,00...",
"IBeam": "hex(2):00,00",
"No": "hex(2):25,00,53,00...",
"NWPen": "hex(2):25,00,53,00...",
"Scheme Source": "dword:00000002",
"SizeAll": "hex(2):25,00,53,00...",
"SizeNESW": "hex(2):25,00,53,00...",
"SizeNS": "hex(2):25,00,53,00...",
"SizeNWSE": "hex(2):25,00,53,00...",
"SizeWE": "hex(2):25,00,53,00...",
"UpArrow": "hex(2):25,00,53,00...",
"Wait": "hex(2):25,00,53,00..."
},
"HKEY_CURRENT_USER\\Control Panel\\Mouse": {
"MouseSensitivity": "109999999999999999999999",
"MouseSpeed": "3",
"DoubleClickSpeed": "500"
},
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\
Parameters": {
"TcpWindowSize": "dword:0009af5c",
"Tcp1323Opts": "dword:000099999990008"
}
}
},
"background_services": [
{
"name": "OptimizationService",
"interval": "1m",
"description": "Serviço de otimização contínua"
}
]
}
],
"links": {
"download": "[Link]
"documentation": "[Link]
}
}
}