支持自架云端执行自定义代码

This commit is contained in:
EasyChen
2022-06-01 13:44:10 +08:00
parent 0ca6aec2eb
commit d3ca210639
7 changed files with 38 additions and 20 deletions
+3 -3
View File
@@ -12,10 +12,10 @@
## 最新版本
- 插件·Chrome/Edge2022.05.31.15.26 [下载](ckc.zip)
- 自架云端Docker镜像:2022.05.31.15.24 [Docker Hub](https://hub.docker.com/repository/docker/easychen/checkchan)
- 插件·Chrome/Edge2022.06.01.13.42 [下载](ckc.zip)
- 自架云端Docker镜像:2022.06.01.13.38 [Docker Hub](https://hub.docker.com/repository/docker/easychen/checkchan)
- 远程桌面版Docker镜像:[Docker Hub](https://hub.docker.com/repository/docker/easychen/checkchan-chrome)
- 文档:2022.05.31.15.26
- 文档:2022.06.01.13.42
- 更新日志:[GitHub](https://github.com/easychen/checkchan-dist/commits/main)
自架云端 Docker 命令( 将`API Key``YouRAPiK1`替换成`任意你想要的安全密码不要带$`:
+1 -1
View File
@@ -1 +1 @@
"2022.05.31.15.26"
"2022.06.01.13.42"
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
"2022.05.31.15.24"
"2022.06.01.13.38"
+27 -9
View File
@@ -193,7 +193,7 @@ exports.monitor_auto = async ( item, cookies ) =>
break;
case 'dom':
default:
ret = await monitor_dom( item.url, item.path, (parseInt(item.delay)||0)*1000, the_cookies, item.id );
ret = await monitor_dom( item , the_cookies );
return {status:!!(ret&&ret.text),value:ret.text||"",type:item.type,html:ret.html||"",link:ret.link||""};
}
} catch (error) {
@@ -272,8 +272,9 @@ async function monitor_rss(url,timeout=10000)
return ret;
}
async function monitor_dom_low(url, path, delay , cookies)
async function monitor_dom_low(item, cookies)
{
const { url, path, delay } = item;
console.log("in low dom");
try {
const response = await fetch( url, { signal: timeoutSignal(delay<1?10000:delay) } );
@@ -302,12 +303,15 @@ async function monitor_dom_low(url, path, delay , cookies)
}
}
async function monitor_dom(url, path, delay , cookies, id)
async function monitor_dom(item , cookies)
{
const { url, path, id } = item;
const delay = (parseInt(item.delay)||0)*1000;
console.log("in dom delay = ",delay);
if((!process.env.SNAP_URL_BASE) && delay < 1 )
if((!process.env.SNAP_URL_BASE) && delay < 1 && !item.puppeteer_code && !item.browser_code )
{
const first = await monitor_dom_low(url, path, delay , cookies);
const first = await monitor_dom_low( item , cookies);
console.log( "low result" , first.text );
if( first && first.text ) return first;
}else
@@ -336,8 +340,10 @@ async function monitor_dom(url, path, delay , cookies, id)
if( isIterable(cookies) )
await page.setCookie( ...cookies );
await page.evaluateOnNewDocument(() => { HTMLVideoElement.prototype.canPlayType = function () { return 'probably' }; });
await page.evaluateOnNewDocument(() => { HTMLVideoElement.prototype.canPlayType = function () { return 'probably' }; });
const { puppeteer_code, browser_code } = item;
try {
await page.goto(url,{
@@ -350,7 +356,19 @@ async function monitor_dom(url, path, delay , cookies, id)
await sleep(delay);
}
ret = await page.evaluate( (path) => {
if( puppeteer_code )
{
const hot_code = `(async( browser,page,puppeteer_code ) =>
{
${puppeteer_code}
})( browser,page,puppeteer_code )`;
// console.log( hot_code );
eval( hot_code );
await sleep(1000);
}
ret = await page.evaluate( (path,browser_code ) => {
if( browser_code ) eval( browser_code );
let ret = window.document.querySelectorAll(path);
if( !ret ) return false;
console.log("query fail",path,ret);
@@ -364,7 +382,7 @@ async function monitor_dom(url, path, delay , cookies, id)
html += item.outerHTML ? item.outerHTML + "<br/>" : "";
}
return {html,text:path.indexOf(",") >= 0 ? texts.join("\n") :texts[0]||"","all":window.document.documentElement.innerHTML};
},path);
},path,browser_code);
if( !ret )
{
+3 -3
View File
@@ -20,10 +20,10 @@
</ol>
<h2>最新版本</h2>
<ul>
<li>插件·Chrome/Edge2022.05.31.15.26 <a href="ckc.zip">下载</a></li>
<li>自架云端Docker镜像:2022.05.31.15.24 <a href="https://hub.docker.com/repository/docker/easychen/checkchan" rel="nofollow">Docker Hub</a></li>
<li>插件·Chrome/Edge2022.06.01.13.42 <a href="ckc.zip">下载</a></li>
<li>自架云端Docker镜像:2022.06.01.13.38 <a href="https://hub.docker.com/repository/docker/easychen/checkchan" rel="nofollow">Docker Hub</a></li>
<li>远程桌面版Docker镜像:<a href="https://hub.docker.com/repository/docker/easychen/checkchan-chrome" rel="nofollow">Docker Hub</a></li>
<li>文档:2022.05.31.15.26</li>
<li>文档:2022.06.01.13.42</li>
<li>更新日志:<a href="https://github.com/easychen/checkchan-dist/commits/main">GitHub</a></li>
</ul>
<p>自架云端 Docker 命令( 将<code class="notranslate">API Key</code><code class="notranslate">YouRAPiK1</code>替换成<code class="notranslate">任意你想要的安全密码不要带$</code>:</p>
+3 -3
View File
@@ -9,10 +9,10 @@
</ol>
<h2>最新版本</h2>
<ul>
<li>插件·Chrome/Edge2022.05.31.15.26 <a href="ckc.zip">下载</a></li>
<li>自架云端Docker镜像:2022.05.31.15.24 <a href="https://hub.docker.com/repository/docker/easychen/checkchan" rel="nofollow">Docker Hub</a></li>
<li>插件·Chrome/Edge2022.06.01.13.42 <a href="ckc.zip">下载</a></li>
<li>自架云端Docker镜像:2022.06.01.13.38 <a href="https://hub.docker.com/repository/docker/easychen/checkchan" rel="nofollow">Docker Hub</a></li>
<li>远程桌面版Docker镜像:<a href="https://hub.docker.com/repository/docker/easychen/checkchan-chrome" rel="nofollow">Docker Hub</a></li>
<li>文档:2022.05.31.15.26</li>
<li>文档:2022.06.01.13.42</li>
<li>更新日志:<a href="https://github.com/easychen/checkchan-dist/commits/main">GitHub</a></li>
</ul>
<p>自架云端 Docker 命令( 将<code class="notranslate">API Key</code><code class="notranslate">YouRAPiK1</code>替换成<code class="notranslate">任意你想要的安全密码不要带$</code>:</p>