HTTP Request Sniffer

log http requests made with javascript in the console.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         HTTP Request Sniffer
// @namespace    HTTP Request Sniffer
// @version      1.0
// @description  log http requests made with javascript in the console.
// @author       Turtle ? Clan
// @license      GPL
// @match        *://*/*
// @grant        none
// @run-at       document-start
// ==/UserScript==
var createElement = function(tag, attributes, value) {
   var element       = document.createElement(tag);
   element.innerText = value || '';
   for ( var i = 0; attributes && i < attributes.length; i += 2 ) {
      element.setAttribute(attributes[i], attributes[i + 1]);
   }
   return element;
};

var injectScript = function(element, callback) {
   var script = createElement('script', ['type', 'text/javascript'], '(' + String(callback) + '())');
   element.appendChild(script);
};

var requestSniffer = function() {
   var self     = {};
   self.request = {};
   self.open    = XMLHttpRequest.prototype.open;
   self.send    = XMLHttpRequest.prototype.send;
   self.header  = XMLHttpRequest.prototype.setRequestHeader;
   XMLHttpRequest.prototype.open = function() {
      self.request         = {};
      self.request.method  = arguments['0'];
      self.request.url     = arguments['1'];
      self.request.headers = [];
      self.open.apply(this, arguments);
   };
   XMLHttpRequest.prototype.setRequestHeader = function() {
      self.request.headers.push(arguments['0']);
      self.request.headers.push(arguments['1']);
      self.header.apply(this, arguments);
   };
   XMLHttpRequest.prototype.send = function() {
      self.request.post = arguments['0'] || false;
      self.send.apply(this, arguments);
      console.log(self.request);
   };
};

injectScript(document.body || document.head || document.documentElement, requestSniffer);