clog2bat

访问 clog 单条日志时重定向至 bat 日志

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         clog2bat
// @home-url     https://greasyfork.org/zh-CN/scripts/468786-clog2bat
// @version      1.1
// @description  访问 clog 单条日志时重定向至 bat 日志
// @author       zwang57
// @match        http://logging.fws.qa.nt.ctripcorp.com/#/one-log/*
// @match        http://logging.ctripcorp.com/#/one-log/*
// @downloadURL
// @grant    GM_setClipboard
// @grant GM_getResourceText
// @grant GM_addStyle
// @license MIT
// @namespace http://tampermonkey.net/
// ==/UserScript==
(function () {
    'use strict';
    //示例
    //http://logging.fws.qa.nt.ctripcorp.com/#/one-log/10.128.191.40-5-20230616134612-2589377871-4/1686895173697?app=100025553
    //http://bat.api.fws.qa.nt.ctripcorp.com/clog/100025553/one-log?rowKey=10.128.191.40-5-20230616134612-2589377871-4

    //http://logging.ctripcorp.com/#/one-log/1669607237981569146/1686900359994?app=100020533
    //http://bat-api-datasource.ctripcorp.com/clog/100020533/one-log?rowKey=1669607237981569146

    var baseUrl;
    if (document.domain == "logging.ctripcorp.com") {
        baseUrl = "http://bat-api-datasource.ctripcorp.com/clog/"
    } else if (document.domain == "logging.fws.qa.nt.ctripcorp.com") {
        baseUrl = "http://bat.api.fws.qa.nt.ctripcorp.com/clog/"
    }

    // 获取当前链接
    var currentUrl = window.location.href;
    var parts = currentUrl.split('/'); // 先按照 / 分割字符串
    var rowKey = parts[parts.length - 2]; // 倒数第二个部分即为需要的 rowKey
    var app = currentUrl.split('=')[1]; // 按照 = 分割字符串,取第二个部分即为需要的 app
    var newUrl = baseUrl + app + "/one-log?rowKey=" + rowKey;
    console.log(newUrl);
    window.location.href = newUrl;
})();