/*
* Copyright (c) 2009 Eric Lawrence
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* */
var fiddlerhook = {
iInterval: 0,
iFiddlerPort: 8888,
isFiddlerListening: false,
bWatchSSL: true,
prefsProxy: null,
prefsHook: null,
oDynamicKey: null,
//
// This function is executed when our addon is loaded
//
onLoad: function() {
this.initialized = true;
this.strings = document.getElementById("fiddlerhook-strings");
document.getElementById('status-bar-panel-FiddlerHook').label = "Loading FiddlerHook...";
// https://developer.mozilla.org/En/NsIPrefBranch2
var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
this.prefsHook = prefManager.getBranch("extensions.fiddlerhook.");
this.prefsHook.QueryInterface(Components.interfaces.nsIPrefBranch2);
this.prefsHook.addObserver("", this, false);
this.prefsProxy = prefManager.getBranch("network.proxy.");
this.prefsProxy.QueryInterface(Components.interfaces.nsIPrefBranch2);
this.prefsProxy.addObserver("", this, false);
// Set up a monitor the Fiddler 2.2.1 Dynamic\Attached key
this.hookFiddlersDynamicKey();
this.iInterval = setInterval(this.queryRegistry, 1000, this);
this.doAutoUpdate();
this.updateFiddlerHookUI();
},
//
// This function is called when our addon is unloaded. It stops monitoring the keys.
//
onUnload: function() {
window.clearInterval(this.iInterval);
if (null != this.oDynamicKey){
this.oDynamicKey.stopWatching();
this.oDynamicKey.close();
}
if (null != this.prefsHook){
this.prefsHook.removeObserver("", this);
}
if (null != this.prefsProxy){
this.prefsProxy.removeObserver("", this);
}
},
//
// Try to open the Fiddler's registry keys and read its settings.
// Then, get the isFiddlerListening value and set up an observer for changes.
//
hookFiddlersDynamicKey: function() {
try {
var wrk = Components.classes["@mozilla.org/windows-registry-key;1"].createInstance(Components.interfaces.nsIWindowsRegKey);
wrk.open(wrk.ROOT_KEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Fiddler2", wrk.ACCESS_READ); // The required ACCESS_NOTIFY bit is in the ACCESS_READ value
this.iFiddlerPort = wrk.readIntValue("ListenPort");
this.bWatchSSL = ("True" == wrk.readStringValue("CaptureCONNECT"));
this.oDynamicKey = wrk.openChild("Dynamic", wrk.ACCESS_READ);
this.oDynamicKey.startWatching(false);
try {
this.isFiddlerListening = (1 == this.oDynamicKey.readIntValue("Attached"));
}
catch(e){}
return true;
}
catch(e) {
Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService).logStringMessage("FiddlerHook Monitoring Error: " + e.message);
return false;
}
},
//
// This function updates UI elements to match the current monitoring mode
//
updateFiddlerHookUI: function() {
if (null == document) return;
// Determine the current hook mode
var iHookMode = 0;
try{
iHookMode = this.prefsHook.getIntPref("hookmode");
}
catch(e){}
// Update status bar and menu state
switch (iHookMode){
case 0:
document.getElementById('rdoMainFHOptionDisable').setAttribute('checked', 'true');
document.getElementById('rdoFHOptionDisable').setAttribute('checked', 'true');
document.getElementById('status-bar-panel-FiddlerHook').label = "Fiddler: Disabled";
break;
case 1:
document.getElementById('rdoMainFHOptionForce').setAttribute('checked', 'true');
document.getElementById('rdoFHOptionForce').setAttribute('checked', 'true');
document.getElementById('status-bar-panel-FiddlerHook').label = "Fiddler: ForceOn";
break;
case 2:
document.getElementById('rdoMainFHOptionOpportune').setAttribute('checked', 'true');
document.getElementById('rdoFHOptionOpportune').setAttribute('checked', 'true');
document.getElementById('status-bar-panel-FiddlerHook').label =
(this.isFiddlerListening == 1) ? "Fiddler: ON (auto)" : "Fiddler: OFF (auto)";
break;
}
},
//
// This callback function executes if the \Software\Microsoft\Fiddler2\Dynamic\Attached DWORD changes
//
queryRegistry: function(oObj){
if ((null == oObj.oDynamicKey) || !oObj.oDynamicKey.hasChanged()) return; // Bail quickly
var i = 0;
try {
i = oObj.oDynamicKey.readIntValue("Attached");
}
catch (e) {
i = 0;
}
// "this" isn't the object you might expect, so we pass 'ourselves' using oObj. There's a good (complicated) reason for that;
// see https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/this_Operator#Method_binding
oObj.isFiddlerListening = (1 == i);
oObj.doAutoUpdate();
oObj.updateFiddlerHookUI();
},
//
// This callback function executes if any of the preference values we care about have changed.
//
observe: function(subject, topic, data){
if (topic != "nsPref:changed") {
return;
}
switch(data)
{
// network.proxy.*
case "type":
case "http":
case "http_port":
// The user modified the network.proxy.type preferences using the UI.
// TODO: If settings are not pointing at us but should be, we should change UI to "disabled"?
// if ( (this.prefsProxy.getIntPref("type") == 1) && (this.prefsProxy.getCharPref("http") == "localhost") && (this.prefsProxy.getIntPref("http_port") == 8888))
break;
// extension.fiddlerhook.*
case "hookmode":
this.updateFiddlerHookUI();
break;
}
},
//
// This function executes when the user changes the monitoring option using the status bar menu or tools menu
//
onMenuCommand: function(e) {
//Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService).logStringMessage("MenuCommand: " + e.target.id);
switch(e.target.id){
case "rdoMainFHOptionOpportune":
case "rdoFHOptionOpportune":
this.prefsHook.setIntPref("hookmode", 2);
this.doAutoUpdate();
break;
case "rdoMainFHOptionForce":
case "rdoFHOptionForce":
this.prefsHook.setIntPref("hookmode", 1);
this.doAttach();
break;
case "rdoMainFHOptionDisable":
case "rdoFHOptionDisable":
this.prefsHook.setIntPref("hookmode", 0);
this.doDetach();
break;
default:
return; // throw exception?
break;
}
this.updateFiddlerHookUI();
},
//
// This function is called to handle Fiddler attach/detach changes
//
doAutoUpdate: function(){
// Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService).alert(window, "AutoUpdate", "hookmode: " + this.prefsHook.getIntPref("hookmode")+"\n"+ this.isFiddlerListening );
if (2 != this.prefsHook.getIntPref("hookmode")) return;
if (null == this.oDynami
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Fiddler2.rar (46个子文件)
Inspectors
Samples.dll 80KB
Be.Windows.Forms.HexBox.dll 60KB
Standard.dll 80KB
Scripts
VSWebtest
FiddlerWebTestPlugins.dll 16KB
SampleRules.js 13KB
SimpleFilter.dll 48KB
Timeline.dll 48KB
makecert.exe 39KB
ResponseTemplates
200_TransPixel.dat 136B
304_NotModified.dat 71B
204_NoContent.dat 69B
200_SimpleHTML.dat 113B
200_FiddlerGif.dat 396B
404_Plain.dat 615B
307_RedirectWithMethod.dat 146B
401_AuthBasic.dat 670B
302_Redirect.dat 128B
303_RedirectWithGet.dat 138B
403_AuthDeny.dat 594B
502_Unreachable.dat 624B
401_AuthDigest.dat 785B
407_ProxyAuthBasic.dat 682B
IE_Toolbar.ico 4KB
LoadScript.wav 2KB
uninst.exe 49KB
Fiddler.exe 548KB
Xceed.Compression.dll 156KB
FiddlerHook
chrome.manifest 290B
skin
toolbar-button.png 1KB
Thumbs.db 5KB
overlay.css 514B
install.rdf 1KB
defaults
preferences
fiddlerhook.js 670B
locale
en-US
fiddlerhook.dtd 515B
fiddlerhook.properties 76B
about.dtd 123B
Content
fiddlerhook.png 1KB
about.xul 2KB
firefoxOverlay.xul 4KB
overlay.js 14KB
Xceed.Compression.Formats.dll 76KB
ExecAction.exe 40KB
Xceed.FileSystem.dll 120KB
fiddler.exe.config 165B
Xceed.Zip.dll 244KB
saz.ico 11KB
共 46 条
- 1
jielanse
- 粉丝: 8
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页