泛采专业版插件

1.检测后台服务是否异常,2.项目报警提示功能

当前为 2021-04-02 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         泛采专业版插件
// @namespace    https://raw.githubusercontent.com/fangtiansheng/xinhua/master/script/baelish.js
// @include        *://spider.vpc.shangjian.tech/*
// @include        *://baelish.zncjtest.xhszjs.cn/*
// @include        *://baelish-zncj.xhszjs.com/*
// @include        *://8.131.101.146:30726/*
// @require        https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js
// @icon           https://www.valuesimplex.com/favicon.ico
// @icon64          https://www.valuesimplex.com/favicon.ico
// @grant           GM_xmlhttpRequest
// @version      2.3.2
// @description  1.检测后台服务是否异常,2.项目报警提示功能
// @author       房天生
// @match        *://spider.vpc.shangjian.tech/*
// @match        *://baelish.zncjtest.xhszjs.cn/*
// @match        *://baelish-zncj.xhszjs.com/*
// @match        *://8.131.101.146:30726/*
// @grant             GM_info
// ==/UserScript==

(function () {
    "use strict";
    // 定时ping泛采系统查看服务是否在线
    const scriptInfo = GM_info.script;
    const version = scriptInfo.version;
    var interval = 1000 * 20;

    var ping = function () {
        let xhr = new XMLHttpRequest();
        xhr.open("GET", "crawl/crawl/get-user-list");
        xhr.onreadystatechange = function () {
            let head = document.getElementsByClassName("head")[0];
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    head.style.backgroundColor = "";
                    window.document.title = "爬虫管理系统";
                } else {
                    head.style.backgroundColor = "gray";
                    window.document.title = "🔥后台服务异常🔥";
                }
            }
        };
        xhr.send();
    };

    window.setInterval(ping, interval);
    console.log(
        `%c 泛采系统专业版插件 %c v${version} %c`,
        "background:#0049b0 ; padding: 1px; border-radius: 3px 0 0 3px;  color: #fff",
        "background:#f56c6c ; padding: 1px; border-radius: 0 3px 3px 0;  color: #fff",
        "background:transparent"
    );

    //定时扫描项目报警数量
    if (window.location.hostname === "spider.vpc.shangjian.tech") {
        setInterval(async () => {
            const project = await fetch(
                "https://spider.vpc.shangjian.tech/spider/project",
                {
                    headers: {
                        accept: "application/json, text/plain, */*",
                        "accept-language":
                            "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
                        "cache-control": "no-cache",
                        pragma: "no-cache",
                        "sec-ch-ua":
                            '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
                        "sec-ch-ua-mobile": "?0",
                        "sec-fetch-dest": "empty",
                        "sec-fetch-mode": "cors",
                        "sec-fetch-site": "same-origin",
                    },
                    referrerPolicy: "no-referrer",
                    body: null,
                    method: "GET",
                    mode: "cors",
                    credentials: "include",
                }
            )
                .then((response) => response.json())
                .then(function (response) {
                    let data = response.data;
                    let count = 0;
                    let names = [];
                    for (let i = 0; i < data.length; i++) {
                        if (data[i].warning_count > 0 && data[i].id !== 97) {
                            names.push(data[i].name);
                        }
                    }
                    return names;
                })
                .then(function (names) {
                    //console.log("[+]项目中 "+names.length+"个报警。");
                    if (names.length > 0) {
                        window.document.title = "🔥报警: " + names.join(", ");
                    }
                });
        }, interval);
    };
    if (window.location.hostname.endsWith("xhszjs.cn")) {
        setInterval(async () => {
            const project = await fetch(window.location.origin, {
                headers: {
                    accept:
                        "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
                    "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
                    "cache-control": "no-cache",
                    pragma: "no-cache",
                    "upgrade-insecure-requests": "1",
                },
                referrer: "http://baelish.zncjtest.xhszjs.cn/",
                referrerPolicy: "strict-origin-when-cross-origin",
                body: null,
                method: "GET",
                mode: "cors",
                credentials: "include",
            });
        }, interval);
    };
})();