优化RSS相关细节

This commit is contained in:
Easy
2022-08-10 01:22:57 +08:00
parent bc6cf4fb97
commit b95b06d619
17 changed files with 148 additions and 68 deletions
+3 -3
View File
@@ -12,9 +12,9 @@
## 最新版本
- 插件·Chrome/Edge2022.08.01.15.59 [下载](ckc.zip) ([Github下载地址,无需注册](https://github.com/easychen/checkchan-dist/raw/master/ckc.zip))
- Docker镜像(云端+远程桌面二合一)2022.08.01.15.50 [Docker Hub](https://hub.docker.com/repository/docker/easychen/checkchan)
- 文档:2022.08.01.15.59
- 插件·Chrome/Edge2022.08.10.01.22 [下载](ckc.zip) ([Github下载地址,无需注册](https://github.com/easychen/checkchan-dist/raw/master/ckc.zip))
- Docker镜像(云端+远程桌面二合一)2022.08.10.00.19 [Docker Hub](https://hub.docker.com/repository/docker/easychen/checkchan)
- 文档:2022.08.10.01.22
- 更新日志:[GitHub](https://github.com/easychen/checkchan-dist/commits/main)
- 生态:RSSHub浏览器插件整合版([源码](https://github.com/easychen/RSSHub-Radar-with-checkchan) | [下载](https://github.com/easychen/RSSHub-Radar-with-checkchan/releases/download/main/1.7.0.with-checkchan.zip)
+1 -1
View File
@@ -1 +1 @@
"2022.08.01.15.59"
"2022.08.10.01.22"
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
"2022.08.01.15.50"
"2022.08.10.00.19"
+7 -6
View File
@@ -56,6 +56,7 @@ for( const item of to_checks )
let check_content = "";
let check_html = "";
let check_link = "";
let check_data = "";
logit("checking..."+item.title, dayjs().format('YYYY-MM-DD HH:mm:ss'));
@@ -65,11 +66,12 @@ for( const item of to_checks )
check_content = ret.value;
// 添加正则替换
if( item.replace_from_regex && item.replace_from_regex ) check_content = check_content.replace( new RegExp(item.replace_from_regex), item.replace_to_regex );
if( item.replace_from_regex && item.replace_to_regex ) check_content = check_content.replace( new RegExp(item.replace_from_regex), item.replace_to_regex );
if( ret.html ) check_html = ret.html;
if( ret.link ) check_link = ret.link;
if( ret.data ) check_data = ret.data;
check_status = 1;
}
@@ -87,7 +89,7 @@ for( const item of to_checks )
if( retry_times >= item.retry )
{
// 发送通知
await send_notify( '监测['+item.title+']多次重试失败', "已暂停执行,请检查登录状态或页面结构变动。点击任务的监测按钮可以解除暂停\r\n\r\n[点此查看]("+item.url+")" , item.sendkey, item.send_channel||-1);
await send_notify( '监测任务['+item.title+']多次重试失败', "已暂停执行,请检查登录状态或页面结构变动。点击任务的监测按钮可以解除暂停\r\n\r\n[点此查看]("+item.url+")" , item.sendkey, item.send_channel||-1);
}
check_update_field( item.id, 'retry_times', retry_times+1, json_data );
@@ -138,7 +140,6 @@ for( const item of to_checks )
if( item.compare_value == '*上次监测返回值*' ) the_value = last_content;
if( item.compare_op == 'ne' && !(check_content != the_value)) can_send_notice = false;
if( item.compare_op == 'eq' && !(check_content == the_value)) can_send_notice = false;
@@ -163,11 +164,11 @@ for( const item of to_checks )
{
logit( '已发送通知' );
await do_webhook( item.id, item.url, check_content, check_html, check_link || item.page || item.url );
await do_webhook( item.id, item.url, check_content, check_html, check_link || item.page || item.url, check_data );
if( item.sendkey )
{
const title = '监测['+item.title+']有新通知';
const title = '监测任务['+item.title+']有新通知';
let desp = short(check_content,50) + (last_content && item.when == 'change' ? ('←' + short(last_content,50)):"");
@@ -186,7 +187,7 @@ for( const item of to_checks )
}
}
// const title = check_content.length > 50 ? '监测['+item.title+']有新通知' : ( '监测['+item.title+']有新通知: ' + check_content + (item.last_content ? ('←' + item.last_content):"") );
// const title = check_content.length > 50 ? '监测任务['+item.title+']有新通知' : ( '监测任务['+item.title+']有新通知: ' + check_content + (item.last_content ? ('←' + item.last_content):"") );
// const desp = check_content.length > 50 ? (check_html ? to_markdown(check_html) : check_content) : check_content + (item.last_content ? ('←' + item.last_content):"") ;
+8 -7
View File
@@ -174,7 +174,7 @@ exports.get_cookies = () =>
return json_data.cookies;
}
exports.do_webhook = async( id, url, value, html, link ) =>
exports.do_webhook = async( id, url, value, html, link, data ) =>
{
// 因为webhook的内容更多,所以不能放到 show_notice 里边处理,这里单独处理
if( process.env.WEBHOOK_URL )
@@ -186,6 +186,7 @@ exports.do_webhook = async( id, url, value, html, link ) =>
form.append( 'value',value );
form.append( 'html',html );
form.append( 'link',link );
form.append( 'data',data );
try {
const response = await fetch( process.env.WEBHOOK_URL , {
@@ -335,7 +336,7 @@ async function monitor_rss(url,timeout=10000)
async function monitor_dom_low(item, cookies)
{
const { url, path, delay, ignore_path,click_path,scroll_down } = item;
const { url, path, delay, ignore_path,click_path,data_path,scroll_down } = item;
console.log("in low dom");
try {
const response = await fetch( url, { signal: timeoutSignal(delay<1?10000:delay) } );
@@ -436,7 +437,7 @@ async function monitor_shell(item, cookies)
async function monitor_dom(item , cookies)
{
const { url, path, id, ignore_path,click_path,scroll_down } = item;
const { url, path, id, ignore_path,click_path,data_path,scroll_down } = item;
const delay = (parseInt(item.delay)||0)*1000;
console.log("in dom delay = ",delay);
@@ -513,7 +514,7 @@ async function monitor_dom(item , cookies)
await sleep(1000);
}
ret = await page.evaluate( async (path,browser_code,ignore_path,click_path,scroll_down ) => {
ret = await page.evaluate( async (path,browser_code,ignore_path,click_path,data_path,scroll_down ) => {
// 滚动的页面底部
if( scroll_down && parseInt(scroll_down) > 0 )
@@ -554,13 +555,13 @@ async function monitor_dom(item , cookies)
html += item.outerHTML ? item.outerHTML + "<br/>" : "";
}
return {html,text:path.indexOf(",") >= 0 ? texts.join("\n") :texts[0]||"","all":window.document.documentElement.innerHTML};
},path,browser_code,ignore_path,click_path,scroll_down);
},path,browser_code,ignore_path,click_path,data_path,scroll_down);
if( !ret )
{
console.log("sleep",1000*5);
await sleep(1000*5);
ret = await page.evaluate( async (path,browser_code,ignore_path,click_path,scroll_down) => {
ret = await page.evaluate( async (path,browser_code,ignore_path,click_path,data_path,scroll_down) => {
// 滚动的页面底部
if( scroll_down && parseInt(scroll_down) > 0 )
{
@@ -600,7 +601,7 @@ async function monitor_dom(item , cookies)
html += item.outerHTML ? item.outerHTML + "<br/>" : "";
}
return {html,text:path.indexOf(",") >= 0 ? texts.join("\n") :texts[0]||"","all":window.document.documentElement.innerHTML};
},path,browser_code,ignore_path,click_path,scroll_down);
},path,browser_code,ignore_path,click_path,data_path,scroll_down);
}
const { all,html, ...ret_short } = ret;
@@ -3,7 +3,7 @@
"message": "Check酱"
},
"appDesc": {
"message": "监控页面变动,并发送异动到微信。 Build.2022.08.01.15.59",
"message": "监控页面变动,并发送异动到微信。 Build.2022.08.10.01.22",
"description":"亦支持http status、json和rss监测。配合自架云端,关电脑后也能运行。"
}
}
@@ -1,20 +1,20 @@
{
"files": {
"main.css": "/static/css/main.0e42becb.chunk.css",
"main.js": "/static/js/main.82b4e77e.chunk.js",
"main.js": "/static/js/main.b985a5e4.chunk.js",
"runtime-main.js": "/static/js/runtime-main.17191aad.js",
"static/css/2.65280f5c.chunk.css": "/static/css/2.65280f5c.chunk.css",
"static/js/2.75a81e0e.chunk.js": "/static/js/2.75a81e0e.chunk.js",
"static/js/2.465e7d2f.chunk.js": "/static/js/2.465e7d2f.chunk.js",
"index.html": "/index.html",
"precache-manifest.0e5126865f008783ee373adbb649d9fd.js": "/precache-manifest.0e5126865f008783ee373adbb649d9fd.js",
"precache-manifest.0fd7de5395cfc4062a9344bfcc8632d5.js": "/precache-manifest.0fd7de5395cfc4062a9344bfcc8632d5.js",
"service-worker.js": "/service-worker.js",
"static/media/index.scss": "/static/media/icons-20.cef8cdbb.woff"
},
"entrypoints": [
"static/js/runtime-main.17191aad.js",
"static/css/2.65280f5c.chunk.css",
"static/js/2.75a81e0e.chunk.js",
"static/js/2.465e7d2f.chunk.js",
"static/css/main.0e42becb.chunk.css",
"static/js/main.82b4e77e.chunk.js"
"static/js/main.b985a5e4.chunk.js"
]
}
+61 -35
View File
@@ -10,39 +10,46 @@ async function show_inspector( tabid,inspector )
maxZIndex: 9999,
onClick: async (path) => {
var getFavicon = function(){
var favicon = undefined;
var nodeList = document.getElementsByTagName("link");
for (var i = 0; i < nodeList.length; i++)
{
if((nodeList[i].getAttribute("rel") == "icon")||(nodeList[i].getAttribute("rel") == "shortcut icon"))
if( window.confirm( "选择器为"+path+",是否转向到任务添加页面?" ) )
{
var getFavicon = function(){
var favicon = undefined;
var nodeList = document.getElementsByTagName("link");
for (var i = 0; i < nodeList.length; i++)
{
favicon = nodeList[i].getAttribute("href");
if((nodeList[i].getAttribute("rel") == "icon")||(nodeList[i].getAttribute("rel") == "shortcut icon"))
{
favicon = nodeList[i].getAttribute("href");
}
}
return favicon;
}
let icon_url = getFavicon() || "/favicon.ico";
if( icon_url.substring(0,4) != 'http' )
{
if( icon_url.substring(0,2) == '//' )
{
icon_url = window.location.protocol + icon_url;
}else
{
if( icon_url.substring(0,1) != '/' ) icon_url = window.origin+ '/' + icon_url;
else icon_url = window.origin + icon_url;
}
}
return favicon;
}
let icon_url = getFavicon() || "/favicon.ico";
if( icon_url.substring(0,4) != 'http' )
const url = 'index.html#/check/add?path='+encodeURIComponent(path)+'&title='+encodeURIComponent(window.document.title)+'&url='+encodeURIComponent(window.location.href)+'&icon='+encodeURIComponent(icon_url);
// 这里是 content script 同等权限,发送消息来调整网页
const ret = await chrome.runtime.sendMessage({action: "redirect","url":url,"tabid":tabid},);
console.log( "ret" , ret, inspector );
// 因为给元素注入了onclick,这里还是要reload才行
}else
{
if( icon_url.substring(0,2) == '//' )
{
icon_url = window.location.protocol + icon_url;
}else
{
if( icon_url.substring(0,1) != '/' ) icon_url = window.origin+ '/' + icon_url;
else icon_url = window.origin + icon_url;
}
window.location.reload();
}
const url = 'index.html#/check/add?path='+encodeURIComponent(path)+'&title='+encodeURIComponent(window.document.title)+'&url='+encodeURIComponent(window.location.href)+'&icon='+encodeURIComponent(icon_url);
// 这里是 content script 同等权限,发送消息来调整网页
const ret = await chrome.runtime.sendMessage({action: "redirect","url":url,"tabid":tabid},);
console.log( "ret" , ret, inspector );
// 因为给元素注入了onclick,这里还是要reload才行
window.location.reload();
}
});
inspector.enable();
@@ -54,7 +61,7 @@ async function show_inspector( tabid,inspector )
}
// javascript-obfuscator:disable
async function ck_get_content( path,delay=3000, ignore_path = "",click_path = "",scroll_down="0" )
async function ck_get_content( path,delay=3000, ignore_path = "",click_path = "",data_path="",scroll_down="0" )
{
function sleep(ms) {
return new Promise((resolve) => {
@@ -77,7 +84,7 @@ async function ck_get_content( path,delay=3000, ignore_path = "",click_path = ""
});
}
async function dom_mul_select( path, ignore_path = "",click_path = "",scroll_down="0" )
async function dom_mul_select( path, ignore_path = "",click_path = "",data_path="",scroll_down="0" )
{
// 滚动到页面底部
if( scroll_down && parseInt(scroll_down) > 0 )
@@ -113,17 +120,36 @@ async function ck_get_content( path,delay=3000, ignore_path = "",click_path = ""
for( let item of ret )
{
item.querySelectorAll("[src]").forEach( item => { if( item.src.substr(0,4) != 'http' ) { item.src = window.origin +( item.src.substr(0,1) == '/' ? item.src : '/'+ item.src ) } } );
item.querySelectorAll("[href]").forEach( item => { if( item.href.substr(0,4) != 'http' ) { item.href = window.origin +( item.href.substr(0,1) == '/' ? item.href : '/'+ item.href ) } } );
if( item.innerText ) texts.push(item.innerText?.trim());
html += item.outerHTML ? item.outerHTML + "<br/>" : "";
}
return {text:path.indexOf(",") >= 0 ? texts.join("\n") :texts[0]||"",html};
let data_ret = "";
if( data_path )
{
const data_path_items = data_path.split(",");
for( let item of data_path_items )
{
const data_items = window.document.querySelectorAll(item);
for( let data_item of data_items ){
if( data_item )
{
data_ret += data_item.outerHTML ? data_item.outerHTML+"<br/>" : "";
}
}
}
}
return {text:path.indexOf(",") >= 0 ? texts.join("\n") :texts[0]||"",html,"data":data_ret};
}
// await sleep(delay);
await dom_ready();
if( delay > 0 ) await sleep(delay);
const ret = await dom_mul_select(path,ignore_path,click_path,scroll_down);
const ret = await dom_mul_select(path,ignore_path,click_path,data_path,scroll_down);
// 直接提取
if( ret )
{
@@ -133,7 +159,7 @@ async function ck_get_content( path,delay=3000, ignore_path = "",click_path = ""
{
// 失败的话,先延迟再尝试一次
await sleep(3000);
const ret2 = await dom_mul_select(path,ignore_path,click_path,scroll_down);
const ret2 = await dom_mul_select(path,ignore_path,click_path,data_path,scroll_down);
if( ret2 )
{
return ret2;
@@ -142,7 +168,7 @@ async function ck_get_content( path,delay=3000, ignore_path = "",click_path = ""
{
await sleep(3000);
// 再来一次
const ret3 = await dom_mul_select(path,ignore_path,click_path,scroll_down);
const ret3 = await dom_mul_select(path,ignore_path,click_path,data_path,scroll_down);
if( ret3 ) return ret;
}
@@ -211,7 +237,7 @@ chrome.runtime.onMessage.addListener( (request, sender, sendResponse) => {
{
target: {tabId: tab.id},
function: ck_get_content,
args: [request.path,request.delay,request.ignore_path,request.click_path,request.scroll_down]
args: [request.path,request.delay,request.ignore_path,request.click_path,request.data_path,request.scroll_down]
});
// console.log( r );
+1 -1
View File
@@ -1 +1 @@
<!doctype html><html lang="zh-cn"><head><meta charset="utf-8"/><link rel="icon" href="/logo.color.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="web content monitor"/><link rel="apple-touch-icon" href="logo.color.png"/><link rel="manifest" href="/manifest.json"/><title>...</title><link rel="stylesheet" href="/tailwind.min.css"><link href="/static/css/2.65280f5c.chunk.css" rel="stylesheet"><link href="/static/css/main.0e42becb.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="/static/js/runtime-main.17191aad.js"></script><script src="/static/js/2.75a81e0e.chunk.js"></script><script src="/static/js/main.82b4e77e.chunk.js"></script></body></html>
<!doctype html><html lang="zh-cn"><head><meta charset="utf-8"/><link rel="icon" href="/logo.color.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="web content monitor"/><link rel="apple-touch-icon" href="logo.color.png"/><link rel="manifest" href="/manifest.json"/><title>...</title><link rel="stylesheet" href="/tailwind.min.css"><link href="/static/css/2.65280f5c.chunk.css" rel="stylesheet"><link href="/static/css/main.0e42becb.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="/static/js/runtime-main.17191aad.js"></script><script src="/static/js/2.465e7d2f.chunk.js"></script><script src="/static/js/main.b985a5e4.chunk.js"></script></body></html>
+1 -1
View File
@@ -3,7 +3,7 @@
"name": "__MSG_appTitle__",
"description": "__MSG_appDesc__",
"default_locale": "zh_CN",
"version": "0.9.5",
"version": "0.9.6",
"icons": {
"512": "logo.color.png"
},
@@ -0,0 +1,50 @@
self.__precacheManifest = (self.__precacheManifest || []).concat([
{
"revision": "5d3f01c97c0ab12bae7a5f7e1674e402",
"url": "/index.html"
},
{
"revision": "5c12cce1404dabf49f3a",
"url": "/static/css/2.65280f5c.chunk.css"
},
{
"revision": "f861aed79b16d1b199fd",
"url": "/static/css/main.0e42becb.chunk.css"
},
{
"revision": "5c12cce1404dabf49f3a",
"url": "/static/js/2.465e7d2f.chunk.js"
},
{
"revision": "f861aed79b16d1b199fd",
"url": "/static/js/main.b985a5e4.chunk.js"
},
{
"revision": "4d30565b04f5f2725c56",
"url": "/static/js/runtime-main.17191aad.js"
},
{
"revision": "05f1cdadfe476395f60e233b15c22155",
"url": "/static/media/icons-16.05f1cdad.eot"
},
{
"revision": "3c1c220e7a18286503fb431c7a7fe183",
"url": "/static/media/icons-16.3c1c220e.woff"
},
{
"revision": "3cde8748332d1de6b1ae1c2dc5850754",
"url": "/static/media/icons-16.3cde8748.ttf"
},
{
"revision": "0a5c76518a68c185baa2c6744456918c",
"url": "/static/media/icons-20.0a5c7651.eot"
},
{
"revision": "51ec31f302d0072808e1f83f85fea4cd",
"url": "/static/media/icons-20.51ec31f3.ttf"
},
{
"revision": "cef8cdbb9d0ba82e6e19fb0eeba2ac3d",
"url": "/static/media/icons-20.cef8cdbb.woff"
}
]);
@@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
importScripts(
"/precache-manifest.0e5126865f008783ee373adbb649d9fd.js"
"/precache-manifest.0fd7de5395cfc4062a9344bfcc8632d5.js"
);
self.addEventListener('message', (event) => {
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -20,9 +20,9 @@
</ol>
<h2>最新版本</h2>
<ul>
<li>插件·Chrome/Edge2022.08.01.15.59 <a href="ckc.zip">下载</a> (<a href="https://github.com/easychen/checkchan-dist/raw/master/ckc.zip">Github下载地址,无需注册</a>)</li>
<li>Docker镜像(云端+远程桌面二合一)2022.08.01.15.50 <a href="https://hub.docker.com/repository/docker/easychen/checkchan" rel="nofollow">Docker Hub</a></li>
<li>文档:2022.08.01.15.59</li>
<li>插件·Chrome/Edge2022.08.10.01.22 <a href="ckc.zip">下载</a> (<a href="https://github.com/easychen/checkchan-dist/raw/master/ckc.zip">Github下载地址,无需注册</a>)</li>
<li>Docker镜像(云端+远程桌面二合一)2022.08.10.00.19 <a href="https://hub.docker.com/repository/docker/easychen/checkchan" rel="nofollow">Docker Hub</a></li>
<li>文档:2022.08.10.01.22</li>
<li>更新日志:<a href="https://github.com/easychen/checkchan-dist/commits/main">GitHub</a></li>
<li>生态:RSSHub浏览器插件整合版(<a href="https://github.com/easychen/RSSHub-Radar-with-checkchan">源码</a> | <a href="https://github.com/easychen/RSSHub-Radar-with-checkchan/releases/download/main/1.7.0.with-checkchan.zip">下载</a></li>
</ul>
+3 -3
View File
@@ -9,9 +9,9 @@
</ol>
<h2>最新版本</h2>
<ul>
<li>插件·Chrome/Edge2022.08.01.15.59 <a href="ckc.zip">下载</a> (<a href="https://github.com/easychen/checkchan-dist/raw/master/ckc.zip">Github下载地址,无需注册</a>)</li>
<li>Docker镜像(云端+远程桌面二合一)2022.08.01.15.50 <a href="https://hub.docker.com/repository/docker/easychen/checkchan" rel="nofollow">Docker Hub</a></li>
<li>文档:2022.08.01.15.59</li>
<li>插件·Chrome/Edge2022.08.10.01.22 <a href="ckc.zip">下载</a> (<a href="https://github.com/easychen/checkchan-dist/raw/master/ckc.zip">Github下载地址,无需注册</a>)</li>
<li>Docker镜像(云端+远程桌面二合一)2022.08.10.00.19 <a href="https://hub.docker.com/repository/docker/easychen/checkchan" rel="nofollow">Docker Hub</a></li>
<li>文档:2022.08.10.01.22</li>
<li>更新日志:<a href="https://github.com/easychen/checkchan-dist/commits/main">GitHub</a></li>
<li>生态:RSSHub浏览器插件整合版(<a href="https://github.com/easychen/RSSHub-Radar-with-checkchan">源码</a> | <a href="https://github.com/easychen/RSSHub-Radar-with-checkchan/releases/download/main/1.7.0.with-checkchan.zip">下载</a></li>
</ul>