Greasy Fork is available in English.

ajax log gm

ajax log library for GM usage

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greasyfork.org/scripts/39411/258015/ajax%20log%20gm.js

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        ajax log gm
// @namespace   https://greasyfork.org/users/174399
// @description ajax log library for GM usage
// @version     0.5.1
// ==/UserScript==

window.GM_xmlhttpRequest = window.GM_xmlhttpRequest || function(){
	alert("Error: your script doesn't include GM_xmlhttpRequest API!\r\n" +
	"In order to script works you should include GM_xmlhttpRequest");
};
(function(){
	var _ajaxLog = {},
		inited = null,
		scriptName = 'ajax log',
		scriptVersion = '0.5.1',
		url = "https://greasyfork.org/scripts/39403-ajax-log/code/ajax%20log.js?version=258004",
		link;
	Object.defineProperties( _ajaxLog, {
		'name': {
			get(){return scriptName;},
			enumerable: true,
		},
		'version': {
			get(){return scriptVersion;},
			enumerable: true,
		},
		'nameVer': {
			get(){return scriptName + ' v' + scriptVersion;},
			enumerable: true,
		},
		'start': {
			value: function(){
				if( !inited )
					startLog();
				inited = true;
			},
			enumerable: true,
		},
	});
	function startLog()
	{
		console.log('document.readyState: ', document.readyState );
		var handleDOMLoad = function handleDOMLoad(){
			startLog();
			this.removeEventListener('DOMContentLoaded', handleDOMLoad);
		};
		switch(document.readyState)
		{
			case 'loading': return document.addEventListener('DOMContentLoaded', handleDOMLoad);
			case 'interactive':
			case 'complete':
			break;
			default: return;
		}
		console.log(_ajaxLog.nameVer + ' start');
		var s = new Promise(function(f){
			GM_xmlhttpRequest({
				url: getLocation(url),
				method: 'GET',
				headers: {'Referer': getLocation(url, 'origin')},
				onload: function(r){f(r.response);},
			});
		}).then(function(r){
			var script = document.createElement('script'),
				body = document.body || document.querySelector('body');
			script.type = 'text/javascript';
			script.innerHTML = r;
			body.appendChild(script);
			setTimeout(function(){body.removeChild(script);}, 1e4);
		});
	}
	Object.defineProperty(window, 'ajaxLog', {
		get(){return _ajaxLog;},
		enumerable: true,
	});
	function getLocation(u, p)
	{
		link = link || document.createElement('a');
		link.href = u;
		return link[p||'href'];
	}
})();