Created
September 30, 2022 06:33
-
-
Save ipaler/7fdb1c894e60dd325a6aa0fe02d1aeb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rules中勾选启用功能 | |
public static RulesOption("标记返回值指定string") | |
var m_showMarkString: boolean = false; | |
public static RulesOption("替换返回值指定string") | |
var m_showReplaceString: boolean = true; | |
static function OnBeforeResponse(oSession: Session) { | |
oSession.oResponse["My_URL"] = oSession.url; | |
// 指定URL | |
if (oSession.url == "www.baidu.com/space/info?b=1575658832749793280&f=1575658832896593920&c=1532186630515986432") { | |
oSession.oResponse["Custom_Config"] = "u1"; | |
} | |
//替换response中指定string,引号需转义 | |
if ( m_showMarkString && oSession.HostnameIs("www.baidu.com") && oSession.oResponse.headers.ExistsAndContains("Content-Type","application/json")){ | |
//以decode格式解码 | |
oSession.utilDecodeResponse(); | |
//需要标记的字符串 | |
var oFindStrings = new Array( "www.baidu.com","z11","v3/deal/all"); | |
// For each target string, check the response to see if it's present. | |
var iEach=0; | |
oSession["ui-customcolumn"]=String.Empty; | |
for (iEach; iEach<oFindStrings.length; iEach++){ | |
if (oSession.utilFindInResponse(oFindStrings[iEach], false)>0 ) { | |
//标记颜色 | |
oSession["ui-color"]="#EE00EE"; | |
//加粗 | |
oSession["ui-bold"]="true"; | |
//在custom标识response中有的关键字 | |
oSession["ui-customcolumn"] += oFindStrings[iEach]+"; "; | |
} | |
} | |
} | |
//替换response中指定string,引号需转义 | |
if(m_showReplaceString && oSession.HostnameIs("www.baidu.com") && oSession.oResponse.headers.ExistsAndContains("Content-Type","application/json")){ | |
//以decode格式解码 | |
oSession.utilDecodeResponse(); | |
//替换前字符串 | |
var oReplaceStrings = new Array( "\"code\":500","测试字符"); | |
//替换后字符串(一一对应) | |
var oNewStings = new Array("\"code\":200","操作成功"); | |
var iEach=0; | |
oSession["ui-customcolumn"]=String.Empty; | |
for (iEach; iEach<oReplaceStrings.length; iEach++){ | |
// if true | |
if (oSession.utilReplaceInResponse(oReplaceStrings[iEach], oNewStings[iEach])){ | |
//标记颜色 | |
oSession["ui-color"]="#B03060"; | |
//加粗 | |
oSession["ui-bold"]="true"; | |
//在custom标识response中被替换的字符串 | |
oSession["ui-customcolumn"] += oReplaceStrings[iEach]+"; "; | |
} | |
} | |
} | |
if (m_Hide304s && oSession.responseCode == 304) { | |
oSession["ui-hide"] = "true"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment