Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
enoyee
Scriptable
提交
2a783c55
S
Scriptable
项目概览
enoyee
/
Scriptable
通知
9
Star
0
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Scriptable
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2a783c55
编写于
12月 11, 2022
作者:
AndroidLeaves
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
fa6f4704
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
61 addition
and
42 deletion
+61
-42
TopHub榜单.js
TopHub榜单.js
+57
-37
_LSP.js
_LSP.js
+4
-5
未找到文件。
TopHub榜单.js
浏览文件 @
2a783c55
...
...
@@ -28,7 +28,7 @@ class Widget extends BaseWidget {
defaultPreference
=
{
domain
:
'
https://tophub.today
'
,
hotban
:
{
title
:
'
微博 · 热搜榜
'
,
link
:
'
https://tophub.today/n/KqndgxeLl9
'
}
,
hotban
:
[{
title
:
'
微博 · 热搜榜
'
,
link
:
'
https://tophub.today/n/KqndgxeLl9
'
}]
,
weiboOpenOptions
:
[
{
name
:
'
国内版
'
},
{
name
:
'
国际版
'
},
...
...
@@ -57,7 +57,7 @@ class Widget extends BaseWidget {
largeItemCount
:
13
};
getHotban
=
(
)
=>
JSON
.
parse
(
this
.
useFileManager
().
readStringCache
(
'
hotban
'
)
??
JSON
.
stringify
(
this
.
defaultPreference
.
hotban
));
getHotban
=
(
defaultValue
)
=>
JSON
.
parse
(
this
.
useFileManager
().
readStringCache
(
'
hotban
'
)
??
(
defaultValue
?
defaultValue
:
JSON
.
stringify
(
this
.
defaultPreference
.
hotban
)
));
getWeiboOpenType
=
()
=>
this
.
getSettingValueByKey
(
'
weiboOpenType
'
,
this
.
defaultPreference
.
weiboOpenOptions
[
2
].
name
);
getTitleFontSize
=
()
=>
Number
(
this
.
getSettingValueByKey
(
'
titleFontSize
'
,
`
${
this
.
defaultPreference
.
titleFontSize
}
`
));
getTitleFontColor
=
()
=>
this
.
getSettingValueByKey
(
'
titleFontColor
'
,
`
${
this
.
defaultPreference
.
titleFontColor
}
`
);
...
...
@@ -261,9 +261,6 @@ class Widget extends BaseWidget {
}
});
////////////////////////////////////
const
{
title
,
link
}
=
event
;
await
this
.
generateAlert
(
`热榜内容`
,
`已成功添加«
${
title
}
»\n关闭窗口点击预览查看效果`
,
[
'
确定
'
]);
this
.
useFileManager
().
writeStringCache
(
'
hotban
'
,
JSON
.
stringify
({
title
,
link
:
`
${
this
.
defaultPreference
.
domain
}${
link
}
`
}));
onItemClick
?.(
event
);
}
...
...
@@ -285,11 +282,11 @@ class Widget extends BaseWidget {
settingItems
:
[
{
name
:
'
hotban
'
,
label
:
'
热搜榜
搜索
'
,
label
:
'
热搜榜
设置
'
,
type
:
'
cell
'
,
icon
:
{
name
:
'
flame
'
,
color
:
'
#EB3323
'
,
},
needLoading
:
true
,
default
:
this
.
getHotban
().
titl
e
,
showDesc
:
fals
e
,
},
{
name
:
'
weiboOpenType
'
,
...
...
@@ -403,19 +400,29 @@ class Widget extends BaseWidget {
let
insertDesc
;
switch
(
item
.
name
)
{
case
'
hotban
'
:
await
this
.
generateInputAlert
({
title
:
'
热榜搜索
'
,
options
:
[{
hint
:
'
请输入关键字
'
,
value
:
''
}]
},
async
(
inputArr
)
=>
{
const
keyword
=
inputArr
[
0
].
value
;
let
response
=
undefined
;
try
{
//////
const
html
=
await
this
.
httpGet
(
`
${
this
.
defaultPreference
.
domain
}
/search?q=
${
encodeURIComponent
(
keyword
)}
`
,
{
jsonFormat
:
false
,
headers
:
this
.
defaultPreference
.
phoneHeaders
});
let
webview
=
new
WebView
();
await
webview
.
loadHTML
(
html
);
// 通过dom操作把HTML里面的热榜内容提取出来
const
getData
=
`
const
hotSelectIndex
=
await
this
.
presentSheet
({
title
:
'
热榜设置
'
,
message
:
'
⊱配置热榜显示榜单内容⊰
'
,
options
:
[{
name
:
'
查看已添加榜单
'
},
{
name
:
'
搜索添加榜单
'
},
{
name
:
'
重置榜单
'
}],
});
if
(
hotSelectIndex
==
0
)
{
const
hotbanArr
=
this
.
getHotban
(
'
[]
'
);
const
hotbanTitleArr
=
hotbanArr
.
map
(
hotban
=>
hotban
.
title
);
await
this
.
generateAlert
(
'
已添加榜单
'
,
`
${
hotbanTitleArr
.
length
>
0
?
hotbanTitleArr
.
join
(
'
、
'
)
:
'
暂无添加,默认微博热搜
'
}
`
,
[
'
确定
'
]);
}
else
if
(
hotSelectIndex
==
1
)
{
await
this
.
generateInputAlert
({
title
:
'
热榜搜索
'
,
options
:
[{
hint
:
'
请输入关键字
'
,
value
:
''
}]
},
async
(
inputArr
)
=>
{
const
keyword
=
inputArr
[
0
].
value
;
let
response
=
undefined
;
try
{
//////
const
html
=
await
this
.
httpGet
(
`
${
this
.
defaultPreference
.
domain
}
/search?q=
${
encodeURIComponent
(
keyword
)}
`
,
{
jsonFormat
:
false
,
headers
:
this
.
defaultPreference
.
phoneHeaders
});
let
webview
=
new
WebView
();
await
webview
.
loadHTML
(
html
);
// 通过dom操作把HTML里面的热榜内容提取出来
const
getData
=
`
function getData() {
// 图片封面
coverArr = []
...
...
@@ -449,22 +456,31 @@ class Widget extends BaseWidget {
}
getData()
`
// 热榜数据
response
=
await
webview
.
evaluateJavaScript
(
getData
,
false
);
const
{
linkArr
=
[]
}
=
response
;
if
(
linkArr
.
length
===
0
)
{
await
this
.
generateAlert
(
'
热榜搜索
'
,
'
搜索结果为空
'
,
[
'
确定
'
]);
}
else
{
await
this
.
renderSearchResultView
(
response
,
()
=>
{
this
.
rerunWidget
();
});
}
//////
}
catch
(
error
)
{
console
.
error
(
`🚫 热榜搜索出错===>
${
error
}
`
);
await
this
.
generateAlert
(
'
🚫 热榜搜索出错
'
,
`
${
error
}
`
,
[
'
确定
'
]);
};
});
// 热榜数据
response
=
await
webview
.
evaluateJavaScript
(
getData
,
false
);
const
{
linkArr
=
[]
}
=
response
;
if
(
linkArr
.
length
===
0
)
{
await
this
.
generateAlert
(
'
热榜搜索
'
,
'
搜索结果为空
'
,
[
'
确定
'
]);
}
else
{
await
this
.
renderSearchResultView
(
response
,
async
(
event
)
=>
{
const
{
title
,
link
}
=
event
;
await
this
.
generateAlert
(
`热榜内容`
,
`已成功添加«
${
title
}
»\n关闭窗口重新运行`
,
[
'
确定
'
]);
const
hotbanArr
=
this
.
getHotban
(
'
[]
'
);
hotbanArr
.
push
({
title
,
link
:
`
${
this
.
defaultPreference
.
domain
}${
link
}
`
});
this
.
useFileManager
().
writeStringCache
(
'
hotban
'
,
JSON
.
stringify
(
hotbanArr
));
this
.
rerunWidget
();
});
}
//////
}
catch
(
error
)
{
console
.
error
(
`🚫 热榜搜索出错==>
${
error
}
`
);
await
this
.
generateAlert
(
'
🚫 热榜搜索出错
'
,
`
${
error
}
`
,
[
'
确定
'
]);
};
});
}
else
{
this
.
useFileManager
().
writeStringCache
(
'
hotban
'
,
JSON
.
stringify
([]));
await
this
.
generateAlert
(
'
热榜设置
'
,
'
热榜已重置成功
'
,
[
'
确定
'
]);
}
break
;
case
'
weiboOpenType
'
:
...
...
@@ -530,7 +546,11 @@ class Widget extends BaseWidget {
}
async
provideWidget
(
itemCount
,
small
=
false
)
{
const
response
=
await
this
.
loadHotBanRES
(
this
.
getHotban
().
link
);
const
defaultHotArr
=
this
.
defaultPreference
.
hotban
;
const
cacheHotStr
=
this
.
useFileManager
().
readStringCache
(
'
hotban
'
);
const
hotbanArr
=
cacheHotStr
?
JSON
.
parse
(
cacheHotStr
)
:
defaultHotArr
;
const
index
=
this
.
carouselIndex
(
'
hotbanRandom
'
,
hotbanArr
.
length
);
const
response
=
await
this
.
loadHotBanRES
(
hotbanArr
[
index
].
link
);
// 数据
const
{
hotTitle
=
''
,
logoUrl
=
''
,
linkArr
=
[],
titleArr
=
[]
}
=
response
;
//=================================
...
...
_LSP.js
浏览文件 @
2a783c55
...
...
@@ -1042,16 +1042,15 @@ class BaseWidget {
}
}
carouselIndex
=
(
cacheKey
,
size
,
root
=
false
)
=>
{
carouselIndex
=
(
cacheKey
,
size
)
=>
{
let
index
=
-
1
;
const
fullName
=
this
.
useFileManager
().
fullFileName
(
cacheKey
,
root
);
if
(
Keychain
.
contains
(
fullName
))
{
let
cacheString
=
this
.
keyGet
(
fullName
);
if
(
Keychain
.
contains
(
cacheKey
))
{
let
cacheString
=
this
.
keyGet
(
cacheKey
);
index
=
parseInt
(
cacheString
);
}
index
=
index
+
1
;
index
=
index
%
size
;
this
.
keySave
(
fullName
,
`
${
index
}
`
)
this
.
keySave
(
cacheKey
,
`
${
index
}
`
)
return
index
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录