clog2bat

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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;
})();