泛采专业版插件

1.检测后台服务是否异常,2.ESC关闭置顶弹出窗.3.保存快捷键, 4.检测meta, 5.confluence显示导航栏

目前為 2022-03-25 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         泛采专业版插件
// @include      *://*/*
// @match        *://*/*
// @require        https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js
// @icon           https://www.valuesimplex.com/images/favicon.ico
// @icon64          https://www.valuesimplex.com/images/favicon.ico
// @grant           GM_xmlhttpRequest
// @version      2.5.6
// @description  1.检测后台服务是否异常,2.ESC关闭置顶弹出窗.3.保存快捷键, 4.检测meta, 5.confluence显示导航栏
// @author       房天生
// @grant             GM_info
// @namespace https://raw.githubusercontent.com/fangtiansheng/xinhua/master/script/baelish.js
// ==/UserScript==

(function () {
    "use strict";
    // 定时ping泛采系统查看服务是否在线
    if (window.document.location.href.endsWith("#/home/crawl")) {
        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:#5D5D5D ; padding: 1px; border-radius: 3px 0 0 3px;  color: #fff",
            "background:#0D7FBF ; padding: 1px; border-radius: 0 3px 3px 0;  color: #fff",
            "background:transparent"
        );
    }


    //定时扫描项目报警数量(禁用)
    if (1 === 2 && window.location.hostname === "baelish.data.prod.valuesimplex.tech") {
        setInterval(async () => {
            await fetch(
                "https://baelish.data.prod.valuesimplex.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 names = [];
                    for (let each of data) {
                        if (each.warning_count > 0 && each.id !== 97) {
                            names.push(each.name);
                        }
                    }
                    return names;
                })
                .then(function (names) {
                    if (names.length > 0) {
                        window.document.title = "🔥报警: " + names.join(", ");
                    }
                });
            let list = JSON.parse(localStorage.getItem("report_ids"));
            if (list.length > 0) {
                console.log("共", list.length, "条警告。");
                let url =
                    "spider/monitor?type=delete_report_history&report_id=" +
                    list.toString();
                fetch(url, {
                    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":
                            '"Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"',
                        "sec-ch-ua-mobile": "?0",
                        "sec-fetch-dest": "empty",
                        "sec-fetch-mode": "cors",
                        "sec-fetch-site": "same-origin",
                    },
                    referrerPolicy: "no-referrer",
                    body: null,
                    method: "DELETE",
                    mode: "cors",
                    credentials: "include",
                });
            } else {
                console.log("目前没有告警。");
            }
        }, interval);
    }
    if (window.location.hostname.endsWith("xhszjs.cn")) {
        setInterval(async () => {
            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);
    }
    // ESC关闭置顶弹出窗
    window.addEventListener("keydown", function (e) {
        if (e.keyCode === 27) {
            console.log("esc 按了");
            //全部弹窗
            var popups = document.getElementsByClassName("popup_hover");
            for (let i = popups.length; i--;) {
                //遍历全部弹窗
                if (popups[i].style.display === "") {
                    //查找弹出的窗口
                    let icon_close = popups[i].getElementsByClassName("popup_head_close_icon");
                    icon_close[0].click();
                    break;
                }
            }
        }
    });
    //保存
    window.addEventListener('keydown', e => {
        if (e.ctrlKey && e.key === 's') {
            // Prevent the Save dialog to open
            e.preventDefault();
            // Place your code here
            var button = document.getElementsByClassName("pageDetail_toolBox_item")[0] || document.getElementsByClassName("planDetail_toolBox_item")[0]
            button.getElementsByTagName("button")[0].click()
        }
    });
    //检测meta标签
    let title = window.document.title;
    if (document.getElementsByName("ArticleTitle").length) {
        console.log('.//*[@name="ArticleTitle"]/@content');
        setInterval(
            function () {
                if (window.document.title.startsWith("🔴")) {
                    window.document.title = "⚪️" + title;
                } else {
                    window.document.title = "🔴" + title;
                }
            }, 600);
    }
    if (document.getElementsByName("PubDate").length || document.getElementsByName("pubdate").length) {
        console.log('.//*[translate(@name, "PUBDATE", "pubdate")="pubdate"]/@content');
    }
    if (document.getElementsByName("ColumnName").length) {
        console.log('.//*[translate(@name, "COLUMNNAME", "columnname")="columnname"]/@content');
    }
    if (document.getElementsByName("ContentSource").length || document.getElementsByName("contentSource").length) {
        console.log('.//*[translate(@name, "CONTENTSOURCE", "contentsource")="contentsource"]/@content');
    }
    if (location.hostname.startsWith("confluence")) {
        document.getElementsByClassName("aui-header-primary")[0].getElementsByClassName("aui-nav")[0].style.width = "auto";
    }
})();