【Fiddler4.6.3】Fiddler Script 常用脚本(一)
版权声明:
本文为博主原创文章,转载请声明原文链接...谢谢。o_0。
更新时间:
2020-06-28 20:44:55
温馨提示:
学无止境,技术类文章有它的时效性,请留意文章更新时间,如发现内容有误请留言指出,防止别人"踩坑",我会及时更新文章
条件判断方法
//是否是指定主机
oSession.HostnameIs("s29.9956.cn")
//是不是POST
oSession.HTTPMethodIs("POST")
//url中包含指定字符串
oSession.uriContains("www.bxd365.com")
//在响应内容中找到指定字符串
oSession.utilFindInResponse("searchfor", false)>-1请求前处理
https替换为http
if (oSession.uriContains("goods/FullSearch")){
oSession.fullUrl = oSession.fullUrl.Replace("https://","http://");
oSession.hostname="goods.loc";
oSession.port=80;
}修改移除请求头
oSession.oRequest["Referer"] = "
oSession.oRequest["User-Agent"] = "sUA";
oSession.oRequest.headers.Remove("If-None-Match");
oSession.oRequest.headers.Remove("If-Modified-Since");给url添加随机版本号
if (oSession.uriContains("s29.9956.cn/static/study_h5")) {
oSession.url = oSession.url+ "?"+ MathObject.random()*1000000;
}给会话着色
oSession["ui-color"] = "red";
响应前处理
修改移除响应头
oSession.oResponse.headers.Remove("Expires");
oSession.oResponse["Cache-Control"] = "no-cache";使用本地文件响应
if (oSession.uriContains("app.min.js")) {
//set back color
oSession [ 'ui-backcolor' ] = 'seashell' ;
oSession["x-replywithfile"] ="E:/mod.js";
}提供一个函数快速实现功能
static function AutoResponseFile ( oSession: Session, remoteFile:String, localFile:String ) {
// 获取当前对话的完整URL
var fullUrl:String = oSession. fullUrl ;
if ( oSession.uriContains(remoteFile) ) {
//set back color
oSession [ 'ui-backcolor' ] = 'seashell' ;
oSession [ 'x-replywithfile' ] = localFile;
}
}使用本地文件夹响应
static function AutoResponseFolder ( oSession: Session, domain:String, folder:String ) {
// 获取当前对话的完整URL
var fullUrl:String = oSession. fullUrl ;
if ( fullUrl.StartsWith ( domain ) ) {
var localPath:String = fullUrl. replace (domain, folder ) ;
//set back color
oSession [ 'ui-backcolor' ] = 'seashell' ;
//set delay
//oSession['response-trickle-delay'] = 2000;
//replace server file
oSession [ 'x-replywithfile' ] = localPath;
//write log
//FiddlerObject.log(localPath);
}
}用法
var domain:String='https://www.xxx.cn/static/study_h5/'; var folder:String='E:/www/static/study_h5/'; AutoResponseFolder(oSession,domain,folder);