创建插件以检测可疑的 AJAX
create plugins to detect suspicious ajax
我想为Firefox制作浏览器扩展,以检测加载隐藏页面并重定向到新页面的网站的ajax代码,例如如果用户访问index.php其中ajax加载两个页面一个是隐藏页面.php并重定向到new.php。是否有任何其他解决方案可以在客户端检测此ajax。
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//document.getElementById("myDiv").innerHTML="";
}
}
xmlhttp.open("GET","hidden.php",true);
xmlhttp.send();
}
.HTML
<a href="new.php" onclick="function();">click here</a>
document.addEventListener('DOMContentLoaded', function() {
getCurrentTabUrl(function(url) {
fetchData(url);
});
});
function fetchData(url)
{
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange=function()
{
if (xhr.readyState==4 && xhr.status==200)
{
var data = xhr.responseText;
var index = data.indexOf('XMLHttpRequest');
if(index != -1){
document.getElementById("status").innerHTML = "The page contains AJAX requests";
}else{
document.getElementById("status").innerHTML = "Page doesn't contains AJAX";
}
//document.getElementById("status").innerHTML = data;
}
}
//xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
//xhr.setRequestHeader("Access-Control-Request-Method", "POST");
xhr.send();
}
function getCurrentTabUrl(callback) {
var queryInfo = {
active: true,
currentWindow: true
};
chrome.tabs.query(queryInfo, function(tabs) {
var tab = tabs[0];
var url = tab.url;
console.assert(typeof url == 'string', 'tab.url should be a string');
callback(url);
});
}
just go through this code you will get the better help
您可以在用户脚本中修改XMLHttpRequest
的原型。
/* Save the old method somewhere, it may be useful if you want to allow some AJAX */
XMLHttpRequest.prototype._send = XMLHttpRequest.prototype.send;
/* Override the previous method to define yours */
XMLHttpRequest.prototype.send = function () {
/* Do stuff here */
alert(1);
/* Use this line if you want to continue the AJAX request */
XMLHttpRequest.prototype._send.apply(this, arguments);
}
相关文章:
- 在PHP中检测AJAX请求来自哪个文件
- 如何在UIWebView中检测AJAX何时更新标题
- 检测ajax提交
- 创建插件以检测可疑的 AJAX
- jquery live 函数未检测到 AJAX 调用更改
- 在Ajax调用中检测Javascript篡改
- 如何检测通过JSON数据引用的图像何时加载AJAX
- 检测ajax请求的跨域重定向
- 在PHP页面中检测AJAX请求
- 检测被用户操作中断的 Ajax 请求
- 检测是否已发送 Ajax 请求
- 如何在检测到 IE8 时禁用 ajax
- 检测任何 ajax 调用何时失败
- 检测使用 ajaxSend 调用的 jquery ajax 方法
- 如何检测从 ajax 加载的内容中选择的变化
- JavaScript:检测 AJAX 请求
- 如何在不使用 DOM 突变事件的情况下检测 AJAX 节点插入
- jQuery ajaxComplete() 检测原型 js ajax 调用
- 使用ajax检测阵列
- 用AJAX检测登录超时,然后用.net重新登录