提交 23674ec5 编写于 作者: AndroidLeaves's avatar AndroidLeaves

update 榜单登录

上级 2f5793e2
......@@ -3,7 +3,7 @@
// icon-color: red; icon-glyph: user-astronaut;
/**
* Author:LSP
* Date:2022-12-15
* Date:2022-12-22
*/
// -------------------------------------------------------
// 是否是开发环境,配合手机端调试使用,正式发布设置为false
......@@ -50,32 +50,10 @@ class Widget extends BaseWidget {
};
getCookie() {
let cookie = '';
const { hotbanCK } = this.readWidgetSetting();
if (hotbanCK?.length > 0) {
const hotbanCKArr = hotbanCK.split(";");
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);
}
const { cookie } = this.readWidgetSetting();
this.logDivider();
console.log(`TopHub的cookie-->${cookie}`);
this.logDivider();
console.log(`cookie-->${cookie}`);
return cookie;
}
......@@ -90,7 +68,7 @@ class Widget extends BaseWidget {
getLargeItemCount = () => Number(this.getSettingValueByKey('largeItemCount', `${this.defaultPreference.largeItemCount}`));
getCKDesc = () => {
let hasCK = this.getCookie()?.length > 0;
return hasCK ? '设置' : '未设置'
return hasCK ? '登录' : '未登录'
};
constructor(scriptName) {
......@@ -304,6 +282,14 @@ class Widget extends BaseWidget {
},
// 预览界面的组件设置item
settingItems: [
{
name: 'hotbanCK',
label: '登录TopHub',
type: 'cell',
icon: 'https://file.ipadown.com/tophub/assets/images/logo.png',
needLoading: true,
desc: this.getCKDesc()
},
{
name: 'hotban',
label: '热搜榜设置',
......@@ -327,23 +313,6 @@ class Widget extends BaseWidget {
icon: 'https://gitcode.net/4qiao/framework/raw/master/img/icon/setting.gif',
needLoading: true,
childItems: [
{
name: 'hotbanCK',
label: 'TopHub的cookie',
type: 'cell',
icon: { name: 'person.crop.circle.badge.clock', color: '#80b918', },
needLoading: false,
alert: {
title: 'TopHub登录的cookie',
options: [
{
key: 'hotbanCK',
hint: '请输入cookie',
}
]
},
desc: this.getCKDesc()
},
{
name: 'titleFontSize',
label: '标题文字大小',
......@@ -440,6 +409,17 @@ class Widget extends BaseWidget {
let widgetSetting = this.readWidgetSetting();
let insertDesc;
switch (item.name) {
case 'hotbanCK':
const url = "https://tophub.today/login";
const webview = new WebView();
await webview.loadURL(url);
await webview.present();
const cookie = await webview.evaluateJavaScript("document.cookie");
console.log(`登录成功,获取到的ck:${cookie}`);
widgetSetting.cookie = cookie;
insertDesc = cookie?.length > 0 ? '已登录' : '未登录';
break;
case 'hotban':
const hotSelectIndex = await this.presentSheet({
title: '热榜设置',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册