提交 384fc168 编写于 作者: AndroidLeaves's avatar AndroidLeaves

update

上级 240bbe1e
......@@ -3,11 +3,11 @@
// icon-color: red; icon-glyph: user-astronaut;
/**
* Author:LSP
* Date:2022-12-13
* Date:2022-12-15
*/
// -------------------------------------------------------
// 是否是开发环境,配合手机端调试使用,正式发布设置为false
const isDev = false;
const isDev = true;
console.log(`开发环境 👉👉👉👉👉 ${isDev ? 'DEV' : 'RELEASE'}`);
console.log(`----------------------------------------`);
const remoteRoot = 'https://gitcode.net/enoyee/scriptable/-/raw/master/';
......@@ -27,7 +27,7 @@ const { BaseWidget } = require(dependencyFileName);
class Widget extends BaseWidget {
defaultPreference = {
version: 20221213_3,
version: 20221215,
domain: 'https://tophub.today',
hotban: [{ title: '微博 · 热搜榜', link: 'https://tophub.today/n/KqndgxeLl9' }],
weiboOpenOptions: [
......@@ -50,35 +50,32 @@ class Widget extends BaseWidget {
largeItemCount: 13
};
async getCookie() {
getCookie() {
let cookie = '';
const { hotbanCK } = this.readWidgetSetting();
if (hotbanCK?.length > 0) {
const hotbanCKArr = hotbanCK.split(";");
if (hotbanCKArr.length !== 3) {
await this.generateAlert('TopHub添加cookie', `添加的cookie不符合要求,需要登录后的cookie`, ['确定']);
} else {
let itc_center_user;
let Hm_lvt;
let Hm_lpvt;
//
hotbanCKArr.forEach(element => {
if (element.indexOf('Hm_lvt') != -1) {
let index = element.lastIndexOf("=");
Hm_lvt = element.slice(0, index - 1)
Hm_lvt += `=${Math.round(new Date() / 1000)}`
} else if (element.indexOf('Hm_lpvt') != -1) {
let index = element.lastIndexOf("=");
Hm_lpvt = element.slice(0, index - 1)
Hm_lpvt += `=${Math.round(new Date() / 1000) - 86400 * Math.ceil(Math.random() * 6)},${Math.round(new Date() / 1000) - 86400 * Math.ceil(Math.random() * 3)}`
} else if (element.startsWith('itc_center_user')) {
itc_center_user = element;
}
});
//
cookie = (itc_center_user + ";" + Hm_lvt + ";" + Hm_lpvt);
}
let itc_center_user;
let Hm_lvt;
let Hm_lpvt;
//
hotbanCKArr.forEach(element => {
if (element.indexOf('Hm_lvt') != -1) {
let index = element.lastIndexOf("=");
Hm_lvt = element.slice(0, index - 1)
Hm_lvt += `=${Math.round(new Date() / 1000)}`
} else if (element.indexOf('Hm_lpvt') != -1) {
let index = element.lastIndexOf("=");
Hm_lpvt = element.slice(0, index - 1)
Hm_lpvt += `=${Math.round(new Date() / 1000) - 86400 * Math.ceil(Math.random() * 6)},${Math.round(new Date() / 1000) - 86400 * Math.ceil(Math.random() * 3)}`
} else if (element.startsWith('itc_center_user')) {
itc_center_user = element;
}
});
//
cookie = (itc_center_user + ";" + Hm_lvt + ";" + Hm_lpvt);
}
console.log(`cookie-->${cookie}`);
return cookie;
}
......@@ -91,6 +88,10 @@ class Widget extends BaseWidget {
getContentLineSpacing = () => Number(this.getSettingValueByKey('contentLineSpacing', `${this.defaultPreference.contentLineSpacing}`));
getNormalItemCount = () => Number(this.getSettingValueByKey('normalItemCount', `${this.defaultPreference.normalItemCount}`));
getLargeItemCount = () => Number(this.getSettingValueByKey('largeItemCount', `${this.defaultPreference.largeItemCount}`));
getCKDesc = () => {
let hasCK = this.getCookie()?.length > 0;
return hasCK ? '已设置' : '未设置'
};
constructor(scriptName) {
super(scriptName);
......@@ -317,7 +318,7 @@ class Widget extends BaseWidget {
name: 'weiboOpenType',
label: '微博打开方式',
type: 'cell',
icon: 'https://s3.uuu.ovh/imgs/2022/12/10/b868456095655916.png',
icon: 'https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic_weibo.png',
needLoading: false,
default: this.getWeiboOpenType(),
},
......@@ -343,7 +344,7 @@ class Widget extends BaseWidget {
}
]
},
showDesc: false,
desc: this.getCKDesc()
},
{
name: 'titleFontSize',
......@@ -706,6 +707,16 @@ class Widget extends BaseWidget {
}
// --------------------------NET START--------------------------
async loadHTML(url) {
let req = new Request(url);
req.headers = {
"cookie": this.getCookie(),
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
};
let html = await req.loadString();
return html.replace(/(\r\n|\n|\r)/gm, "");
}
async loadHotBanRES(link) {
// 热榜数据
let response = undefined;
......@@ -723,12 +734,11 @@ class Widget extends BaseWidget {
const shouldLoadCache = timeInterval <= Number(refreshInterval) && canUseCache;
let html = ufm.readStringCache(cacheFileName);
if (!shouldLoadCache) {
console.log(`-->>在线加载网页数据`);
await webview.loadURL(link);
html = await webview.getHTML();
console.log(`-->>在线加载网页数据:${link}`);
html = await this.loadHTML(link);
ufm.writeStringCache(cacheFileName, html);
} else {
console.log(`-->>加载缓存网页数据`);
console.log(`-->>加载缓存网页数据${link}`);
}
await webview.loadHTML(html);
// 通过dom操作把HTML里面的热榜内容提取出来
......@@ -901,4 +911,4 @@ async function downloadFile2Scriptable(moduleName, url) {
};
// =================================================================================
// =================================================================================
\ No newline at end of file
// =================================================================================
......@@ -8,7 +8,7 @@
*/
// 当前环境版本号
const VERSION = 20221212
const VERSION = 20221214
// 组件配置文件名
const settingConfigName = 'settings.json';
// 组件默认配置
......@@ -2132,7 +2132,7 @@ class BaseWidget {
const formData = {};
const fragment = document.createDocumentFragment()
for (const item of settingItems) {
const value = settings[item.name] ?? item.default ?? null
const value = item.desc ?? settings[item.name] ?? item.default ?? null
if(value && item.type != 'cell') {
formData[item.name] = value;
}
......
此差异已折叠。
......@@ -214,7 +214,7 @@ class Widget extends BaseWidget {
const calendar = await Calendar.forReminders();
const originalRdList = await Reminder.all(calendar);
const filterList = originalRdList.filter(item => {
const { isCompleted, dueDate } = item;
const { isCompleted } = item;
const date = item.dueDate ? this.getDateStr(item.dueDate, 'yyyy-MM-dd') : '';
const currDate = this.getDateStr(new Date(), 'yyyy-MM-dd')
return date == currDate || (!isCompleted && date < currDate);
......
......@@ -3,7 +3,7 @@
// icon-color: red; icon-glyph: user-astronaut;
/**
* Author:LSP
* Date:2022-12-10
* Date:2022-12-15
*/
// -------------------------------------------------------
// 是否是开发环境,配合手机端调试使用,正式发布设置为false
......@@ -97,7 +97,7 @@ class Widget extends BaseWidget {
name: 'caiyun',
label: '彩云key',
type: 'cell',
icon: 'https://s3.uuu.ovh/imgs/2022/12/05/a95f9edce36891d9.gif',
icon: 'https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic_weather_loop.gif',
alert: {
title: '彩云key',
message: "外部已使用默认key\\n如果不可用了需要自己去申请填入替换",
......@@ -206,7 +206,7 @@ class Widget extends BaseWidget {
name: 'dateFontSize',
label: '日期文字大小',
type: 'cell',
icon: 'https://s3.uuu.ovh/imgs/2022/12/05/ac2c5b8843ff2719.gif',
icon: 'https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic_calendar.gif',
needLoading: false,
alert: {
title: '日期文字大小',
......@@ -223,7 +223,7 @@ class Widget extends BaseWidget {
name: 'dateFontColor',
label: '日期文字颜色',
type: 'color',
icon: 'https://s3.uuu.ovh/imgs/2022/12/05/ac2c5b8843ff2719.gif',
icon: 'https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic_calendar.gif',
needLoading: false,
default: this.dateFontColor(),
},
......@@ -231,7 +231,7 @@ class Widget extends BaseWidget {
name: 'weatherFontSize',
label: '天气文字大小',
type: 'cell',
icon: 'https://s3.uuu.ovh/imgs/2022/12/05/a95f9edce36891d9.gif',
icon: 'https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic_weather_loop.gif',
needLoading: false,
alert: {
title: '天气文字大小',
......@@ -248,7 +248,7 @@ class Widget extends BaseWidget {
name: 'weatherFontColor',
label: '天气文字颜色',
type: 'color',
icon: 'https://s3.uuu.ovh/imgs/2022/12/05/a95f9edce36891d9.gif',
icon: 'https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic_weather_loop.gif',
needLoading: false,
default: this.weatherFontColor(),
},
......@@ -256,7 +256,7 @@ class Widget extends BaseWidget {
name: 'covFontSize',
label: '疫情文字大小',
type: 'cell',
icon: 'https://s3.uuu.ovh/imgs/2022/12/05/2cd3dee47cd0824f.png',
icon: 'https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic_corona_virus.png',
needLoading: false,
alert: {
title: '疫情文字大小',
......@@ -273,7 +273,7 @@ class Widget extends BaseWidget {
name: 'covFontColor',
label: '疫情文字颜色',
type: 'color',
icon: 'https://s3.uuu.ovh/imgs/2022/12/05/2cd3dee47cd0824f.png',
icon: 'https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic_corona_virus.png',
needLoading: false,
default: this.covFontColor(),
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册